Merge "Replace dict(obj.iteritems()) with dict(obj)"
This commit is contained in:
@@ -82,7 +82,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
|||||||
except exception.InstanceNotFound:
|
except exception.InstanceNotFound:
|
||||||
LOG.debug('Dropping event %(name)s:%(tag)s for unknown '
|
LOG.debug('Dropping event %(name)s:%(tag)s for unknown '
|
||||||
'instance %(instance_uuid)s',
|
'instance %(instance_uuid)s',
|
||||||
dict(event.iteritems()))
|
dict(event))
|
||||||
_event['status'] = 'failed'
|
_event['status'] = 'failed'
|
||||||
_event['code'] = 404
|
_event['code'] = 404
|
||||||
result = 207
|
result = 207
|
||||||
@@ -96,7 +96,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
|||||||
accepted_instances.add(instance)
|
accepted_instances.add(instance)
|
||||||
LOG.info(_LI('Creating event %(name)s:%(tag)s for '
|
LOG.info(_LI('Creating event %(name)s:%(tag)s for '
|
||||||
'instance %(instance_uuid)s'),
|
'instance %(instance_uuid)s'),
|
||||||
dict(event.iteritems()))
|
dict(event))
|
||||||
# NOTE: as the event is processed asynchronously verify
|
# NOTE: as the event is processed asynchronously verify
|
||||||
# whether 202 is a more suitable response code than 200
|
# whether 202 is a more suitable response code than 200
|
||||||
_event['status'] = 'completed'
|
_event['status'] = 'completed'
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
|||||||
except exception.InstanceNotFound:
|
except exception.InstanceNotFound:
|
||||||
LOG.debug('Dropping event %(name)s:%(tag)s for unknown '
|
LOG.debug('Dropping event %(name)s:%(tag)s for unknown '
|
||||||
'instance %(instance_uuid)s',
|
'instance %(instance_uuid)s',
|
||||||
dict(event.iteritems()))
|
dict(event))
|
||||||
_event['status'] = 'failed'
|
_event['status'] = 'failed'
|
||||||
_event['code'] = 404
|
_event['code'] = 404
|
||||||
result = 207
|
result = 207
|
||||||
@@ -85,7 +85,7 @@ class ServerExternalEventsController(wsgi.Controller):
|
|||||||
accepted_instances.add(instance)
|
accepted_instances.add(instance)
|
||||||
LOG.info(_LI('Creating event %(name)s:%(tag)s for '
|
LOG.info(_LI('Creating event %(name)s:%(tag)s for '
|
||||||
'instance %(instance_uuid)s'),
|
'instance %(instance_uuid)s'),
|
||||||
dict(event.iteritems()))
|
dict(event))
|
||||||
# NOTE: as the event is processed asynchronously verify
|
# NOTE: as the event is processed asynchronously verify
|
||||||
# whether 202 is a more suitable response code than 200
|
# whether 202 is a more suitable response code than 200
|
||||||
_event['status'] = 'completed'
|
_event['status'] = 'completed'
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ def _build_metadata_by_host(aggregates, hosts=None):
|
|||||||
|
|
||||||
def set_availability_zones(context, services):
|
def set_availability_zones(context, services):
|
||||||
# Makes sure services isn't a sqlalchemy object
|
# Makes sure services isn't a sqlalchemy object
|
||||||
services = [dict(service.iteritems()) for service in services]
|
services = [dict(service) for service in services]
|
||||||
hosts = set([service['host'] for service in services])
|
hosts = set([service['host'] for service in services])
|
||||||
aggregates = objects.AggregateList.get_by_metadata_key(context,
|
aggregates = objects.AggregateList.get_by_metadata_key(context,
|
||||||
'availability_zone', hosts=hosts)
|
'availability_zone', hosts=hosts)
|
||||||
|
|||||||
@@ -5629,7 +5629,7 @@ def instance_fault_get_by_instance_uuids(context, instance_uuids):
|
|||||||
output[instance_uuid] = []
|
output[instance_uuid] = []
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
data = dict(row.iteritems())
|
data = dict(row)
|
||||||
output[row['instance_uuid']].append(data)
|
output[row['instance_uuid']].append(data)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ class FloatingIP(object):
|
|||||||
"""Returns a floating IP as a dict."""
|
"""Returns a floating IP as a dict."""
|
||||||
# NOTE(vish): This is no longer used but can't be removed until
|
# NOTE(vish): This is no longer used but can't be removed until
|
||||||
# we major version the network_rpcapi.
|
# we major version the network_rpcapi.
|
||||||
return dict(objects.FloatingIP.get_by_id(context, id).iteritems())
|
return dict(objects.FloatingIP.get_by_id(context, id))
|
||||||
|
|
||||||
def get_floating_pools(self, context):
|
def get_floating_pools(self, context):
|
||||||
"""Returns list of floating pools."""
|
"""Returns list of floating pools."""
|
||||||
|
|||||||
@@ -1570,7 +1570,7 @@ class NetworkManager(manager.Manager):
|
|||||||
if vif.network_id is not None:
|
if vif.network_id is not None:
|
||||||
network = self._get_network_by_id(context, vif.network_id)
|
network = self._get_network_by_id(context, vif.network_id)
|
||||||
vif.net_uuid = network.uuid
|
vif.net_uuid = network.uuid
|
||||||
return [dict(vif.iteritems()) for vif in vifs]
|
return [dict(vif) for vif in vifs]
|
||||||
|
|
||||||
def get_instance_id_by_floating_address(self, context, address):
|
def get_instance_id_by_floating_address(self, context, address):
|
||||||
"""Returns the instance id a floating ip's fixed ip is allocated to."""
|
"""Returns the instance id a floating ip's fixed ip is allocated to."""
|
||||||
|
|||||||
@@ -647,7 +647,14 @@ class NovaObject(object):
|
|||||||
|
|
||||||
|
|
||||||
class NovaObjectDictCompat(ovoo_base.VersionedObjectDictCompat):
|
class NovaObjectDictCompat(ovoo_base.VersionedObjectDictCompat):
|
||||||
pass
|
def __iter__(self):
|
||||||
|
for name in self.obj_fields:
|
||||||
|
if (self.obj_attr_is_set(name) or
|
||||||
|
name in self.obj_extra_fields):
|
||||||
|
yield name
|
||||||
|
|
||||||
|
def keys(self):
|
||||||
|
return list(self)
|
||||||
|
|
||||||
|
|
||||||
class NovaTimestampObject(object):
|
class NovaTimestampObject(object):
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ class HostManager(object):
|
|||||||
host_state.aggregates = [self.aggs_by_id[agg_id] for agg_id in
|
host_state.aggregates = [self.aggs_by_id[agg_id] for agg_id in
|
||||||
self.host_aggregates_map[
|
self.host_aggregates_map[
|
||||||
host_state.host]]
|
host_state.host]]
|
||||||
host_state.update_service(dict(service.iteritems()))
|
host_state.update_service(dict(service))
|
||||||
self._add_instance_info(context, compute, host_state)
|
self._add_instance_info(context, compute, host_state)
|
||||||
seen_nodes.add(state_key)
|
seen_nodes.add(state_key)
|
||||||
|
|
||||||
|
|||||||
@@ -1581,7 +1581,7 @@ class _TestInstanceListObject(object):
|
|||||||
use_slave=False)
|
use_slave=False)
|
||||||
self.assertEqual(2, len(instances))
|
self.assertEqual(2, len(instances))
|
||||||
self.assertEqual(fake_faults['fake-uuid'][0],
|
self.assertEqual(fake_faults['fake-uuid'][0],
|
||||||
dict(instances[0].fault.iteritems()))
|
dict(instances[0].fault))
|
||||||
self.assertIsNone(instances[1].fault)
|
self.assertIsNone(instances[1].fault)
|
||||||
|
|
||||||
def test_fill_faults(self):
|
def test_fill_faults(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user