Skip to content

Commit

Permalink
Fix direct use of block_device module objects
Browse files Browse the repository at this point in the history
This replaces all uses of nova.objects.block_device.Block* with
nova.objects.Block*.

Partial-Blueprint: object-subclassing

Change-Id: I7b7641cc75bbc180abd36920deedcb097fc3ecbc
  • Loading branch information
comstud committed Jun 3, 2014
1 parent 338c355 commit 3c1085f
Show file tree
Hide file tree
Showing 24 changed files with 186 additions and 194 deletions.
4 changes: 2 additions & 2 deletions nova/api/ec2/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
from nova.image import s3
from nova import network
from nova.network.security_group import neutron_driver
from nova import objects
from nova.objects import base as obj_base
from nova.objects import block_device as block_device_obj
from nova.objects import ec2 as ec2_obj
from nova.objects import flavor as flavor_obj
from nova.objects import instance as instance_obj
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def _format_instance_bdm(self, context, instance_uuid, root_device_name,
"""Format InstanceBlockDeviceMappingResponseItemType."""
root_device_type = 'instance-store'
mapping = []
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance_uuid)
for bdm in bdms:
volume_id = bdm.volume_id
Expand Down
4 changes: 2 additions & 2 deletions nova/api/metadata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from nova import conductor
from nova import context
from nova import network
from nova import objects
from nova.objects import base as obj_base
from nova.objects import block_device as block_device_obj
from nova.objects import instance as instance_obj
from nova.objects import security_group as secgroup_obj
from nova.openstack.common import importutils
Expand Down Expand Up @@ -524,7 +524,7 @@ def get_metadata_by_instance_id(conductor_api, instance_id, address,


def _format_instance_mapping(ctxt, instance):
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
ctxt, instance.uuid)
return block_device.instance_block_mapping(instance, bdms)

Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/contrib/extended_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
from nova.objects import block_device as block_device_obj
from nova import objects

authorize = extensions.soft_extension_authorizer('compute', 'extended_volumes')

Expand All @@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs):
self.compute_api = compute.API()

def _extend_server(self, context, server, instance):
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])
volume_ids = [bdm.volume_id for bdm in bdms if bdm.volume_id]
key = "%s:volumes_attached" % Extended_volumes.alias
Expand Down
10 changes: 5 additions & 5 deletions nova/api/openstack/compute/contrib/volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from nova.api.openstack import xmlutil
from nova import compute
from nova import exception
from nova.objects import block_device as block_device_obj
from nova import objects
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.openstack.common import strutils
Expand Down Expand Up @@ -355,7 +355,7 @@ def show(self, req, server_id, id):
except exception.NotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])

if not bdms:
Expand Down Expand Up @@ -468,7 +468,7 @@ def update(self, req, server_id, id, body):
except exception.NotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
found = False
try:
Expand Down Expand Up @@ -513,7 +513,7 @@ def delete(self, req, server_id, id):

volume = self.volume_api.get(context, volume_id)

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])
if not bdms:
msg = _("Instance %s is not attached.") % server_id
Expand Down Expand Up @@ -557,7 +557,7 @@ def _items(self, req, server_id, entity_maker):
except exception.NotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])
limited_list = common.limited(bdms, req)
results = []
Expand Down
8 changes: 4 additions & 4 deletions nova/api/openstack/compute/plugins/v3/extended_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from nova.api import validation
from nova import compute
from nova import exception
from nova.objects import block_device as block_device_obj
from nova import objects
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova import volume
Expand All @@ -46,7 +46,7 @@ def __init__(self, *args, **kwargs):
self.volume_api = volume.API()

def _extend_server(self, context, server, instance):
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])
volume_ids = [bdm['volume_id'] for bdm in bdms if bdm['volume_id']]
key = "%s:volumes_attached" % ExtendedVolumes.alias
Expand All @@ -70,7 +70,7 @@ def swap(self, req, id, body):

instance = common.get_instance(self.compute_api, context, id,
want_objects=True)
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
found = False
try:
Expand Down Expand Up @@ -185,7 +185,7 @@ def detach(self, req, id, body):
except exception.VolumeNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
if not bdms:
msg = _("Volume %(volume_id)s is not attached to the "
Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/plugins/v3/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from nova.compute import flavors
from nova import exception
from nova.image import glance
from nova.objects import block_device as block_device_obj
from nova import objects
from nova.objects import instance as instance_obj
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
Expand Down Expand Up @@ -894,7 +894,7 @@ def _action_create_image(self, req, id, body):

instance = self._get_server(context, req, id)

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)

try:
Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from nova import compute
from nova.compute import flavors
from nova import exception
from nova.objects import block_device as block_device_obj
from nova import objects
from nova.objects import instance as instance_obj
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
Expand Down Expand Up @@ -1434,7 +1434,7 @@ def _action_create_image(self, req, id, body):

instance = self._get_server(context, req, id)

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)

try:
Expand Down
19 changes: 9 additions & 10 deletions nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from nova import notifications
from nova import objects
from nova.objects import base as obj_base
from nova.objects import block_device as block_device_obj
from nova.objects import flavor as flavor_obj
from nova.objects import instance_action
from nova.objects import instance_group as instance_group_obj
Expand Down Expand Up @@ -1402,7 +1401,7 @@ def _delete(self, context, instance, delete_type, cb, **instance_attrs):
return

host = instance['host']
bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
reservations = None

Expand Down Expand Up @@ -2025,7 +2024,7 @@ def snapshot_volume_backed(self, context, instance, image_meta, name,
properties['root_device_name'] = instance['root_device_name']
properties.update(extra_properties or {})

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])

mapping = []
Expand Down Expand Up @@ -2180,7 +2179,7 @@ def _reset_image_metadata():
# system metadata... and copy in the properties for the new image.
orig_sys_metadata = _reset_image_metadata()

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)

self._record_action_start(context, instance, instance_actions.REBUILD)
Expand Down Expand Up @@ -2573,7 +2572,7 @@ def rescue(self, context, instance, rescue_password=None,
rescue_image_ref=None):
"""Rescue the given instance."""

bdms = block_device_obj.BlockDeviceMappingList.get_by_instance_uuid(
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
for bdm in bdms:
if bdm.volume_id:
Expand Down Expand Up @@ -2754,7 +2753,7 @@ def _attach_volume(self, context, instance, volume_id, device,
device = self.compute_rpcapi.reserve_block_device_name(
context, device=device, instance=instance, volume_id=volume_id,
disk_bus=disk_bus, device_type=device_type)
volume_bdm = block_device_obj.BlockDeviceMapping.get_by_volume_id(
volume_bdm = objects.BlockDeviceMapping.get_by_volume_id(
context, volume_id)
try:
volume = self.volume_api.get(context, volume_id)
Expand Down Expand Up @@ -2988,8 +2987,8 @@ def is_volume_backed_instance(self, context, instance, bdms=None):
return True

if bdms is None:
bdms = block_device_obj.BlockDeviceMappingList.\
get_by_instance_uuid(context, instance['uuid'])
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance['uuid'])

root_bdm = bdms.root_bdm()
if not root_bdm:
Expand Down Expand Up @@ -3056,7 +3055,7 @@ def get_migrations(self, context, filters):

@wrap_check_policy
def volume_snapshot_create(self, context, volume_id, create_info):
bdm = block_device_obj.BlockDeviceMapping.get_by_volume_id(
bdm = objects.BlockDeviceMapping.get_by_volume_id(
context, volume_id, expected_attrs=['instance'])
self.compute_rpcapi.volume_snapshot_create(context, bdm.instance,
volume_id, create_info)
Expand All @@ -3071,7 +3070,7 @@ def volume_snapshot_create(self, context, volume_id, create_info):
@wrap_check_policy
def volume_snapshot_delete(self, context, volume_id, snapshot_id,
delete_info):
bdm = block_device_obj.BlockDeviceMapping.get_by_volume_id(
bdm = objects.BlockDeviceMapping.get_by_volume_id(
context, volume_id, expected_attrs=['instance'])
self.compute_rpcapi.volume_snapshot_delete(context, bdm.instance,
volume_id, snapshot_id, delete_info)
Expand Down
Loading

0 comments on commit 3c1085f

Please sign in to comment.