Fix renaming of instance fields using update_instance api method.
This commit is contained in:
commit
9610c61055
@ -52,7 +52,23 @@ def _database_to_isoformat(datetimeobj):
|
|||||||
|
|
||||||
|
|
||||||
def _try_convert(value):
|
def _try_convert(value):
|
||||||
"""Return a non-string if possible"""
|
"""Return a non-string from a string or unicode, if possible.
|
||||||
|
|
||||||
|
============= =====================================================
|
||||||
|
When value is returns
|
||||||
|
============= =====================================================
|
||||||
|
zero-length ''
|
||||||
|
'None' None
|
||||||
|
'True' True
|
||||||
|
'False' False
|
||||||
|
'0', '-0' 0
|
||||||
|
0xN, -0xN int from hex (postitive) (N is any number)
|
||||||
|
0bN, -0bN int from binary (positive) (N is any number)
|
||||||
|
* try conversion to int, float, complex, fallback value
|
||||||
|
|
||||||
|
"""
|
||||||
|
if len(value) == 0:
|
||||||
|
return ''
|
||||||
if value == 'None':
|
if value == 'None':
|
||||||
return None
|
return None
|
||||||
if value == 'True':
|
if value == 'True':
|
||||||
|
@ -838,14 +838,14 @@ class CloudController(object):
|
|||||||
self.compute_api.unrescue(context, instance_id=instance_id)
|
self.compute_api.unrescue(context, instance_id=instance_id)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def update_instance(self, context, ec2_id, **kwargs):
|
def update_instance(self, context, instance_id, **kwargs):
|
||||||
updatable_fields = ['display_name', 'display_description']
|
updatable_fields = ['display_name', 'display_description']
|
||||||
changes = {}
|
changes = {}
|
||||||
for field in updatable_fields:
|
for field in updatable_fields:
|
||||||
if field in kwargs:
|
if field in kwargs:
|
||||||
changes[field] = kwargs[field]
|
changes[field] = kwargs[field]
|
||||||
if changes:
|
if changes:
|
||||||
instance_id = ec2_id_to_id(ec2_id)
|
instance_id = ec2_id_to_id(instance_id)
|
||||||
self.compute_api.update(context, instance_id=instance_id, **kwargs)
|
self.compute_api.update(context, instance_id=instance_id, **kwargs)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user