Add public property from storage to flowdetail.meta

Sometimes you need to access the metadata from listeners
and currently that requires a private property access.

Change-Id: Ib4f15650b15dfe8a04dbb690607d515663371d90
Fixes: #1511086
This commit is contained in:
Greg Hill 2015-11-17 08:32:32 -06:00
parent 6ac4f122e5
commit 3e1dfae164
2 changed files with 8 additions and 1 deletions

View File

@ -301,6 +301,11 @@ class Storage(object):
# This never changes (so no read locking needed).
return self._flowdetail.uuid
@property
def flow_meta(self):
"""The flow detail metadata this storage unit is associated with."""
return self._flowdetail.meta
@property
def backend(self):
"""The backend this storage unit is associated with."""

View File

@ -60,11 +60,13 @@ class StorageTestMixin(object):
s.ensure_atom(test_utils.NoopTask('my_task'))
self.assertTrue(uuidutils.is_uuid_like(s.get_atom_uuid('my_task')))
def test_flow_name_and_uuid(self):
def test_flow_name_uuid_and_meta(self):
flow_detail = models.FlowDetail(name='test-fd', uuid='aaaa')
flow_detail.meta = {'a': 1}
s = self._get_storage(flow_detail)
self.assertEqual('test-fd', s.flow_name)
self.assertEqual('aaaa', s.flow_uuid)
self.assertEqual({'a': 1}, s.flow_meta)
def test_ensure_task(self):
s = self._get_storage()