Do not pass rich objects in Zaqar Queue

Do not return queue object from handle_create.
An extra API call is introduced in check_create_complete.

Change-Id: Ic46f50b011fe9e5b397e5f822c9e9c86e8544c81
Partial-Bug: #1393268
This commit is contained in:
Pavlo Shchelokovskyy 2015-04-24 16:07:10 -07:00
parent 23e10121b0
commit 860c7f6338
2 changed files with 10 additions and 6 deletions

View File

@ -78,19 +78,19 @@ class ZaqarQueue(resource.Resource):
% queue_name)
queue.ensure_exists()
self.resource_id_set(queue_name)
return queue
return queue_name
def check_create_complete(self, queue):
def check_create_complete(self, queue_name):
"""Set metadata of the newly created queue."""
queue = self.client().queue(queue_name, auto_create=False)
if queue.exists():
metadata = self.properties.get('metadata')
if metadata:
queue.metadata(new_meta=metadata)
return True
queue_name = self.physical_resource_name()
raise exception.Error(_('Message queue %s creation failed.')
% queue_name)
else:
raise exception.Error(_('Message queue %s creation failed.')
% queue_name)
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
"""Update queue metadata."""

View File

@ -108,6 +108,8 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
fake_q.exists().AndReturn(False)
self.m.StubOutWithMock(fake_q, 'ensure_exists')
fake_q.ensure_exists()
self.fc.queue(queue.physical_resource_name(),
auto_create=False).AndReturn(fake_q)
fake_q.exists().AndReturn(True)
self.m.StubOutWithMock(fake_q, 'metadata')
fake_q.metadata(new_meta=queue.properties.get('metadata'))
@ -156,6 +158,8 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
self.m.StubOutWithMock(fake_q, 'exists')
fake_q.exists().AndReturn(False)
self.m.StubOutWithMock(fake_q, 'ensure_exists')
self.fc.queue(queue.physical_resource_name(),
auto_create=False).AndReturn(fake_q)
fake_q.ensure_exists()
fake_q.exists().AndReturn(False)