Add delete() operation to InstanceInfoCache
This adds the trivial delete() operation to InstanceInfoCache and makes the _local_delete() path in compute_api use it. Related to blueprint compute-api-objects Change-Id: Iac4c36c1158ca98f3a2ab011f151ccd2a9ebeac0
This commit is contained in:
parent
6da474eda2
commit
8fcf6a7d41
@ -1335,7 +1335,7 @@ class API(base.Base):
|
||||
LOG.warning(_("instance's host %s is down, deleting from "
|
||||
"database") % instance['host'], instance=instance)
|
||||
instance_uuid = instance['uuid']
|
||||
self.db.instance_info_cache_delete(context, instance_uuid)
|
||||
instance.info_cache.delete()
|
||||
compute_utils.notify_about_instance_usage(
|
||||
context, instance, "%s.start" % delete_type)
|
||||
|
||||
|
@ -25,10 +25,11 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InstanceInfoCache(base.NovaObject):
|
||||
VERSION = '1.2'
|
||||
VERSION = '1.3'
|
||||
# Version 1.0: Initial version
|
||||
# Version 1.1: Converted network_info to store the model.
|
||||
# Version 1.2: Added new() and update_cells kwarg to save().
|
||||
# Version 1.3: Added delete()
|
||||
|
||||
fields = {
|
||||
'instance_uuid': str,
|
||||
@ -92,3 +93,7 @@ class InstanceInfoCache(base.NovaObject):
|
||||
if update_cells and rv:
|
||||
self._info_cache_cells_update(context, rv)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
def delete(self, context):
|
||||
db.instance_info_cache_delete(context, self.instance_uuid)
|
||||
|
@ -29,6 +29,7 @@ from nova import db
|
||||
from nova import exception
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_info_cache
|
||||
from nova.openstack.common import timeutils
|
||||
from nova.openstack.common import uuidutils
|
||||
from nova import quota
|
||||
@ -109,6 +110,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
instance.updated_at = now
|
||||
instance.launched_at = now
|
||||
instance.disable_terminate = False
|
||||
instance.info_cache = instance_info_cache.InstanceInfoCache()
|
||||
|
||||
if params:
|
||||
instance.update(params)
|
||||
@ -374,7 +376,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
self.mox.StubOutWithMock(self.compute_api, '_reserve_quota_delta')
|
||||
self.mox.StubOutWithMock(self.compute_api, '_record_action_start')
|
||||
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
|
||||
self.mox.StubOutWithMock(db, 'instance_info_cache_delete')
|
||||
self.mox.StubOutWithMock(inst.info_cache, 'delete')
|
||||
self.mox.StubOutWithMock(self.compute_api.network_api,
|
||||
'deallocate_for_instance')
|
||||
self.mox.StubOutWithMock(db, 'instance_system_metadata_get')
|
||||
@ -408,7 +410,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
self.mox.StubOutWithMock(rpcapi, 'soft_delete_instance')
|
||||
|
||||
if inst.host == 'down-host':
|
||||
db.instance_info_cache_delete(self.context, inst.uuid)
|
||||
inst.info_cache.delete()
|
||||
compute_utils.notify_about_instance_usage(self.context,
|
||||
inst,
|
||||
'%s.start' % delete_type)
|
||||
|
Loading…
x
Reference in New Issue
Block a user