Merge "Add image_id and node_count to bay"

This commit is contained in:
Jenkins 2014-12-07 02:05:37 +00:00 committed by Gerrit Code Review
commit 79d61e5244
5 changed files with 21 additions and 3 deletions

View File

@ -78,6 +78,12 @@ class Bay(base.APIBase):
type = wtypes.text
"""Type of this bay"""
image_id = wtypes.text
"""The image name or UUID to use as a base image for this bay"""
node_count = wtypes.IntegerType()
"""The image name or UUID to use as a base image for this bay"""
links = wsme.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated bay links"""
@ -104,7 +110,8 @@ class Bay(base.APIBase):
@staticmethod
def _convert_with_links(bay, url, expand=True):
if not expand:
bay.unset_fields_except(['uuid', 'name', 'type'])
bay.unset_fields_except(['uuid', 'name', 'type', 'image_id',
'node_count'])
# never expose the bay_id attribute
bay.bay_id = wtypes.Unset
@ -127,6 +134,8 @@ class Bay(base.APIBase):
sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
name='example',
type='virt',
image_id='Fedora-k8s',
node_count=1,
created_at=datetime.datetime.utcnow(),
updated_at=datetime.datetime.utcnow())
# NOTE(lucasagomes): bay_uuid getter() method look at the

View File

@ -37,6 +37,8 @@ def upgrade():
sa.Column('uuid', sa.String(length=36), nullable=True),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('type', sa.String(length=20), nullable=True),
sa.Column('image_id', sa.String(length=255), nullable=True),
sa.Column('node_count', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_ENGINE='InnoDB',
mysql_DEFAULT_CHARSET='UTF8'

View File

@ -123,6 +123,8 @@ class Bay(Base):
uuid = Column(String(36))
name = Column(String(255))
type = Column(String(20))
image_id = Column(String(255))
node_count = Column(Integer())
class Container(Base):

View File

@ -35,7 +35,9 @@ class Bay(base.MagnumObject):
'id': int,
'uuid': obj_utils.str_or_none,
'name': obj_utils.str_or_none,
'type': obj_utils.str_or_none
'type': obj_utils.str_or_none,
'image_id': obj_utils.str_or_none,
'node_count': obj_utils.int_or_none
}
@staticmethod

View File

@ -71,7 +71,8 @@ class TestRootController(tests.FunctionalTest):
class TestBayController(db_base.DbTestCase):
def test_bay_api(self):
# Create a bay
params = '{"name": "bay_example_A", "type": "virt"}'
params = '{"name": "bay_example_A", "type": "virt", \
"image_id": "Fedora", "node_count": "3"}'
response = self.app.post('/v1/bays',
params=params,
content_type='application/json')
@ -85,6 +86,8 @@ class TestBayController(db_base.DbTestCase):
self.assertIsNotNone(c.get('uuid'))
self.assertEqual('bay_example_A', c.get('name'))
self.assertEqual('virt', c.get('type'))
self.assertEqual('Fedora', c.get('image_id'))
self.assertEqual(3, c.get('node_count'))
# Get just the one we created
response = self.app.get('/v1/bays/%s' % c.get('uuid'))