Remove duplicate code in Objects create() function
Remove duplicate code updates.pop('id', None) in create() function.
Because if self.obj_attr_is_set('id'):
raise exception.ObjectActionError(action='create',
reason='already created')
already make sure object doesn't have 'id' values, which means that
'id' won't appear in updates.
Change-Id: I582ef8857b32c07ea8ba1eb5fc1e64516110f3ce
This commit is contained in:
@@ -71,7 +71,6 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject):
|
||||
"create.start",
|
||||
payload)
|
||||
metadata = updates.pop('metadata', None)
|
||||
updates.pop('id', None)
|
||||
db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
|
||||
self._from_db_object(context, self, db_aggregate)
|
||||
payload['aggregate_id'] = self.id
|
||||
|
||||
@@ -88,7 +88,6 @@ class BlockDeviceMapping(base.NovaPersistentObject, base.NovaObject):
|
||||
if 'instance' in updates:
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='instance assigned')
|
||||
updates.pop('id', None)
|
||||
|
||||
db_bdm = db.block_device_mapping_create(context, updates, legacy=False)
|
||||
cells_api = cells_rpcapi.CellsAPI()
|
||||
|
||||
@@ -91,7 +91,6 @@ class ComputeNode(base.NovaPersistentObject, base.NovaObject):
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='already created')
|
||||
updates = self.obj_get_changes()
|
||||
updates.pop('id', None)
|
||||
self._convert_stats_to_db_format(updates)
|
||||
|
||||
db_compute = db.compute_node_create(context, updates)
|
||||
|
||||
@@ -330,7 +330,6 @@ class Instance(base.NovaPersistentObject, base.NovaObject):
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='already created')
|
||||
updates = self.obj_get_changes()
|
||||
updates.pop('id', None)
|
||||
expected_attrs = [attr for attr in INSTANCE_DEFAULT_FIELDS
|
||||
if attr in updates]
|
||||
if 'security_groups' in updates:
|
||||
|
||||
@@ -54,7 +54,6 @@ class KeyPair(base.NovaPersistentObject, base.NovaObject):
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='already created')
|
||||
updates = self.obj_get_changes()
|
||||
updates.pop('id', None)
|
||||
db_keypair = db.key_pair_create(context, updates)
|
||||
self._from_db_object(context, self, db_keypair)
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ class Migration(base.NovaPersistentObject, base.NovaObject):
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='already created')
|
||||
updates = self.obj_get_changes()
|
||||
updates.pop('id', None)
|
||||
db_migration = db.migration_create(context, updates)
|
||||
self._from_db_object(context, self, db_migration)
|
||||
|
||||
|
||||
@@ -110,7 +110,6 @@ class Service(base.NovaPersistentObject, base.NovaObject):
|
||||
raise exception.ObjectActionError(action='create',
|
||||
reason='already created')
|
||||
updates = self.obj_get_changes()
|
||||
updates.pop('id', None)
|
||||
db_service = db.service_create(context, updates)
|
||||
self._from_db_object(context, self, db_service)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user