Swap and ephemeral fields should be optional
Such as in Nova CLI, during flavor create/update the swap and ephemeral fields should be optional. If Nova receive an empty value in swap or ephemeral field sets it to "0" Change-Id: I896e4fa842a1cf6213f564d8890931a0818b657a Closes-Bug: #1480343
This commit is contained in:
parent
eedcdb4d50
commit
3f3da92350
@ -257,6 +257,32 @@ class CreateFlavorWorkflowTests(BaseFlavorWorkflowTests):
|
|||||||
self.assertFormErrors(res)
|
self.assertFormErrors(res)
|
||||||
self.assertContains(res, "field is required")
|
self.assertContains(res, "field is required")
|
||||||
|
|
||||||
|
@test.create_stubs({api.keystone: ('tenant_list',),
|
||||||
|
api.nova: ('flavor_list',)})
|
||||||
|
def test_create_flavor_missing_swap_and_ephemeral_fields(self):
|
||||||
|
flavor = self.flavors.first()
|
||||||
|
projects = self.tenants.list()
|
||||||
|
|
||||||
|
# init
|
||||||
|
api.keystone.tenant_list(IsA(http.HttpRequest)).AndReturn([projects,
|
||||||
|
False])
|
||||||
|
|
||||||
|
# handle
|
||||||
|
api.nova.flavor_list(IsA(http.HttpRequest), None) \
|
||||||
|
.AndReturn(self.flavors.list())
|
||||||
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
|
workflow_data = self._get_workflow_data(flavor)
|
||||||
|
# Swap field empty
|
||||||
|
workflow_data['swap'] = None
|
||||||
|
# Ephemeral field empty
|
||||||
|
workflow_data['eph'] = None
|
||||||
|
|
||||||
|
url = reverse(constants.FLAVORS_CREATE_URL)
|
||||||
|
res = self.client.post(url, workflow_data)
|
||||||
|
|
||||||
|
self.assertFormErrors(res)
|
||||||
|
|
||||||
|
|
||||||
class UpdateFlavorWorkflowTests(BaseFlavorWorkflowTests):
|
class UpdateFlavorWorkflowTests(BaseFlavorWorkflowTests):
|
||||||
@test.create_stubs({api.nova: ('flavor_get',
|
@test.create_stubs({api.nova: ('flavor_get',
|
||||||
|
@ -50,8 +50,12 @@ class CreateFlavorInfoAction(workflows.Action):
|
|||||||
disk_gb = forms.IntegerField(label=_("Root Disk (GB)"),
|
disk_gb = forms.IntegerField(label=_("Root Disk (GB)"),
|
||||||
min_value=0)
|
min_value=0)
|
||||||
eph_gb = forms.IntegerField(label=_("Ephemeral Disk (GB)"),
|
eph_gb = forms.IntegerField(label=_("Ephemeral Disk (GB)"),
|
||||||
|
required=False,
|
||||||
|
initial=0,
|
||||||
min_value=0)
|
min_value=0)
|
||||||
swap_mb = forms.IntegerField(label=_("Swap Disk (MB)"),
|
swap_mb = forms.IntegerField(label=_("Swap Disk (MB)"),
|
||||||
|
required=False,
|
||||||
|
initial=0,
|
||||||
min_value=0)
|
min_value=0)
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
@ -188,6 +192,8 @@ class CreateFlavor(workflows.Workflow):
|
|||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
flavor_id = data.get('flavor_id') or 'auto'
|
flavor_id = data.get('flavor_id') or 'auto'
|
||||||
|
swap = data.get('swap_mb') or 0
|
||||||
|
ephemeral = data.get('eph_gb') or 0
|
||||||
flavor_access = data['flavor_access']
|
flavor_access = data['flavor_access']
|
||||||
is_public = not flavor_access
|
is_public = not flavor_access
|
||||||
|
|
||||||
@ -198,8 +204,8 @@ class CreateFlavor(workflows.Workflow):
|
|||||||
memory=data['memory_mb'],
|
memory=data['memory_mb'],
|
||||||
vcpu=data['vcpus'],
|
vcpu=data['vcpus'],
|
||||||
disk=data['disk_gb'],
|
disk=data['disk_gb'],
|
||||||
ephemeral=data['eph_gb'],
|
ephemeral=ephemeral,
|
||||||
swap=data['swap_mb'],
|
swap=swap,
|
||||||
flavorid=flavor_id,
|
flavorid=flavor_id,
|
||||||
is_public=is_public)
|
is_public=is_public)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user