Skip to content

Commit

Permalink
Updated stack blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
nedema committed Oct 11, 2018
1 parent c647277 commit 06a0994
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions blueprints/heat_orchestration/deploy_heat_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from keystoneauth1.identity import v3
from heatclient import client


AUTH_URL = 'https://10.50.1.244:5000/v3'

def run():
Expand All @@ -24,31 +25,19 @@ def run():
timestamp = str(time.time())
timestamp, _ = timestamp.split('.')

stack_name = "HEAT-{}".format(timestamp)
#stack = heat.stacks.create() # list(heat.stacks.list())
stack_name = "HEAT-{}-{}".format(project_id, timestamp)


response = heat.stacks.create(
stack_name=stack_name,
template_url='https://s3.amazonaws.com/hot-template/heat_stack.yml',
parameters=[
{'ParameterKey': 'db_name', 'ParameterValue': 'MyDatabase{}'.format(timestamp)},
{'ParameterKey': 'db_password', 'ParameterValue': '{{DBPassword}}'},
{'ParameterKey': 'db_root_password', 'ParameterValue': '{{DBRootPassword}}'},
{'ParameterKey': 'db_user', 'ParameterValue': 'admin'},
{'ParameterKey': 'image', 'ParameterValue': 'Ubuntu 14'},
{'ParameterKey': 'key_name', 'ParameterValue': 'cb-key'},
{'ParameterKey': 'db_port', 'ParameterValue': '50000'},
{'ParameterKey': 'priv_net', 'ParameterValue': 'int-net'},
{'ParameterKey': 'pub_net', 'ParameterValue': 'ext-net'},
{'ParameterKey': 'flavor', 'ParameterValue': 'm1.small'},
],
)
template_url='https://s3.amazonaws.com/hot-template/heat-stack-sample.yml',
param=None)

logger.debug("Response: {}".format(response))
stack_id = response['Id']


resource = job.parent_job.resource_set.first()
cf, _ = CustomField.objects.get_or_create(name="heat_stack_name", type="STR")
cfv, _ = CustomFieldValue.objects.get_or_create(field=cf, value=stack_name)
resource.attributes.add(cfv)
return ("", "Stack installation initiated, the new stack has name {} and ID {}".format(stack_name, stack_id), "")
return ("", "Stack installation initiated, the new stack has name {}".format(stack_name), "")

0 comments on commit 06a0994

Please sign in to comment.