Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Created March 10, 2017 16:13
Show Gist options
  • Save allthingsclowd/748ffbeb08d91ca1fd0b8831b776e859 to your computer and use it in GitHub Desktop.
Save allthingsclowd/748ffbeb08d91ca1fd0b8831b776e859 to your computer and use it in GitHub Desktop.
Python function to call Fujitsu's K5 IaaS Orchestration EndPoint
def deploy_heat_stack(k5token, stack_name, stack_to_deploy, stack_parameters):
"""Summary : K5 HEAT API call to send a heat stack, wrapped in a string, to a K5 Project
Returns:
TYPE: JSON Object containing the new Stack Id or Error Codes
"""
orchestrationURL = unicode(get_endpoint(k5token, "orchestration")) + unicode("/stacks")
print orchestrationURL
token = k5token.headers['X-Subject-Token']
try:
response = requests.post(orchestrationURL,
headers={
'X-Auth-Token': token, 'Content-Type': 'application/json', 'Accept': 'application/json'},
json={
"files": {},
"disable_rollback": True,
"parameters": stack_parameters,
"stack_name": stack_name,
"template": stack_to_deploy,
"timeout_mins": 60
})
return response
except:
return ("\nUnexpected error:", sys.exc_info())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment