Browse Source

Pass the stack_id into the resource_metadata_update

Change-Id: I2b98592cf3970e3cd79ae7002504fb34cf2d42cd
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
changes/42/242/2
Angus Salkeld 10 years ago
parent
commit
8623ba8dbd
  1. 14
      heat/engine/manager.py
  2. 2
      heat/engine/wait_condition.py
  3. 2
      heat/metadata/api/v1/__init__.py
  4. 12
      heat/metadata/api/v1/metadata.py

14
heat/engine/manager.py

@ -433,19 +433,15 @@ class EngineManager(manager.Manager):
return [None, r.rsrc_metadata]
def metadata_update(self, context, stack_name, resource_id, metadata):
def metadata_update(self, context, stack_id, resource_name, metadata):
"""
Update the metadata for the given resource.
"""
s = db_api.stack_get_by_name(None, stack_name)
if not s:
logger.warn("Stack not found %s." % (stack_name))
return ['stack', None]
r = db_api.resource_get_by_name_and_stack(None, resource_id, s.id)
r = db_api.resource_get_by_name_and_stack(None, resource_name,
stack_id)
if r is None:
logger.warn("Resource not found %s:%s." % (stack_name,
resource_id))
logger.warn("Resource not found %s:%s." % (stack_id,
resource_name))
return ['resource', None]
r.update_and_save({'rsrc_metadata': metadata})

2
heat/engine/wait_condition.py

@ -40,7 +40,7 @@ class WaitConditionHandle(Resource):
def handle_create(self):
self.instance_id = '%s/stacks/%s/resources/%s' % \
(self.stack.metadata_server,
self.stack.name,
self.stack.id,
self.name)

2
heat/metadata/api/v1/__init__.py

@ -45,7 +45,7 @@ class API(wsgi.Router):
mapper.connect('/stacks/:stack_name',
controller=metadata_controller, action='create_stack',
conditions=dict(method=['PUT']))
mapper.connect('/stacks/:stack_name/resources/:resource_id',
mapper.connect('/stacks/:stack_id/resources/:resource_name',
controller=metadata_controller,
action='update_metadata',
conditions=dict(method=['PUT']))

12
heat/metadata/api/v1/metadata.py

@ -78,22 +78,22 @@ class MetadataController:
'The resource "%s" does not exist.' % resource_id)
return metadata
def update_metadata(self, req, body, stack_name, resource_id):
def update_metadata(self, req, body, stack_id, resource_name):
con = context.get_admin_context()
[error, metadata] = rpc.call(con, 'engine',
{'method': 'metadata_update',
'args': {'stack_name': stack_name,
'resource_id': resource_id,
'args': {'stack_id': stack_id,
'resource_name': resource_name,
'metadata': body}})
if error:
if error == 'stack':
return json_error(404,
'The stack "%s" does not exist.' % stack_name)
'The stack "%s" does not exist.' % stack_id)
else:
return json_error(404,
'The resource "%s" does not exist.' % resource_id)
'The resource "%s" does not exist.' % resource_name)
return json_response(201, {
'resource': resource_id,
'resource': resource_name,
'metadata': body,
})

Loading…
Cancel
Save