Merge "Fix the rest of direct uses of instance module objects"
This commit is contained in:
commit
524fc1791c
|
@ -28,7 +28,7 @@ from nova.cells import utils as cells_utils
|
|||
from nova import context
|
||||
from nova import exception
|
||||
from nova import manager
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -226,8 +226,8 @@ class CellsManager(manager.Manager):
|
|||
deleted or soft_deleted. So, we'll broadcast this everywhere.
|
||||
"""
|
||||
if isinstance(instance, dict):
|
||||
instance = instance_obj.Instance._from_db_object(ctxt,
|
||||
instance_obj.Instance(), instance)
|
||||
instance = objects.Instance._from_db_object(ctxt,
|
||||
objects.Instance(), instance)
|
||||
self.msg_runner.instance_delete_everywhere(ctxt, instance,
|
||||
delete_type)
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ from nova import context
|
|||
from nova.db import base
|
||||
from nova import exception
|
||||
from nova.network import model as network_model
|
||||
from nova import objects
|
||||
from nova.objects import base as objects_base
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_fault as instance_fault_obj
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -685,7 +685,7 @@ class _TargetedMessageMethods(_BaseMessageMethods):
|
|||
EXPECTS_OBJECTS = ['start', 'stop', 'delete_instance_metadata',
|
||||
'update_instance_metadata']
|
||||
if method in EXPECTS_OBJECTS:
|
||||
inst_obj = instance_obj.Instance()
|
||||
inst_obj = objects.Instance()
|
||||
inst_obj._from_db_object(message.ctxt, inst_obj, instance)
|
||||
instance = inst_obj
|
||||
args[0] = instance
|
||||
|
|
|
@ -30,8 +30,8 @@ from nova.compute import vm_states
|
|||
from nova import conductor
|
||||
from nova.db import base
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_action as instance_action_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -101,7 +101,7 @@ class CellsScheduler(base.Base):
|
|||
instances = []
|
||||
num_instances = len(instance_uuids)
|
||||
for i, instance_uuid in enumerate(instance_uuids):
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.update(instance_values)
|
||||
instance.uuid = instance_uuid
|
||||
instance = self.compute_api.create_db_entry_for_new_instance(
|
||||
|
|
|
@ -38,7 +38,6 @@ from nova.network.security_group import openstack_driver
|
|||
from nova import notifications
|
||||
from nova import objects
|
||||
from nova.objects import base as nova_object
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -474,13 +473,13 @@ class ComputeTaskManager(base.Base):
|
|||
exception.MigrationPreCheckError)
|
||||
def migrate_server(self, context, instance, scheduler_hint, live, rebuild,
|
||||
flavor, block_migration, disk_over_commit, reservations=None):
|
||||
if instance and not isinstance(instance, instance_obj.Instance):
|
||||
if instance and not isinstance(instance, nova_object.NovaObject):
|
||||
# NOTE(danms): Until v2 of the RPC API, we need to tolerate
|
||||
# old-world instance objects here
|
||||
attrs = ['metadata', 'system_metadata', 'info_cache',
|
||||
'security_groups']
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(), instance,
|
||||
instance = objects.Instance._from_db_object(
|
||||
context, objects.Instance(), instance,
|
||||
expected_attrs=attrs)
|
||||
if live and not rebuild and not flavor:
|
||||
self._live_migrate(context, instance, scheduler_hint,
|
||||
|
|
|
@ -24,7 +24,7 @@ from oslo import messaging
|
|||
from nova.cells import rpcapi as cells_rpcapi
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import manager
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.openstack.common.gettextutils import _, _LW
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -111,7 +111,7 @@ class ConsoleAuthManager(manager.Manager):
|
|||
return self.cells_rpcapi.validate_console_port(context,
|
||||
instance_uuid, token['port'], token['console_type'])
|
||||
|
||||
instance = instance_obj.Instance.get_by_uuid(context, instance_uuid)
|
||||
instance = objects.Instance.get_by_uuid(context, instance_uuid)
|
||||
|
||||
return self.compute_rpcapi.validate_console_port(context,
|
||||
instance,
|
||||
|
|
|
@ -24,9 +24,10 @@ from nova.network import base_api
|
|||
from nova.network import floating_ips
|
||||
from nova.network import model as network_model
|
||||
from nova.network import rpcapi as network_rpcapi
|
||||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import fixed_ip as fixed_ip_obj
|
||||
from nova.objects import floating_ip as floating_ip_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import network as network_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -262,9 +263,9 @@ class API(base_api.NetworkAPI):
|
|||
# this is called from compute.manager which shouldn't
|
||||
# have db access so we do it on the other side of the
|
||||
# rpc.
|
||||
if not isinstance(instance, instance_obj.Instance):
|
||||
instance = instance_obj.Instance._from_db_object(context,
|
||||
instance_obj.Instance(), instance)
|
||||
if not isinstance(instance, obj_base.NovaObject):
|
||||
instance = objects.Instance._from_db_object(context,
|
||||
objects.Instance(), instance)
|
||||
self.network_rpcapi.deallocate_for_instance(context, instance=instance,
|
||||
requested_networks=requested_networks)
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ from nova import context
|
|||
from nova.db import base
|
||||
from nova import exception
|
||||
from nova.network import rpcapi as network_rpcapi
|
||||
from nova import objects
|
||||
from nova.objects import dns_domain as dns_domain_obj
|
||||
from nova.objects import fixed_ip as fixed_ip_obj
|
||||
from nova.objects import floating_ip as floating_ip_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import network as network_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova.openstack.common import excutils
|
||||
|
@ -154,7 +154,7 @@ class FloatingIP(object):
|
|||
# NOTE(francois.charlier): in some cases the instance might be
|
||||
# deleted before the IPs are released, so we need to get
|
||||
# deleted instances too
|
||||
instance = instance_obj.Instance.get_by_id(
|
||||
instance = objects.Instance.get_by_id(
|
||||
context.elevated(read_deleted='yes'), instance_uuid)
|
||||
instance_uuid = instance.uuid
|
||||
|
||||
|
@ -336,7 +336,7 @@ class FloatingIP(object):
|
|||
network = network_obj.Network.get_by_id(context.elevated(),
|
||||
fixed_ip.network_id)
|
||||
if network.multi_host:
|
||||
instance = instance_obj.Instance.get_by_uuid(
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
context, fixed_ip.instance_uuid)
|
||||
host = instance.host
|
||||
else:
|
||||
|
@ -431,7 +431,7 @@ class FloatingIP(object):
|
|||
fixed_ip.network_id)
|
||||
interface = floating_ip.interface
|
||||
if network.multi_host:
|
||||
instance = instance_obj.Instance.get_by_uuid(
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
context, fixed_ip.instance_uuid)
|
||||
service = service_obj.Service.get_by_host_and_topic(
|
||||
context.elevated(), instance.host, CONF.network_topic)
|
||||
|
|
|
@ -63,10 +63,10 @@ from nova.network import driver
|
|||
from nova.network import floating_ips
|
||||
from nova.network import model as network_model
|
||||
from nova.network import rpcapi as network_rpcapi
|
||||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import dns_domain as dns_domain_obj
|
||||
from nova.objects import fixed_ip as fixed_ip_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_info_cache as info_cache_obj
|
||||
from nova.objects import network as network_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
|
@ -387,8 +387,7 @@ class NetworkManager(manager.Manager):
|
|||
# NOTE(francois.charlier): the instance may have been deleted already
|
||||
# thus enabling `read_deleted`
|
||||
admin_context = context.get_admin_context(read_deleted='yes')
|
||||
instance = instance_obj.Instance.get_by_uuid(admin_context,
|
||||
instance_id)
|
||||
instance = objects.Instance.get_by_uuid(admin_context, instance_id)
|
||||
|
||||
try:
|
||||
# NOTE(vish): We need to make sure the instance info cache has been
|
||||
|
@ -548,10 +547,10 @@ class NetworkManager(manager.Manager):
|
|||
else:
|
||||
instance_id = kwargs['instance_id']
|
||||
if uuidutils.is_uuid_like(instance_id):
|
||||
instance = instance_obj.Instance.get_by_uuid(
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
read_deleted_context, instance_id)
|
||||
else:
|
||||
instance = instance_obj.Instance.get_by_id(
|
||||
instance = objects.Instance.get_by_id(
|
||||
read_deleted_context, instance_id)
|
||||
# NOTE(russellb) in case instance_id was an ID and not UUID
|
||||
instance_uuid = instance.uuid
|
||||
|
@ -863,7 +862,7 @@ class NetworkManager(manager.Manager):
|
|||
|
||||
# NOTE(vish) This db query could be removed if we pass az and name
|
||||
# (or the whole instance object).
|
||||
instance = instance_obj.Instance.get_by_uuid(context, instance_id)
|
||||
instance = objects.Instance.get_by_uuid(context, instance_id)
|
||||
LOG.debug('Allocate fixed ip on network %s', network['uuid'],
|
||||
instance=instance)
|
||||
|
||||
|
@ -960,7 +959,7 @@ class NetworkManager(manager.Manager):
|
|||
# NOTE(danms) We can't use fixed_ip_ref.instance because
|
||||
# instance may be deleted and the relationship
|
||||
# doesn't extend to deleted instances
|
||||
instance = instance_obj.Instance.get_by_uuid(
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
context.elevated(read_deleted='yes'), instance_uuid)
|
||||
|
||||
quotas = self.quotas_cls()
|
||||
|
@ -1375,7 +1374,7 @@ class NetworkManager(manager.Manager):
|
|||
else:
|
||||
call_func = self._setup_network_on_host
|
||||
|
||||
instance = instance_obj.Instance.get_by_id(context, instance_id)
|
||||
instance = objects.Instance.get_by_id(context, instance_id)
|
||||
vifs = vif_obj.VirtualInterfaceList.get_by_instance_uuid(context,
|
||||
instance['uuid'])
|
||||
LOG.debug('Setup networks on host', instance=instance)
|
||||
|
@ -1460,7 +1459,7 @@ class NetworkManager(manager.Manager):
|
|||
"""Returns the vifs associated with an instance."""
|
||||
# NOTE(vish): This is no longer used but can't be removed until
|
||||
# we major version the network_rpcapi to 2.0.
|
||||
instance = instance_obj.Instance.get_by_id(context, instance_id)
|
||||
instance = objects.Instance.get_by_id(context, instance_id)
|
||||
LOG.debug('Get VIFs for instance', instance=instance)
|
||||
|
||||
# NOTE(russellb) No need to object-ify this since
|
||||
|
@ -1859,7 +1858,7 @@ class VlanManager(RPCAllocateFixedIP, floating_ips.FloatingIP, NetworkManager):
|
|||
|
||||
# NOTE(vish) This db query could be removed if we pass az and name
|
||||
# (or the whole instance object).
|
||||
instance = instance_obj.Instance.get_by_uuid(context, instance_id)
|
||||
instance = objects.Instance.get_by_uuid(context, instance_id)
|
||||
|
||||
name = instance.display_name
|
||||
if self._validate_instance_zone_for_dns_domain(context, instance):
|
||||
|
|
|
@ -28,6 +28,7 @@ from nova import db
|
|||
from nova.image import glance
|
||||
from nova import network
|
||||
from nova.network import model as network_model
|
||||
from nova.objects import base as obj_base
|
||||
from nova.openstack.common import context as common_context
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -273,10 +274,8 @@ def bandwidth_usage(instance_ref, audit_start,
|
|||
return
|
||||
raise
|
||||
|
||||
# FIXME(comstud): Temporary as we transition to objects. This import
|
||||
# is here to avoid circular imports.
|
||||
from nova.objects import instance as instance_obj
|
||||
if isinstance(instance_ref, instance_obj.Instance):
|
||||
# FIXME(comstud): Temporary as we transition to objects.
|
||||
if isinstance(instance_ref, obj_base.NovaObject):
|
||||
nw_info = instance_ref.info_cache.network_info
|
||||
if nw_info is None:
|
||||
nw_info = network_model.NetworkInfo()
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import network as network_obj
|
||||
from nova.objects import virtual_interface as vif_obj
|
||||
from nova.openstack.common import timeutils
|
||||
|
@ -67,9 +67,9 @@ class FixedIP(obj_base.NovaPersistentObject, obj_base.NovaObject):
|
|||
fixedip[field] = db_fixedip[field]
|
||||
# NOTE(danms): Instance could be deleted, and thus None
|
||||
if 'instance' in expected_attrs:
|
||||
fixedip.instance = instance_obj.Instance._from_db_object(
|
||||
fixedip.instance = objects.Instance._from_db_object(
|
||||
context,
|
||||
instance_obj.Instance(),
|
||||
objects.Instance(),
|
||||
db_fixedip['instance']) if db_fixedip['instance'] else None
|
||||
if 'network' in expected_attrs:
|
||||
fixedip.network = network_obj.Network._from_db_object(
|
||||
|
@ -206,11 +206,11 @@ class FixedIPList(obj_base.ObjectListBase, obj_base.NovaObject):
|
|||
fips = cls(context=context, objects=[])
|
||||
|
||||
for info in ipinfo:
|
||||
inst = instance_obj.Instance(context=context,
|
||||
uuid=info['instance_uuid'],
|
||||
hostname=info['instance_hostname'],
|
||||
created_at=info['instance_created'],
|
||||
updated_at=info['instance_updated'])
|
||||
inst = objects.Instance(context=context,
|
||||
uuid=info['instance_uuid'],
|
||||
hostname=info['instance_hostname'],
|
||||
created_at=info['instance_created'],
|
||||
updated_at=info['instance_updated'])
|
||||
vif = vif_obj.VirtualInterface(context=context,
|
||||
id=info['vif_id'],
|
||||
address=info['vif_address'])
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.openstack.common import uuidutils
|
||||
|
||||
|
||||
|
@ -154,8 +154,8 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject):
|
|||
if exclude:
|
||||
filter_uuids = set(filter_uuids) - set(exclude)
|
||||
filters = {'uuid': filter_uuids, 'deleted': False}
|
||||
instances = instance_obj.InstanceList.get_by_filters(context,
|
||||
filters=filters)
|
||||
instances = objects.InstanceList.get_by_filters(context,
|
||||
filters=filters)
|
||||
return list(set([instance.host for instance in instances
|
||||
if instance.host]))
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
|
||||
|
||||
class Migration(base.NovaPersistentObject, base.NovaObject):
|
||||
|
@ -76,8 +76,7 @@ class Migration(base.NovaPersistentObject, base.NovaObject):
|
|||
|
||||
@property
|
||||
def instance(self):
|
||||
return instance_obj.Instance.get_by_uuid(self._context,
|
||||
self.instance_uuid)
|
||||
return objects.Instance.get_by_uuid(self._context, self.instance_uuid)
|
||||
|
||||
|
||||
class MigrationList(base.ObjectListBase, base.NovaObject):
|
||||
|
|
|
@ -27,7 +27,7 @@ from nova.compute import utils as compute_utils
|
|||
from nova.compute import vm_states
|
||||
from nova import exception
|
||||
from nova import manager
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common import importutils
|
||||
from nova.openstack.common import jsonutils
|
||||
|
@ -122,8 +122,8 @@ class SchedulerManager(manager.Manager):
|
|||
(host, node) = (host_state['host'], host_state['nodename'])
|
||||
attrs = ['metadata', 'system_metadata', 'info_cache',
|
||||
'security_groups']
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(), instance,
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
context, objects.Instance(), instance,
|
||||
expected_attrs=attrs)
|
||||
self.compute_rpcapi.prep_resize(
|
||||
context, image, inst_obj, instance_type, host,
|
||||
|
|
|
@ -24,7 +24,6 @@ from nova import db
|
|||
from nova import exception
|
||||
from nova import notifications
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -50,7 +49,7 @@ def build_request_spec(ctxt, image, instances, instance_type=None):
|
|||
type.
|
||||
"""
|
||||
instance = instances[0]
|
||||
if isinstance(instance, instance_obj.Instance):
|
||||
if isinstance(instance, obj_base.NovaObject):
|
||||
instance = obj_base.obj_to_primitive(instance)
|
||||
|
||||
if instance_type is None:
|
||||
|
|
|
@ -20,7 +20,7 @@ from nova.api.openstack import wsgi
|
|||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.objects import instance
|
||||
from nova import objects
|
||||
from nova.objects import pci_device as pci_device_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.pci import pci_device
|
||||
|
@ -65,7 +65,7 @@ class PciServerControllerTest(test.NoDBTestCase):
|
|||
pci_device.allocate(self.pci_device, self.inst)
|
||||
|
||||
def _create_fake_instance(self):
|
||||
self.inst = instance.Instance()
|
||||
self.inst = objects.Instance()
|
||||
self.inst.uuid = 'fake-inst-uuid'
|
||||
self.inst.pci_devices = pci_device_obj.PciDeviceList()
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ from nova import context
|
|||
from nova import db
|
||||
from nova import exception
|
||||
from nova.network import model as network_model
|
||||
from nova import objects
|
||||
from nova.objects import base as objects_base
|
||||
from nova.objects import fields as objects_fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_fault as instance_fault_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import timeutils
|
||||
|
@ -696,12 +696,12 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
# NOTE(comstud): This block of code simulates the following
|
||||
# mox code:
|
||||
#
|
||||
# self.mox.StubOutWithMock(instance_obj, 'Instance',
|
||||
# self.mox.StubOutWithMock(objects, 'Instance',
|
||||
# use_mock_anything=True)
|
||||
# self.mox.StubOutWithMock(instance_obj.Instance,
|
||||
# self.mox.StubOutWithMock(objects.Instance,
|
||||
# '_from_db_object')
|
||||
# instance_mock = self.mox.CreateMock(instance_obj.Instance)
|
||||
# instance_obj.Instance().AndReturn(instance_mock)
|
||||
# instance_mock = self.mox.CreateMock(objects.Instance)
|
||||
# objects.Instance().AndReturn(instance_mock)
|
||||
#
|
||||
# Unfortunately, the above code fails on py27 do to some
|
||||
# issue with the Mock object do to similar issue as this:
|
||||
|
@ -717,7 +717,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
def fake_instance():
|
||||
return instance_mock
|
||||
|
||||
self.stubs.Set(instance_obj, 'Instance', fake_instance)
|
||||
self.stubs.Set(objects, 'Instance', fake_instance)
|
||||
self.mox.StubOutWithMock(instance_mock, '_from_db_object')
|
||||
return instance_mock
|
||||
|
||||
|
@ -1086,7 +1086,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
self.assertEqual(0, len(responses))
|
||||
|
||||
def test_call_compute_api_with_obj(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.uuid = uuidutils.generate_uuid()
|
||||
self.mox.StubOutWithMock(instance, 'refresh')
|
||||
# Using 'snapshot' for this test, because it
|
||||
|
@ -1104,7 +1104,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
self.assertEqual('foo', result)
|
||||
|
||||
def test_call_compute_with_obj_unknown_instance(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.uuid = uuidutils.generate_uuid()
|
||||
instance.vm_state = vm_states.ACTIVE
|
||||
instance.task_state = None
|
||||
|
@ -1130,7 +1130,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
message = FakeMessage()
|
||||
message.ctxt = self.ctxt
|
||||
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.cell_name = self.tgt_cell_name
|
||||
instance.obj_reset_changes()
|
||||
instance.task_state = 'meow'
|
||||
|
@ -1293,7 +1293,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
(), {}, (), {}, False)
|
||||
|
||||
def test_snapshot_instance(self):
|
||||
inst = instance_obj.Instance()
|
||||
inst = objects.Instance()
|
||||
meth_cls = self.tgt_methods_cls
|
||||
|
||||
self.mox.StubOutWithMock(inst, 'refresh')
|
||||
|
@ -1322,7 +1322,7 @@ class CellsTargetedMethodsTestCase(test.TestCase):
|
|||
meth_cls.snapshot_instance(message, inst, image_id='image-id')
|
||||
|
||||
def test_backup_instance(self):
|
||||
inst = instance_obj.Instance()
|
||||
inst = objects.Instance()
|
||||
meth_cls = self.tgt_methods_cls
|
||||
|
||||
self.mox.StubOutWithMock(inst, 'refresh')
|
||||
|
|
|
@ -17,7 +17,7 @@ from nova.compute import utils as compute_utils
|
|||
from nova.conductor.tasks import live_migrate
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.scheduler import utils as scheduler_utils
|
||||
from nova import test
|
||||
from nova.tests import fake_instance
|
||||
|
@ -36,8 +36,8 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
|
|||
power_state=power_state.RUNNING,
|
||||
memory_mb=512,
|
||||
image_ref=self.instance_image)
|
||||
self.instance = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), db_instance)
|
||||
self.instance = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), db_instance)
|
||||
self.destination = "destination"
|
||||
self.block_migration = "bm"
|
||||
self.disk_over_commit = "doc"
|
||||
|
|
|
@ -38,7 +38,6 @@ from nova import notifications
|
|||
from nova import objects
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import timeutils
|
||||
|
@ -1118,12 +1117,12 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
def test_live_migrate(self):
|
||||
inst = fake_instance.fake_db_instance()
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst, [])
|
||||
|
||||
self.mox.StubOutWithMock(live_migrate, 'execute')
|
||||
live_migrate.execute(self.context,
|
||||
mox.IsA(instance_obj.Instance),
|
||||
mox.IsA(objects.Instance),
|
||||
'destination',
|
||||
'block_migration',
|
||||
'disk_over_commit')
|
||||
|
@ -1148,18 +1147,18 @@ class _BaseTaskTestCase(object):
|
|||
self.mox.StubOutWithMock(self.conductor_manager.scheduler_rpcapi,
|
||||
'select_destinations')
|
||||
inst = fake_instance.fake_db_instance(image_ref='image_ref')
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst, [])
|
||||
flavor = flavors.get_default_flavor()
|
||||
flavor['extra_specs'] = 'extra_specs'
|
||||
request_spec = {'instance_type': flavor}
|
||||
compute_utils.get_image_metadata(
|
||||
self.context, self.conductor_manager.image_api,
|
||||
'image_ref', mox.IsA(instance_obj.Instance)).AndReturn('image')
|
||||
'image_ref', mox.IsA(objects.Instance)).AndReturn('image')
|
||||
|
||||
scheduler_utils.build_request_spec(
|
||||
self.context, 'image',
|
||||
[mox.IsA(instance_obj.Instance)],
|
||||
[mox.IsA(objects.Instance)],
|
||||
instance_type=flavor).AndReturn(request_spec)
|
||||
|
||||
hosts = [dict(host='host1', nodename=None, limits={})]
|
||||
|
@ -1169,7 +1168,7 @@ class _BaseTaskTestCase(object):
|
|||
filter_properties = {'limits': {}}
|
||||
|
||||
self.conductor_manager.compute_rpcapi.prep_resize(
|
||||
self.context, 'image', mox.IsA(instance_obj.Instance),
|
||||
self.context, 'image', mox.IsA(objects.Instance),
|
||||
mox.IsA(dict), 'host1', [], request_spec=request_spec,
|
||||
filter_properties=filter_properties, node=None)
|
||||
|
||||
|
@ -1328,7 +1327,7 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
def test_unshelve_instance_on_host(self):
|
||||
db_instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
instance = instance_obj.Instance.get_by_uuid(self.context,
|
||||
instance = objects.Instance.get_by_uuid(self.context,
|
||||
db_instance['uuid'], expected_attrs=['system_metadata'])
|
||||
instance.vm_state = vm_states.SHELVED
|
||||
instance.task_state = task_states.UNSHELVING
|
||||
|
@ -1356,7 +1355,7 @@ class _BaseTaskTestCase(object):
|
|||
shelved_image_id = "image_not_found"
|
||||
|
||||
db_instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
instance = instance_obj.Instance.get_by_uuid(
|
||||
instance = objects.Instance.get_by_uuid(
|
||||
self.context,
|
||||
db_instance['uuid'],
|
||||
expected_attrs=['system_metadata'])
|
||||
|
@ -1384,7 +1383,7 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
def test_unshelve_instance_schedule_and_rebuild(self):
|
||||
db_instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
instance = instance_obj.Instance.get_by_uuid(self.context,
|
||||
instance = objects.Instance.get_by_uuid(self.context,
|
||||
db_instance['uuid'], expected_attrs=['system_metadata'])
|
||||
instance.vm_state = vm_states.SHELVED_OFFLOADED
|
||||
instance.save()
|
||||
|
@ -1415,7 +1414,7 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
def test_unshelve_instance_schedule_and_rebuild_novalid_host(self):
|
||||
db_instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
instance = instance_obj.Instance.get_by_uuid(self.context,
|
||||
instance = objects.Instance.get_by_uuid(self.context,
|
||||
db_instance['uuid'], expected_attrs=['system_metadata'])
|
||||
instance.vm_state = vm_states.SHELVED_OFFLOADED
|
||||
instance.save()
|
||||
|
@ -1441,7 +1440,7 @@ class _BaseTaskTestCase(object):
|
|||
|
||||
def test_unshelve_instance_schedule_and_rebuild_volume_backed(self):
|
||||
db_instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
instance = instance_obj.Instance.get_by_uuid(self.context,
|
||||
instance = objects.Instance.get_by_uuid(self.context,
|
||||
db_instance['uuid'], expected_attrs=['system_metadata'])
|
||||
instance.vm_state = vm_states.SHELVED_OFFLOADED
|
||||
instance.save()
|
||||
|
@ -1495,13 +1494,13 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
def _test_migrate_server_deals_with_expected_exceptions(self, ex):
|
||||
instance = fake_instance.fake_db_instance(uuid='uuid',
|
||||
vm_state=vm_states.ACTIVE)
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), instance, [])
|
||||
self.mox.StubOutWithMock(live_migrate, 'execute')
|
||||
self.mox.StubOutWithMock(scheduler_utils,
|
||||
'set_vm_state_and_notify')
|
||||
|
||||
live_migrate.execute(self.context, mox.IsA(instance_obj.Instance),
|
||||
live_migrate.execute(self.context, mox.IsA(objects.Instance),
|
||||
'destination', 'block_migration',
|
||||
'disk_over_commit').AndRaise(ex)
|
||||
|
||||
|
@ -1524,14 +1523,14 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
def test_migrate_server_deals_with_invalidcpuinfo_exception(self):
|
||||
instance = fake_instance.fake_db_instance(uuid='uuid',
|
||||
vm_state=vm_states.ACTIVE)
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), instance, [])
|
||||
self.mox.StubOutWithMock(live_migrate, 'execute')
|
||||
self.mox.StubOutWithMock(scheduler_utils,
|
||||
'set_vm_state_and_notify')
|
||||
|
||||
ex = exc.InvalidCPUInfo(reason="invalid cpu info.")
|
||||
live_migrate.execute(self.context, mox.IsA(instance_obj.Instance),
|
||||
live_migrate.execute(self.context, mox.IsA(objects.Instance),
|
||||
'destination', 'block_migration',
|
||||
'disk_over_commit').AndRaise(ex)
|
||||
|
||||
|
@ -1556,8 +1555,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
def test_migrate_server_deals_with_instancenotrunning_exception(self,
|
||||
mock_live_migrate, mock_set_state):
|
||||
inst = fake_instance.fake_db_instance()
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst, [])
|
||||
|
||||
error = exc.InstanceNotRunning(instance_id="fake")
|
||||
mock_live_migrate.side_effect = error
|
||||
|
@ -1587,14 +1586,14 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
def test_migrate_server_deals_with_unexpected_exceptions(self):
|
||||
instance = fake_instance.fake_db_instance()
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance, [])
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), instance, [])
|
||||
self.mox.StubOutWithMock(live_migrate, 'execute')
|
||||
self.mox.StubOutWithMock(scheduler_utils,
|
||||
'set_vm_state_and_notify')
|
||||
|
||||
ex = IOError()
|
||||
live_migrate.execute(self.context, mox.IsA(instance_obj.Instance),
|
||||
live_migrate.execute(self.context, mox.IsA(objects.Instance),
|
||||
'destination', 'block_migration',
|
||||
'disk_over_commit').AndRaise(ex)
|
||||
self.mox.ReplayAll()
|
||||
|
@ -1620,8 +1619,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
def test_cold_migrate_no_valid_host_back_in_active_state(self):
|
||||
inst = fake_instance.fake_db_instance(image_ref='fake-image_ref')
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst,
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst,
|
||||
expected_attrs=[])
|
||||
request_spec = dict(instance_type=dict(extra_specs=dict()))
|
||||
filter_props = dict(context=None)
|
||||
|
@ -1638,7 +1637,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
compute_utils.get_image_metadata(
|
||||
self.context, self.conductor_manager.image_api,
|
||||
'fake-image_ref', mox.IsA(instance_obj.Instance)).AndReturn(image)
|
||||
'fake-image_ref', mox.IsA(objects.Instance)).AndReturn(image)
|
||||
|
||||
scheduler_utils.build_request_spec(
|
||||
self.context, image, [inst_obj],
|
||||
|
@ -1672,8 +1671,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
def test_cold_migrate_no_valid_host_back_in_stopped_state(self):
|
||||
inst = fake_instance.fake_db_instance(image_ref='fake-image_ref',
|
||||
vm_state=vm_states.STOPPED)
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst,
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst,
|
||||
expected_attrs=[])
|
||||
request_spec = dict(instance_type=dict(extra_specs=dict()))
|
||||
filter_props = dict(context=None)
|
||||
|
@ -1690,7 +1689,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
compute_utils.get_image_metadata(
|
||||
self.context, self.conductor_manager.image_api,
|
||||
'fake-image_ref', mox.IsA(instance_obj.Instance)).AndReturn(image)
|
||||
'fake-image_ref', mox.IsA(objects.Instance)).AndReturn(image)
|
||||
|
||||
scheduler_utils.build_request_spec(
|
||||
self.context, image, [inst_obj],
|
||||
|
@ -1724,8 +1723,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
def test_cold_migrate_exception_host_in_error_state_and_raise(self):
|
||||
inst = fake_instance.fake_db_instance(image_ref='fake-image_ref',
|
||||
vm_state=vm_states.STOPPED)
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), inst,
|
||||
inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), inst,
|
||||
expected_attrs=[])
|
||||
request_spec = dict(instance_type=dict(extra_specs=dict()))
|
||||
filter_props = dict(context=None)
|
||||
|
@ -1747,7 +1746,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
|
||||
compute_utils.get_image_metadata(
|
||||
self.context, self.conductor_manager.image_api,
|
||||
'fake-image_ref', mox.IsA(instance_obj.Instance)).AndReturn(image)
|
||||
'fake-image_ref', mox.IsA(objects.Instance)).AndReturn(image)
|
||||
|
||||
scheduler_utils.build_request_spec(
|
||||
self.context, image, [inst_obj],
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import datetime
|
||||
import uuid
|
||||
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import instance_fault as inst_fault_obj
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ def fake_db_instance(**updates):
|
|||
'ephemeral_gb': 0
|
||||
}
|
||||
|
||||
for name, field in instance_obj.Instance.fields.items():
|
||||
for name, field in objects.Instance.fields.items():
|
||||
if name in db_instance:
|
||||
continue
|
||||
if field.nullable:
|
||||
|
@ -80,8 +80,8 @@ def fake_db_instance(**updates):
|
|||
|
||||
def fake_instance_obj(context, **updates):
|
||||
expected_attrs = updates.pop('expected_attrs', None)
|
||||
return instance_obj.Instance._from_db_object(context,
|
||||
instance_obj.Instance(), fake_db_instance(**updates),
|
||||
return objects.Instance._from_db_object(context,
|
||||
objects.Instance(), fake_db_instance(**updates),
|
||||
expected_attrs=expected_attrs)
|
||||
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ from nova.network import floating_ips
|
|||
from nova.network import linux_net
|
||||
from nova.network import manager as network_manager
|
||||
from nova.network import model as net_model
|
||||
from nova import objects
|
||||
from nova.objects import fixed_ip as fixed_ip_obj
|
||||
from nova.objects import floating_ip as floating_ip_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import network as network_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
from nova.objects import virtual_interface as vif_obj
|
||||
|
@ -643,7 +643,7 @@ class FlatNetworkTestCase(test.TestCase):
|
|||
@mock.patch('nova.objects.quotas.ids_from_instance')
|
||||
def test_allocate_calculates_quota_auth(self, util_method, reserve,
|
||||
get_by_uuid):
|
||||
inst = instance_obj.Instance()
|
||||
inst = objects.Instance()
|
||||
inst['uuid'] = 'nosuch'
|
||||
get_by_uuid.return_value = inst
|
||||
reserve.side_effect = exception.OverQuota(overs='testing')
|
||||
|
@ -658,7 +658,7 @@ class FlatNetworkTestCase(test.TestCase):
|
|||
@mock.patch('nova.objects.quotas.ids_from_instance')
|
||||
def test_deallocate_calculates_quota_auth(self, util_method, reserve,
|
||||
get_by_address):
|
||||
inst = instance_obj.Instance(uuid='fake-uuid')
|
||||
inst = objects.Instance(uuid='fake-uuid')
|
||||
fip = fixed_ip_obj.FixedIP(instance_uuid='fake-uuid',
|
||||
virtual_interface_id=1)
|
||||
get_by_address.return_value = fip
|
||||
|
@ -675,7 +675,7 @@ class FlatNetworkTestCase(test.TestCase):
|
|||
def test_allocate_fixed_ip_passes_string_address(self, mock_associate,
|
||||
mock_get):
|
||||
mock_associate.side_effect = test.TestingException
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.create()
|
||||
mock_get.return_value = instance
|
||||
self.assertRaises(test.TestingException,
|
||||
|
@ -707,7 +707,7 @@ class FlatNetworkTestCase(test.TestCase):
|
|||
virtual_interface_id=1)
|
||||
mock_fixedip_associate.return_value = fip
|
||||
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.create()
|
||||
mock_instance_get.return_value = instance
|
||||
|
||||
|
@ -883,7 +883,7 @@ class VlanNetworkTestCase(test.TestCase):
|
|||
def test_allocate_fixed_ip_passes_string_address(self, mock_associate,
|
||||
mock_get):
|
||||
mock_associate.side_effect = test.TestingException
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.create()
|
||||
mock_get.return_value = instance
|
||||
self.assertRaises(test.TestingException,
|
||||
|
@ -901,7 +901,7 @@ class VlanNetworkTestCase(test.TestCase):
|
|||
def test_allocate_fixed_ip_passes_string_address_vpn(self, mock_associate,
|
||||
mock_get):
|
||||
mock_associate.side_effect = test.TestingException
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.create()
|
||||
mock_get.return_value = instance
|
||||
self.assertRaises(test.TestingException,
|
||||
|
@ -1807,8 +1807,8 @@ class CommonNetworkTestCase(test.TestCase):
|
|||
network_id=123)]
|
||||
|
||||
manager.deallocate_for_instance(
|
||||
ctx, instance=instance_obj.Instance._from_db_object(self.context,
|
||||
instance_obj.Instance(), instance_get.return_value))
|
||||
ctx, instance=objects.Instance._from_db_object(self.context,
|
||||
objects.Instance(), instance_get.return_value))
|
||||
|
||||
self.assertEqual([
|
||||
(ctx, '1.2.3.4', 'fake-host')
|
||||
|
@ -2411,7 +2411,7 @@ class AllocateTestCase(test.TestCase):
|
|||
db.floating_ip_create(self.context,
|
||||
{'address': address,
|
||||
'pool': 'nova'})
|
||||
inst = instance_obj.Instance()
|
||||
inst = objects.Instance()
|
||||
inst.host = self.compute.host
|
||||
inst.display_name = HOST
|
||||
inst.instance_type_id = 1
|
||||
|
@ -2614,7 +2614,7 @@ class FloatingIPTestCase(test.TestCase):
|
|||
def test_deallocation_deleted_instance(self):
|
||||
self.stubs.Set(self.network, '_teardown_network_on_host',
|
||||
lambda *args, **kwargs: None)
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.project_id = self.project_id
|
||||
instance.deleted = True
|
||||
instance.create(self.context)
|
||||
|
@ -2634,7 +2634,7 @@ class FloatingIPTestCase(test.TestCase):
|
|||
def test_deallocation_duplicate_floating_ip(self):
|
||||
self.stubs.Set(self.network, '_teardown_network_on_host',
|
||||
lambda *args, **kwargs: None)
|
||||
instance = instance_obj.Instance()
|
||||
instance = objects.Instance()
|
||||
instance.project_id = self.project_id
|
||||
instance.create(self.context)
|
||||
network = db.network_create_safe(self.context.elevated(), {
|
||||
|
|
|
@ -21,7 +21,6 @@ from nova import db
|
|||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import block_device as block_device_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.tests import fake_block_device
|
||||
from nova.tests import fake_instance
|
||||
from nova.tests.objects import test_objects
|
||||
|
@ -64,7 +63,7 @@ class _TestBlockDeviceMappingObject(object):
|
|||
|
||||
def test_save_instance_changed(self):
|
||||
bdm_object = objects.BlockDeviceMapping()
|
||||
bdm_object.instance = instance_obj.Instance()
|
||||
bdm_object.instance = objects.Instance()
|
||||
self.assertRaises(exception.ObjectActionError,
|
||||
bdm_object.save, self.context)
|
||||
|
||||
|
@ -154,7 +153,7 @@ class _TestBlockDeviceMappingObject(object):
|
|||
values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
|
||||
'destination_type': 'volume',
|
||||
'instance_uuid': 'fake-instance',
|
||||
'instance': instance_obj.Instance()}
|
||||
'instance': objects.Instance()}
|
||||
bdm = objects.BlockDeviceMapping(**values)
|
||||
self.assertRaises(exception.ObjectActionError,
|
||||
bdm.create, self.context)
|
||||
|
|
|
@ -20,7 +20,7 @@ from nova.compute import vm_states
|
|||
from nova import context
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.objects import instance
|
||||
from nova import objects
|
||||
from nova.objects import pci_device as pci_device_obj
|
||||
from nova.pci import pci_device
|
||||
from nova.pci import pci_manager
|
||||
|
@ -73,7 +73,7 @@ fake_pci_requests = [
|
|||
|
||||
class PciDevTrackerTestCase(test.TestCase):
|
||||
def _create_fake_instance(self):
|
||||
self.inst = instance.Instance()
|
||||
self.inst = objects.Instance()
|
||||
self.inst.uuid = 'fake-inst-uuid'
|
||||
self.inst.pci_devices = pci_device_obj.PciDeviceList()
|
||||
self.inst.vm_state = vm_states.ACTIVE
|
||||
|
@ -342,9 +342,8 @@ class PciGetInstanceDevs(test.TestCase):
|
|||
db.instance_get(ctxt, '1', columns_to_join=[]
|
||||
).AndReturn(inst)
|
||||
self.mox.ReplayAll()
|
||||
inst = instance.Instance.get_by_id(ctxt, '1', expected_attrs=[])
|
||||
self.stubs.Set(instance.Instance, 'obj_load_attr',
|
||||
_fake_obj_load_attr)
|
||||
inst = objects.Instance.get_by_id(ctxt, '1', expected_attrs=[])
|
||||
self.stubs.Set(objects.Instance, 'obj_load_attr', _fake_obj_load_attr)
|
||||
|
||||
self.load_attr_called = False
|
||||
pci_manager.get_instance_pci_devs(inst)
|
||||
|
|
|
@ -27,7 +27,7 @@ from nova import context
|
|||
from nova import db
|
||||
from nova import exception
|
||||
from nova.image import glance
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova import rpc
|
||||
from nova.scheduler import driver
|
||||
from nova.scheduler import manager
|
||||
|
@ -258,7 +258,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
|
|||
|
||||
self.mox.StubOutWithMock(self.manager.compute_rpcapi, 'prep_resize')
|
||||
self.manager.compute_rpcapi.prep_resize(self.context, image,
|
||||
mox.IsA(instance_obj.Instance),
|
||||
mox.IsA(objects.Instance),
|
||||
instance_type, 'host', reservations, request_spec=request_spec,
|
||||
filter_properties=filter_properties, node='node')
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ from nova import db
|
|||
from nova.db.sqlalchemy import api
|
||||
from nova import exception
|
||||
from nova.network import api as network_api
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova import test
|
||||
from nova.tests import fake_block_device
|
||||
from nova.tests import fake_instance
|
||||
|
@ -81,8 +81,8 @@ INSTANCE = fake_instance.fake_db_instance(**
|
|||
|
||||
|
||||
def fake_inst_obj(context):
|
||||
return instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(), INSTANCE,
|
||||
return objects.Instance._from_db_object(
|
||||
context, objects.Instance(), INSTANCE,
|
||||
expected_attrs=['metadata', 'system_metadata',
|
||||
'info_cache'])
|
||||
|
||||
|
@ -193,12 +193,12 @@ class MetadataTestCase(test.TestCase):
|
|||
def test_format_instance_mapping(self):
|
||||
# Make sure that _format_instance_mappings works.
|
||||
ctxt = None
|
||||
instance_ref0 = instance_obj.Instance(**{'id': 0,
|
||||
instance_ref0 = objects.Instance(**{'id': 0,
|
||||
'uuid': 'e5fe5518-0288-4fa3-b0c4-c79764101b85',
|
||||
'root_device_name': None,
|
||||
'default_ephemeral_device': None,
|
||||
'default_swap_device': None})
|
||||
instance_ref1 = instance_obj.Instance(**{'id': 0,
|
||||
instance_ref1 = objects.Instance(**{'id': 0,
|
||||
'uuid': 'b65cee2f-8c69-4aeb-be2f-f79742548fc2',
|
||||
'root_device_name': '/dev/sda1',
|
||||
'default_ephemeral_device': None,
|
||||
|
|
|
@ -26,7 +26,7 @@ from nova import exception
|
|||
from nova.image import glance
|
||||
from nova.network import minidns
|
||||
from nova.network import model as network_model
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
import nova.utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -95,7 +95,7 @@ def get_test_instance(context=None, flavor=None, obj=False):
|
|||
}
|
||||
|
||||
if obj:
|
||||
instance = instance_obj.Instance(context, **test_instance)
|
||||
instance = objects.Instance(context, **test_instance)
|
||||
instance.create()
|
||||
else:
|
||||
instance = nova.db.instance_create(context, test_instance)
|
||||
|
|
|
@ -28,7 +28,7 @@ from nova.compute import power_state
|
|||
from nova.compute import task_states
|
||||
from nova import db as main_db
|
||||
from nova import exception
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova import test
|
||||
from nova.tests.image import fake as fake_image
|
||||
|
@ -142,8 +142,8 @@ class BareMetalDriverWithDBTestCase(bm_db_base.BMDBTestCase):
|
|||
block_device_info=result['spawn_params']['block_device_info'],
|
||||
)
|
||||
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), result['instance'])
|
||||
instance = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), result['instance'])
|
||||
instance.node = result['node']['uuid']
|
||||
|
||||
result['rebuild_params'] = dict(
|
||||
|
@ -187,7 +187,7 @@ class BareMetalDriverWithDBTestCase(bm_db_base.BMDBTestCase):
|
|||
self.assertEqual(instance['default_ephemeral_device'], '/dev/sda1')
|
||||
|
||||
def test_set_default_ephemeral_device(self):
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.system_metadata = flavors.save_flavor_info(
|
||||
{}, flavors.get_default_flavor())
|
||||
instance.system_metadata['instance_type_ephemeral_gb'] = 1
|
||||
|
|
|
@ -42,8 +42,8 @@ from nova import context
|
|||
from nova import db
|
||||
from nova import exception
|
||||
from nova.network import model as network_model
|
||||
from nova import objects
|
||||
from nova.objects import flavor as flavor_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import pci_device as pci_device_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova.openstack.common import fileutils
|
||||
|
@ -582,7 +582,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
default_params = self.test_instance
|
||||
default_params['pci_devices'] = pci_device_obj.PciDeviceList()
|
||||
default_params.update(params)
|
||||
instance = instance_obj.Instance(context, **params)
|
||||
instance = objects.Instance(context, **params)
|
||||
flavor = flavors.get_default_flavor()
|
||||
instance.system_metadata = flavors.save_flavor_info({}, flavor)
|
||||
instance.instance_type_id = flavor['id']
|
||||
|
@ -5238,11 +5238,11 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
self.stubs.Set(conn.firewall_driver,
|
||||
'unfilter_instance', fake_unfilter_instance)
|
||||
self.stubs.Set(os.path, 'exists', fake_os_path_exists)
|
||||
self.stubs.Set(instance_obj.Instance, 'fields',
|
||||
self.stubs.Set(objects.Instance, 'fields',
|
||||
{'id': int, 'uuid': str, 'cleaned': int})
|
||||
self.stubs.Set(instance_obj.Instance, 'obj_load_attr',
|
||||
self.stubs.Set(objects.Instance, 'obj_load_attr',
|
||||
fake_obj_load_attr)
|
||||
self.stubs.Set(instance_obj.Instance, 'save', fake_save)
|
||||
self.stubs.Set(objects.Instance, 'save', fake_save)
|
||||
|
||||
conn.destroy(self.context, instance, [], vol)
|
||||
|
||||
|
@ -5313,12 +5313,12 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
self[attrname] = {}
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
self.stubs.Set(instance_obj.Instance, 'fields',
|
||||
self.stubs.Set(objects.Instance, 'fields',
|
||||
{'id': int, 'uuid': str, 'cleaned': int})
|
||||
self.stubs.Set(instance_obj.Instance, 'obj_load_attr',
|
||||
self.stubs.Set(objects.Instance, 'obj_load_attr',
|
||||
fake_obj_load_attr)
|
||||
|
||||
inst_obj = instance_obj.Instance.get_by_uuid(None, instance['uuid'])
|
||||
inst_obj = objects.Instance.get_by_uuid(None, instance['uuid'])
|
||||
self.assertFalse(conn.delete_instance_files(inst_obj))
|
||||
self.assertTrue(conn.delete_instance_files(inst_obj))
|
||||
|
||||
|
@ -7166,7 +7166,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
self.flags(virt_type='lxc', group='libvirt')
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
instance = instance_obj.Instance(id=1, uuid='fake-uuid')
|
||||
instance = objects.Instance(id=1, uuid='fake-uuid')
|
||||
|
||||
with contextlib.nested(
|
||||
mock.patch.object(conn, 'plug_vifs'),
|
||||
|
@ -7185,7 +7185,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
self.flags(virt_type='lxc', group='libvirt')
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
instance = instance_obj.Instance(id=1, uuid='fake-uuid')
|
||||
instance = objects.Instance(id=1, uuid='fake-uuid')
|
||||
|
||||
with contextlib.nested(
|
||||
mock.patch.object(conn, 'plug_vifs'),
|
||||
|
@ -7227,7 +7227,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
prepare.side_effect = fake_prepare
|
||||
conn = libvirt_driver.LibvirtDriver(virtapi, False)
|
||||
|
||||
instance = instance_obj.Instance(id=1, uuid='fake-uuid')
|
||||
instance = objects.Instance(id=1, uuid='fake-uuid')
|
||||
vifs = [{'id': 'vif1', 'active': False},
|
||||
{'id': 'vif2', 'active': False}]
|
||||
|
||||
|
@ -9030,8 +9030,7 @@ class LibvirtDriverTestCase(test.TestCase):
|
|||
@mock.patch('os.path.exists')
|
||||
@mock.patch('nova.virt.libvirt.lvm.list_volumes')
|
||||
def test_lvm_disks(self, listlvs, exists):
|
||||
instance = instance_obj.Instance(uuid='fake-uuid',
|
||||
id=1)
|
||||
instance = objects.Instance(uuid='fake-uuid', id=1)
|
||||
self.flags(images_volume_group='vols', group='libvirt')
|
||||
exists.return_value = True
|
||||
listlvs.return_value = ['fake-uuid_foo',
|
||||
|
|
|
@ -21,7 +21,7 @@ from nova.compute import power_state
|
|||
from nova import context
|
||||
from nova import exception
|
||||
from nova.network import model as network_model
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.openstack.common import units
|
||||
from nova.openstack.common import uuidutils
|
||||
from nova import test
|
||||
|
@ -290,8 +290,7 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
|
|||
mock.call('fake_snapshot_task')])
|
||||
|
||||
def test_update_instance_progress(self):
|
||||
instance = instance_obj.Instance(context=mock.MagicMock(),
|
||||
uuid='fake-uuid')
|
||||
instance = objects.Instance(context=mock.MagicMock(), uuid='fake-uuid')
|
||||
with mock.patch.object(instance, 'save') as mock_save:
|
||||
self._vmops._update_instance_progress(instance._context,
|
||||
instance, 5, 10)
|
||||
|
|
|
@ -19,7 +19,7 @@ import mock
|
|||
from nova.compute import power_state
|
||||
from nova.compute import task_states
|
||||
from nova import exception
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.pci import pci_manager
|
||||
from nova import test
|
||||
from nova.tests import fake_instance
|
||||
|
@ -782,7 +782,7 @@ class CreateVMRecordTestCase(VMOpsTestBase):
|
|||
mock_get_vm_device_id, mock_determine_vm_mode):
|
||||
|
||||
context = "context"
|
||||
instance = instance_obj.Instance(vm_mode="vm_mode", uuid="uuid123")
|
||||
instance = objects.Instance(vm_mode="vm_mode", uuid="uuid123")
|
||||
name_label = "dummy"
|
||||
disk_image_type = "vhd"
|
||||
kernel_file = "kernel"
|
||||
|
|
|
@ -330,8 +330,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
vm_utils.lookup(mox.IgnoreArg(), 'foo').AndReturn(True)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.stubs.Set(instance_obj.Instance, 'name', 'foo')
|
||||
instance = instance_obj.Instance(uuid='fake-uuid')
|
||||
self.stubs.Set(objects.Instance, 'name', 'foo')
|
||||
instance = objects.Instance(uuid='fake-uuid')
|
||||
self.assertTrue(self.conn.instance_exists(instance))
|
||||
|
||||
def test_instance_not_exists(self):
|
||||
|
@ -339,8 +339,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
vm_utils.lookup(mox.IgnoreArg(), 'bar').AndReturn(None)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.stubs.Set(instance_obj.Instance, 'name', 'bar')
|
||||
instance = instance_obj.Instance(uuid='fake-uuid')
|
||||
self.stubs.Set(objects.Instance, 'name', 'bar')
|
||||
instance = objects.Instance(uuid='fake-uuid')
|
||||
self.assertFalse(self.conn.instance_exists(instance))
|
||||
|
||||
def test_list_instances_0(self):
|
||||
|
@ -665,7 +665,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
fake_inject_instance_metadata)
|
||||
|
||||
if create_record:
|
||||
instance = instance_obj.Instance(context=self.context)
|
||||
instance = objects.Instance(context=self.context)
|
||||
instance.project_id = self.project_id
|
||||
instance.user_id = self.user_id
|
||||
instance.image_ref = image_ref
|
||||
|
@ -682,8 +682,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
self.context, instance_type_id)
|
||||
instance.create()
|
||||
else:
|
||||
instance = instance_obj.Instance.get_by_id(self.context,
|
||||
instance_id)
|
||||
instance = objects.Instance.get_by_id(self.context, instance_id)
|
||||
|
||||
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
|
||||
if empty_dns:
|
||||
|
@ -1459,8 +1458,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
|||
self.conn.spawn(self.context, instance, image_meta, [], 'herp',
|
||||
network_info)
|
||||
if obj:
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance,
|
||||
instance = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), instance,
|
||||
expected_attrs=instance_obj.INSTANCE_DEFAULT_FIELDS)
|
||||
return instance
|
||||
|
||||
|
@ -1789,8 +1788,8 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
|
|||
self.mox.StubOutWithMock(vm_utils, 'get_vdi_for_vm_safely')
|
||||
self.mox.StubOutWithMock(vmops, '_restore_orig_vm_and_cleanup_orphan')
|
||||
|
||||
instance = instance_obj.Instance(context=self.context,
|
||||
auto_disk_config=True, uuid='uuid')
|
||||
instance = objects.Instance(context=self.context,
|
||||
auto_disk_config=True, uuid='uuid')
|
||||
instance.obj_reset_changes()
|
||||
vm_ref = "vm_ref"
|
||||
dest = "dest"
|
||||
|
|
|
@ -20,7 +20,7 @@ from oslo.config import cfg
|
|||
from nova.compute import utils as compute_utils
|
||||
from nova import context
|
||||
from nova.network import linux_net
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova import objects
|
||||
from nova.objects import security_group as security_group_obj
|
||||
from nova.objects import security_group_rule as security_group_rule_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -336,8 +336,8 @@ class IptablesFirewallDriver(FirewallDriver):
|
|||
if isinstance(instance, dict):
|
||||
# NOTE(danms): allow old-world instance objects from
|
||||
# unconverted callers; all we need is instance.uuid below
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
ctxt, instance_obj.Instance(), instance, [])
|
||||
instance = objects.Instance._from_db_object(
|
||||
ctxt, objects.Instance(), instance, [])
|
||||
|
||||
ipv4_rules = []
|
||||
ipv6_rules = []
|
||||
|
@ -403,7 +403,7 @@ class IptablesFirewallDriver(FirewallDriver):
|
|||
else:
|
||||
if rule['grantee_group']:
|
||||
insts = (
|
||||
instance_obj.InstanceList.get_by_security_group(
|
||||
objects.InstanceList.get_by_security_group(
|
||||
ctxt, rule['grantee_group']))
|
||||
for instance in insts:
|
||||
if instance['info_cache']['deleted']:
|
||||
|
|
|
@ -59,7 +59,6 @@ from nova import exception
|
|||
from nova import image
|
||||
from nova import objects
|
||||
from nova.objects import flavor as flavor_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common import fileutils
|
||||
|
@ -5210,7 +5209,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# NOTE(mikal): a shim to handle this file not using instance objects
|
||||
# everywhere. Remove this when that conversion happens.
|
||||
context = nova_context.get_admin_context(read_deleted='yes')
|
||||
inst_obj = instance_obj.Instance.get_by_uuid(context, instance['uuid'])
|
||||
inst_obj = objects.Instance.get_by_uuid(context, instance['uuid'])
|
||||
|
||||
# NOTE(mikal): this code should be pushed up a layer when this shim is
|
||||
# removed.
|
||||
|
|
|
@ -26,7 +26,6 @@ from nova.compute import vm_states
|
|||
from nova import context
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import jsonutils
|
||||
|
@ -78,7 +77,7 @@ class Host(object):
|
|||
' ping migration to a new host'),
|
||||
{'name': name, 'host': host})
|
||||
continue
|
||||
instance = instance_obj.Instance.get_by_uuid(ctxt, uuid)
|
||||
instance = objects.Instance.get_by_uuid(ctxt, uuid)
|
||||
vm_counter = vm_counter + 1
|
||||
|
||||
aggregate = objects.AggregateList.get_by_host(
|
||||
|
@ -309,7 +308,7 @@ def call_xenhost(session, method, arg_dict):
|
|||
|
||||
def _uuid_find(context, host, name_label):
|
||||
"""Return instance uuid by name_label."""
|
||||
for i in instance_obj.InstanceList.get_by_host(context, host):
|
||||
for i in objects.InstanceList.get_by_host(context, host):
|
||||
if i.name == name_label:
|
||||
return i.uuid
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue