Remove usage of remotable context parameter in instance* objects
This removes the use of the context parameter in remotable methods in these objects. This is a precursor to actually removing the context from the call, but we need to remove dependence on the argument first. Remotable methods should be using the bundled object context. Related to blueprint kilo-objects Change-Id: If89e6e03d1e15f8ce688166ff2faa4794280c112
This commit is contained in:
@@ -75,8 +75,8 @@ class InstanceFault(base.NovaPersistentObject, base.NovaObject,
|
|||||||
'details': self.details,
|
'details': self.details,
|
||||||
'host': self.host,
|
'host': self.host,
|
||||||
}
|
}
|
||||||
db_fault = db.instance_fault_create(context, values)
|
db_fault = db.instance_fault_create(self._context, values)
|
||||||
self._from_db_object(context, self, db_fault)
|
self._from_db_object(self._context, self, db_fault)
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
# Cells should only try sending a message over to nova-cells
|
# Cells should only try sending a message over to nova-cells
|
||||||
# if cells is enabled and we're not the API cell. Otherwise,
|
# if cells is enabled and we're not the API cell. Otherwise,
|
||||||
@@ -85,7 +85,7 @@ class InstanceFault(base.NovaPersistentObject, base.NovaObject,
|
|||||||
if cells_opts.get_cell_type() == 'compute':
|
if cells_opts.get_cell_type() == 'compute':
|
||||||
try:
|
try:
|
||||||
cells_rpcapi.CellsAPI().instance_fault_create_at_top(
|
cells_rpcapi.CellsAPI().instance_fault_create_at_top(
|
||||||
context, db_fault)
|
self._context, db_fault)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception(_LE("Failed to notify cells of instance fault"))
|
LOG.exception(_LE("Failed to notify cells of instance fault"))
|
||||||
|
|
||||||
|
|||||||
@@ -117,16 +117,16 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject,
|
|||||||
payload = dict(updates)
|
payload = dict(updates)
|
||||||
payload['server_group_id'] = self.uuid
|
payload['server_group_id'] = self.uuid
|
||||||
|
|
||||||
db.instance_group_update(context, self.uuid, updates)
|
db.instance_group_update(self._context, self.uuid, updates)
|
||||||
db_inst = db.instance_group_get(context, self.uuid)
|
db_inst = db.instance_group_get(self._context, self.uuid)
|
||||||
self._from_db_object(context, self, db_inst)
|
self._from_db_object(self._context, self, db_inst)
|
||||||
compute_utils.notify_about_server_group_update(context,
|
compute_utils.notify_about_server_group_update(self._context,
|
||||||
"update", payload)
|
"update", payload)
|
||||||
|
|
||||||
@base.remotable
|
@base.remotable
|
||||||
def refresh(self, context):
|
def refresh(self, context):
|
||||||
"""Refreshes the instance group."""
|
"""Refreshes the instance group."""
|
||||||
current = self.__class__.get_by_uuid(context, self.uuid)
|
current = self.__class__.get_by_uuid(self._context, self.uuid)
|
||||||
for field in self.fields:
|
for field in self.fields:
|
||||||
if self.obj_attr_is_set(field) and self[field] != current[field]:
|
if self.obj_attr_is_set(field) and self[field] != current[field]:
|
||||||
self[field] = current[field]
|
self[field] = current[field]
|
||||||
@@ -143,20 +143,20 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject,
|
|||||||
policies = updates.pop('policies', None)
|
policies = updates.pop('policies', None)
|
||||||
members = updates.pop('members', None)
|
members = updates.pop('members', None)
|
||||||
|
|
||||||
db_inst = db.instance_group_create(context, updates,
|
db_inst = db.instance_group_create(self._context, updates,
|
||||||
policies=policies,
|
policies=policies,
|
||||||
members=members)
|
members=members)
|
||||||
self._from_db_object(context, self, db_inst)
|
self._from_db_object(self._context, self, db_inst)
|
||||||
payload['server_group_id'] = self.uuid
|
payload['server_group_id'] = self.uuid
|
||||||
compute_utils.notify_about_server_group_update(context,
|
compute_utils.notify_about_server_group_update(self._context,
|
||||||
"create", payload)
|
"create", payload)
|
||||||
|
|
||||||
@base.remotable
|
@base.remotable
|
||||||
def destroy(self, context):
|
def destroy(self, context):
|
||||||
payload = {'server_group_id': self.uuid}
|
payload = {'server_group_id': self.uuid}
|
||||||
db.instance_group_delete(context, self.uuid)
|
db.instance_group_delete(self._context, self.uuid)
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
compute_utils.notify_about_server_group_update(context,
|
compute_utils.notify_about_server_group_update(self._context,
|
||||||
"delete", payload)
|
"delete", payload)
|
||||||
|
|
||||||
@base.remotable_classmethod
|
@base.remotable_classmethod
|
||||||
@@ -182,7 +182,7 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject,
|
|||||||
if exclude:
|
if exclude:
|
||||||
filter_uuids = set(filter_uuids) - set(exclude)
|
filter_uuids = set(filter_uuids) - set(exclude)
|
||||||
filters = {'uuid': filter_uuids, 'deleted': False}
|
filters = {'uuid': filter_uuids, 'deleted': False}
|
||||||
instances = objects.InstanceList.get_by_filters(context,
|
instances = objects.InstanceList.get_by_filters(self._context,
|
||||||
filters=filters)
|
filters=filters)
|
||||||
return list(set([instance.host for instance in instances
|
return list(set([instance.host for instance in instances
|
||||||
if instance.host]))
|
if instance.host]))
|
||||||
@@ -192,7 +192,7 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject,
|
|||||||
"""Count the number of instances in a group belonging to a user."""
|
"""Count the number of instances in a group belonging to a user."""
|
||||||
filter_uuids = self.members
|
filter_uuids = self.members
|
||||||
filters = {'uuid': filter_uuids, 'user_id': user_id, 'deleted': False}
|
filters = {'uuid': filter_uuids, 'user_id': user_id, 'deleted': False}
|
||||||
instances = objects.InstanceList.get_by_filters(context,
|
instances = objects.InstanceList.get_by_filters(self._context,
|
||||||
filters=filters)
|
filters=filters)
|
||||||
return len(instances)
|
return len(instances)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user