Change BayModel#coe type to wtypes.Enum
BayModel coe should be Enum value. This patch fixes this. Change-Id: I2fbd0ae16af473e953bfccf7dd5fa34d615de9e5 Closes-Bug: #1542167
This commit is contained in:
parent
22d15557c8
commit
1772284b99
|
@ -30,6 +30,7 @@ from magnum.common import clients
|
|||
from magnum.common import exception
|
||||
from magnum.common import policy
|
||||
from magnum import objects
|
||||
from magnum.objects import fields
|
||||
|
||||
|
||||
class BayModelPatchType(types.JsonPatchType):
|
||||
|
@ -48,24 +49,13 @@ class BayModel(base.APIBase):
|
|||
between the internal object model and the API representation of a baymodel.
|
||||
"""
|
||||
|
||||
_coe = None
|
||||
|
||||
def _get_coe(self):
|
||||
return self._coe
|
||||
|
||||
def _set_coe(self, value):
|
||||
if value and self._coe != value:
|
||||
self._coe = value
|
||||
elif value == wtypes.Unset:
|
||||
self._coe = wtypes.Unset
|
||||
|
||||
uuid = types.uuid
|
||||
"""Unique UUID for this baymodel"""
|
||||
|
||||
name = wtypes.StringType(min_length=1, max_length=255)
|
||||
"""The name of the bay model"""
|
||||
|
||||
coe = wsme.wsproperty(wtypes.text, _get_coe, _set_coe, mandatory=True)
|
||||
coe = wtypes.Enum(str, *fields.BayType.ALL, mondatory=True)
|
||||
"""The Container Orchestration Engine for this bay model"""
|
||||
|
||||
image_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),
|
||||
|
@ -185,7 +175,7 @@ class BayModel(base.APIBase):
|
|||
docker_volume_size=25,
|
||||
cluster_distro='fedora-atomic',
|
||||
ssh_authorized_key='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB',
|
||||
coe='kubernetes',
|
||||
coe=fields.BayType.KUBERNETES,
|
||||
http_proxy='http://proxy.com:123',
|
||||
https_proxy='https://proxy.com:123',
|
||||
no_proxy='192.168.0.1,192.168.0.2,192.168.0.3',
|
||||
|
|
|
@ -471,6 +471,12 @@ class TestPost(api_base.FunctionalTest):
|
|||
for field in fields:
|
||||
self._create_baymodel_raises_app_error(**{field: ''})
|
||||
|
||||
def test_create_baymodel_with_invalid_coe(self):
|
||||
self._create_baymodel_raises_app_error(coe='k8s')
|
||||
self._create_baymodel_raises_app_error(coe='storm')
|
||||
self._create_baymodel_raises_app_error(coe='meson')
|
||||
self._create_baymodel_raises_app_error(coe='osomatsu')
|
||||
|
||||
def test_create_baymodel_with_invalid_docker_volume_size(self):
|
||||
self._create_baymodel_raises_app_error(docker_volume_size=0)
|
||||
self._create_baymodel_raises_app_error(docker_volume_size=-1)
|
||||
|
|
Loading…
Reference in New Issue