Heat auto-discovery, keero-linux-keys -> keero-keys

This commit is contained in:
Stan Lagun
2013-03-28 01:11:06 +04:00
parent 600e161f6c
commit f33bd681ab
7 changed files with 357 additions and 352 deletions

View File

@@ -22,42 +22,43 @@ log = logging.getLogger(__name__)
def task_received(task, message_id): def task_received(task, message_id):
with rabbitmq.RmqClient() as rmqclient: with rabbitmq.RmqClient() as rmqclient:
log.info('Starting processing task {0}: {1}'.format( try:
message_id, anyjson.dumps(task))) log.info('Starting processing task {0}: {1}'.format(
reporter = reporting.Reporter(rmqclient, message_id, task['id']) message_id, anyjson.dumps(task)))
reporter = reporting.Reporter(rmqclient, message_id, task['id'])
command_dispatcher = CommandDispatcher( command_dispatcher = CommandDispatcher(
task['id'], rmqclient, task['token'], task['tenant_id']) task['id'], rmqclient, task['token'], task['tenant_id'])
workflows = [] workflows = []
for path in glob.glob("data/workflows/*.xml"): for path in glob.glob("data/workflows/*.xml"):
log.debug('Loading XML {0}'.format(path)) log.debug('Loading XML {0}'.format(path))
workflow = Workflow(path, task, command_dispatcher, config, workflow = Workflow(path, task, command_dispatcher, config,
reporter) reporter)
workflows.append(workflow) workflows.append(workflow)
while True: while True:
try: try:
while True: while True:
result = False result = False
for workflow in workflows: for workflow in workflows:
if workflow.execute(): if workflow.execute():
result = True result = True
if not result: if not result:
break
if not command_dispatcher.execute_pending():
break break
if not command_dispatcher.execute_pending(): except Exception as ex:
log.exception(ex)
break break
except Exception as ex:
log.exception(ex)
break
command_dispatcher.close() command_dispatcher.close()
finally:
del task['token']
result_msg = rabbitmq.Message()
result_msg.body = task
result_msg.id = message_id
del task['token'] rmqclient.send(message=result_msg, key='task-results')
result_msg = rabbitmq.Message()
result_msg.body = task
result_msg.id = message_id
rmqclient.send(message=result_msg, key='task-results')
log.info('Finished processing task {0}. Result = {1}'.format( log.info('Finished processing task {0}. Result = {1}'.format(
message_id, anyjson.dumps(task))) message_id, anyjson.dumps(task)))

View File

@@ -1,6 +1,7 @@
import anyjson import anyjson
import eventlet import eventlet
import jsonpath
from conductor.openstack.common import log as logging from conductor.openstack.common import log as logging
import conductor.helpers import conductor.helpers
from command import CommandBase from command import CommandBase
@@ -20,13 +21,18 @@ class HeatExecutor(CommandBase):
self._stack = 'e' + stack self._stack = 'e' + stack
settings = conductor.config.CONF.heat settings = conductor.config.CONF.heat
client = ksclient.Client(endpoint=settings.keystone) client = ksclient.Client(endpoint=settings.auth_url)
scoped_token = client.tokens.authenticate( auth_data = client.tokens.authenticate(
tenant_id=tenant_id, tenant_id=tenant_id,
token=token).id token=token)
self._heat_client = Client('1', settings.url, scoped_token = auth_data.id
token_only=True, token=scoped_token)
heat_url = jsonpath.jsonpath(auth_data.serviceCatalog,
"$[?(@.name == 'heat')].endpoints[0].publicURL")[0]
self._heat_client = Client('1', heat_url,
token_only=True, token=scoped_token)
def execute(self, command, callback, **kwargs): def execute(self, command, callback, **kwargs):
log.debug('Got command {0} on stack {1}'.format(command, self._stack)) log.debug('Got command {0} on stack {1}'.format(command, self._stack))

View File

@@ -46,8 +46,7 @@ rabbit_opts = [
] ]
heat_opts = [ heat_opts = [
cfg.StrOpt('url'), cfg.StrOpt('auth_url'),
cfg.StrOpt('keystone')
] ]
CONF = cfg.CONF CONF = cfg.CONF

View File

@@ -12,8 +12,8 @@ def send_command(engine, context, body, template, service, host, mappings=None,
def callback(result_value): def callback(result_value):
log.info( log.info(
'Received result from {3} for {0}: {1}. Body is {2}'.format( 'Received result from {2} for {0}: {1}'.format(
template, result_value, body, host)) template, result_value, host))
if result is not None: if result is not None:
context[result] = result_value['Result'] context[result] = result_value['Result']

View File

@@ -25,7 +25,7 @@
</parameter> </parameter>
<parameter name="arguments"> <parameter name="arguments">
<map> <map>
<argument name="KeyName">keero-linux-keys</argument> <argument name="KeyName">keero-keys</argument>
<argument name="InstanceType">m1.medium</argument> <argument name="InstanceType">m1.medium</argument>
<argument name="ImageName">ws-2012-full</argument> <argument name="ImageName">ws-2012-full</argument>
</map> </map>

View File

@@ -25,7 +25,7 @@
</parameter> </parameter>
<parameter name="arguments"> <parameter name="arguments">
<map> <map>
<argument name="KeyName">keero-linux-keys</argument> <argument name="KeyName">keero-keys</argument>
<argument name="InstanceType">m1.medium</argument> <argument name="InstanceType">m1.medium</argument>
<argument name="ImageName">ws-2012-full</argument> <argument name="ImageName">ws-2012-full</argument>
</map> </map>

View File

@@ -4,8 +4,7 @@ debug=True
verbose=True verbose=True
[heat] [heat]
url = http://172.18.124.101:8004/v1/16eb78cbb688459c8308d89678bcef50 auth_url = http://172.18.124.101:5000/v2.0
keystone = http://172.18.124.101:5000/v2.0
[rabbitmq] [rabbitmq]
host = 172.18.124.101 host = 172.18.124.101