Added ability to add services to environment
This commit is contained in:
parent
250c233db9
commit
270525d732
@ -77,8 +77,9 @@ class HeatExecutor(CommandBase):
|
|||||||
if not len(self._update_pending_list):
|
if not len(self._update_pending_list):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
template = {}
|
template, arguments = self._get_current_template()
|
||||||
arguments = {}
|
stack_exists = (template != {})
|
||||||
|
|
||||||
for t in self._update_pending_list:
|
for t in self._update_pending_list:
|
||||||
template = conductor.helpers.merge_dicts(
|
template = conductor.helpers.merge_dicts(
|
||||||
template, t['template'], max_levels=2)
|
template, t['template'], max_levels=2)
|
||||||
@ -89,7 +90,7 @@ class HeatExecutor(CommandBase):
|
|||||||
'Executing heat template {0} with arguments {1} on stack {2}'
|
'Executing heat template {0} with arguments {1} on stack {2}'
|
||||||
.format(anyjson.dumps(template), arguments, self._stack))
|
.format(anyjson.dumps(template), arguments, self._stack))
|
||||||
|
|
||||||
try:
|
if stack_exists:
|
||||||
self._heat_client.stacks.update(
|
self._heat_client.stacks.update(
|
||||||
stack_id=self._stack,
|
stack_id=self._stack,
|
||||||
parameters=arguments,
|
parameters=arguments,
|
||||||
@ -98,7 +99,7 @@ class HeatExecutor(CommandBase):
|
|||||||
'Waiting for the stack {0} to be update'.format(self._stack))
|
'Waiting for the stack {0} to be update'.format(self._stack))
|
||||||
self._wait_state('UPDATE_COMPLETE')
|
self._wait_state('UPDATE_COMPLETE')
|
||||||
log.info('Stack {0} updated'.format(self._stack))
|
log.info('Stack {0} updated'.format(self._stack))
|
||||||
except heatclient.exc.HTTPNotFound:
|
else:
|
||||||
self._heat_client.stacks.create(
|
self._heat_client.stacks.create(
|
||||||
stack_name=self._stack,
|
stack_name=self._stack,
|
||||||
parameters=arguments,
|
parameters=arguments,
|
||||||
@ -138,6 +139,15 @@ class HeatExecutor(CommandBase):
|
|||||||
item['callback'](True)
|
item['callback'](True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _get_current_template(self):
|
||||||
|
try:
|
||||||
|
stack_info = self._heat_client.stacks.get(stack_id=self._stack)
|
||||||
|
template = self._heat_client.stacks.template(
|
||||||
|
stack_id='{0}/{1}'.format(stack_info.stack_name, stack_info.id))
|
||||||
|
return template, stack_info.parameters
|
||||||
|
except heatclient.exc.HTTPNotFound:
|
||||||
|
return {}, {}
|
||||||
|
|
||||||
def _wait_state(self, state):
|
def _wait_state(self, state):
|
||||||
if isinstance(state, types.ListType):
|
if isinstance(state, types.ListType):
|
||||||
states = state
|
states = state
|
||||||
|
@ -131,10 +131,6 @@
|
|||||||
<set path="::state.primaryDcIp">
|
<set path="::state.primaryDcIp">
|
||||||
<select source="ip" path="0.Result.0"/>
|
<select source="ip" path="0.Result.0"/>
|
||||||
</set>
|
</set>
|
||||||
<report entity="unit">
|
|
||||||
<parameter name="id"><select path="id"/></parameter>
|
|
||||||
<parameter name="text">DNS IP = <select source="ip" path="0.Result.0"/></parameter>
|
|
||||||
</report>
|
|
||||||
</success>
|
</success>
|
||||||
</send-command>
|
</send-command>
|
||||||
</rule>
|
</rule>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<workflow>
|
<workflow>
|
||||||
|
|
||||||
<rule match="$..units[?(@.state.hostname is None)]">
|
<rule match="$.services[*][*].units[?(@.state.hostname is None)]">
|
||||||
<set path="state.hostname"><generate-hostname/></set>
|
<set path="state.hostname"><generate-hostname/></set>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<update-cf-stack template="Windows">
|
<update-cf-stack template="Windows">
|
||||||
<parameter name="mappings">
|
<parameter name="mappings">
|
||||||
<map>
|
<map>
|
||||||
<mapping name="instanceName">WS-<select path="::name"/>-<select path="name"/></mapping>
|
<mapping name="instanceName"><select path="::name"/>-<select path="name"/></mapping>
|
||||||
<mapping name="userData">
|
<mapping name="userData">
|
||||||
<prepare-user-data>
|
<prepare-user-data>
|
||||||
<parameter name="hostname"><select path="state.hostname"/></parameter>
|
<parameter name="hostname"><select path="state.hostname"/></parameter>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user