Merge "Add source to Resource API object"

This commit is contained in:
Jenkins 2013-10-25 13:32:15 +00:00 committed by Gerrit Code Review
commit 4b2275db19
2 changed files with 6 additions and 0 deletions

View File

@ -897,6 +897,9 @@ class Resource(_Base):
links = [Link] links = [Link]
"A list containing a self link and associated meter links" "A list containing a self link and associated meter links"
source = wtypes.text
"The source where the resource come from"
def __init__(self, metadata={}, **kwds): def __init__(self, metadata={}, **kwds):
metadata = _flatten_metadata(metadata) metadata = _flatten_metadata(metadata)
super(Resource, self).__init__(metadata=metadata, **kwds) super(Resource, self).__init__(metadata=metadata, **kwds)
@ -907,6 +910,7 @@ class Resource(_Base):
project_id='35b17138-b364-4e6a-a131-8f3099c5be68', project_id='35b17138-b364-4e6a-a131-8f3099c5be68',
user_id='efd87807-12d2-4b38-9c70-5f5c2ac427ff', user_id='efd87807-12d2-4b38-9c70-5f5c2ac427ff',
timestamp=datetime.datetime.utcnow(), timestamp=datetime.datetime.utcnow(),
source="openstack",
metadata={'name1': 'value1', metadata={'name1': 'value1',
'name2': 'value2'}, 'name2': 'value2'},
links=[Link(href=('http://localhost:8777/v2/resources/' links=[Link(href=('http://localhost:8777/v2/resources/'

View File

@ -201,6 +201,8 @@ class TestListResources(FunctionalTest,
}]) }])
ids = [r['resource_id'] for r in data] ids = [r['resource_id'] for r in data]
self.assertEqual(['resource-id'], ids) self.assertEqual(['resource-id'], ids)
sources = [r['source'] for r in data]
self.assertEqual(['test_list_resources'], sources)
def test_with_invalid_resource_id(self): def test_with_invalid_resource_id(self):
sample1 = sample.Sample( sample1 = sample.Sample(