Allow sending events using metadata server

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
changes/40/40/1
Tomas Sedovic 11 years ago
parent 50d2ca8029
commit 4d432413e1

@ -223,6 +223,20 @@ class EngineManager(manager.Manager):
return {'events': [parse_event(e) for e in events]}
def event_create(self, context, event):
try:
result = db_api.event_create(None, event)
event['id'] = result.id
return [None, event]
except Exception as ex:
logger.warn('db error %s' % str(ex))
try:
# This returns the error message without the entire SQL request
msg = ex.inner_exception.orig[1]
except:
msg = 'Error creating event'
return [msg, None]
def metadata_register_address(self, context, url):
config.FLAGS.heat_metadata_server_url = url

@ -48,6 +48,9 @@ class API(wsgi.Router):
mapper.connect('/stacks/:stack_name/resources/:resource_id',
controller=metadata_controller, action='update_metadata',
conditions=dict(method=['PUT']))
mapper.connect('/events/',
controller=metadata_controller, action='create_event',
conditions=dict(method=['POST']))
# TODO(shadower): make sure all responses are JSON-encoded
# currently, calling an unknown route uses the default handler which

@ -98,6 +98,15 @@ class MetadataController:
'metadata': body,
})
def create_event(self, req, body=None):
con = context.get_admin_context()
[error, event] = rpc.call(con, 'engine',
{'method': 'event_create',
'args': {'event': body}})
if error:
return json_error(400, error)
return json_response(201, event)
def create_resource(options):
"""

Loading…
Cancel
Save