Add bay_uuid for replication controller

bay_uuid is needed when creating replication controller

Change-Id: If88235bda4b2f9833058533d1308fd89e6b6da4d
This commit is contained in:
Jay Lau (Guangya Liu) 2015-01-05 07:58:43 -05:00
parent fffbfd8a4e
commit 01ce1daac8
3 changed files with 10 additions and 2 deletions

View File

@ -76,6 +76,9 @@ class ReplicationController(base.APIBase):
images = [wtypes.text]
"""A list of images used by containers in this ReplicationController."""
bay_uuid = types.uuid
"""Unique UUID of the bay the ReplicationController runs on"""
selector = {wtypes.text: wtypes.text}
"""Selector of this ReplicationController"""
@ -114,8 +117,8 @@ class ReplicationController(base.APIBase):
@staticmethod
def _convert_with_links(rc, url, expand=True):
if not expand:
rc.unset_fields_except(['uuid', 'name', 'images', 'selector',
'replicas'])
rc.unset_fields_except(['uuid', 'name', 'images', 'bay_uuid',
'selector', 'replicas'])
# never expose the rc_id attribute
rc.rc_id = wtypes.Unset
@ -138,6 +141,7 @@ class ReplicationController(base.APIBase):
sample = cls(uuid='f978db47-9a37-4e9f-8572-804a10abc0aa',
name='MyReplicationController',
images=['MyImage'],
bay_uuid='f978db47-9a37-4e9f-8572-804a10abc0ab',
selector={'name': 'foo'},
replicas=2,
created_at=datetime.datetime.utcnow(),

View File

@ -30,6 +30,7 @@ class ReplicationController(base.MagnumObject):
'uuid': obj_utils.str_or_none,
'name': obj_utils.str_or_none,
'images': obj_utils.list_or_none,
'bay_uuid': obj_utils.str_or_none,
'selector': obj_utils.dict_or_none,
'replicas': int,
'rc_definition_url': obj_utils.str_or_none,

View File

@ -29,6 +29,7 @@ class TestRCController(db_base.DbTestCase):
# Create a replication controller
params = '{"name": "rc_example_A", "images": ["ubuntu"],' \
'"selector": {"foo": "foo1"}, "replicas": 2,' \
'"bay_uuid": "7ae81bb3-dec3-4289-8d6c-da80bd8001ae",' \
'"rc_definition_url": "http://172.17.1.2/rc.json"}'
response = self.app.post('/v1/rcs',
params=params,
@ -43,6 +44,8 @@ class TestRCController(db_base.DbTestCase):
self.assertIsNotNone(c.get('uuid'))
self.assertEqual('rc_example_A', c.get('name'))
self.assertEqual(['ubuntu'], c.get('images'))
self.assertEqual('7ae81bb3-dec3-4289-8d6c-da80bd8001ae',
c.get('bay_uuid'))
self.assertEqual('foo1', c.get('selector')['foo'])
# Get just the one we created