Merge "[flavor update] Fixing a flavor comparation issue"
This commit is contained in:
commit
f05fd1e4f7
@ -298,11 +298,14 @@ class UpdateFlavor(workflows.Workflow):
|
|||||||
flavor_projects = data["flavor_access"]
|
flavor_projects = data["flavor_access"]
|
||||||
is_public = not flavor_projects
|
is_public = not flavor_projects
|
||||||
|
|
||||||
def is_equals(a, b, keys):
|
def is_changed(flavor):
|
||||||
for k in keys:
|
return not (data['name'] == flavor.name and
|
||||||
if getattr(a, k, None) != getattr(b, k, None):
|
data['memory_mb'] == flavor.ram and
|
||||||
return False
|
data['vcpus'] == flavor.vcpus and
|
||||||
return True
|
data['disk_gb'] == flavor.disk and
|
||||||
|
data['swap_mb'] == (flavor.swap or 0) and
|
||||||
|
data['rxtx_factor'] == flavor.rxtx_factor and
|
||||||
|
data['eph_gb'] == flavor.ephemeral)
|
||||||
|
|
||||||
def setup_access():
|
def setup_access():
|
||||||
for project in flavor_projects:
|
for project in flavor_projects:
|
||||||
@ -312,20 +315,17 @@ class UpdateFlavor(workflows.Workflow):
|
|||||||
|
|
||||||
# Update flavor information
|
# Update flavor information
|
||||||
try:
|
try:
|
||||||
|
|
||||||
flavor_id = data['flavor_id']
|
flavor_id = data['flavor_id']
|
||||||
flavor = api.nova.flavor_get(self.request, flavor_id)
|
flavor = api.nova.flavor_get(self.request, flavor_id)
|
||||||
|
|
||||||
# Check if the flavor info is not actually changed
|
# Check if the flavor info is not actually changed
|
||||||
if is_equals(flavor, data, UpdateFlavorInfo.contributes):
|
if not is_changed(flavor):
|
||||||
if is_public:
|
try:
|
||||||
return True
|
|
||||||
else:
|
|
||||||
# In this case info like cpu, ram, etc not changed
|
|
||||||
# so, just set the access without any flavor changing
|
|
||||||
# this behavior coincides with nova cli
|
|
||||||
setup_access()
|
setup_access()
|
||||||
return True
|
except Exception:
|
||||||
|
exceptions.handle(request,
|
||||||
|
_('Unable to modify flavor access.'))
|
||||||
|
return True
|
||||||
|
|
||||||
# Grab any existing extra specs, because flavor edit is currently
|
# Grab any existing extra specs, because flavor edit is currently
|
||||||
# implemented as a delete followed by a create.
|
# implemented as a delete followed by a create.
|
||||||
|
Loading…
Reference in New Issue
Block a user