diff options
author | Matthew Booth <mbooth@redhat.com> | 2016-11-01 16:25:01 +0000 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2016-11-01 16:41:08 +0000 |
commit | 36322fdf48dc50a4518c0c9fd6aa787d3aa01fed (patch) | |
tree | b05d379bf9003719692d88f0c7c115108585671c /nova/virt/libvirt/volume | |
parent | 26dcc8e45bb64e01325e738e4c18caef9163d9b5 (diff) | |
download | nova-36322fdf48dc50a4518c0c9fd6aa787d3aa01fed.tar.gz |
libvirt: Pass Host instead of Driver to volume drivers
We were initialising libvirt volume drivers by passing the
LibvirtDriver object. However, this is only ever used to fetch the
Host. We update the interface to pass the Host instead. This is
cleaner, but also better represents the intent of the interface. They
should not be able to access arbitrary attributes of the LibvirtDriver
object.
Change-Id: I87ceeee1ec46dc22754321574b16e6c47b27a848
Diffstat (limited to 'nova/virt/libvirt/volume')
-rw-r--r-- | nova/virt/libvirt/volume/aoe.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/disco.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/fibrechannel.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/fs.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/hgst.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/iscsi.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/net.py | 10 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/scaleio.py | 4 | ||||
-rw-r--r-- | nova/virt/libvirt/volume/volume.py | 16 |
9 files changed, 27 insertions, 27 deletions
diff --git a/nova/virt/libvirt/volume/aoe.py b/nova/virt/libvirt/volume/aoe.py index e910f9a02e..b88a63aa9d 100644 --- a/nova/virt/libvirt/volume/aoe.py +++ b/nova/virt/libvirt/volume/aoe.py @@ -24,9 +24,9 @@ CONF = nova.conf.CONF class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): """Driver to attach AoE volumes to libvirt.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtAOEVolumeDriver, - self).__init__(connection, is_block_dev=True) + self).__init__(host, is_block_dev=True) # Call the factory here so we can support # more than x86 architectures. diff --git a/nova/virt/libvirt/volume/disco.py b/nova/virt/libvirt/volume/disco.py index e165e4eb1f..3af2750e82 100644 --- a/nova/virt/libvirt/volume/disco.py +++ b/nova/virt/libvirt/volume/disco.py @@ -31,9 +31,9 @@ class LibvirtDISCOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): Uses the DISCO connector from the os-brick projects. """ - def __init__(self, connection): + def __init__(self, host): """Init DISCO connector for LibVirt.""" - super(LibvirtDISCOVolumeDriver, self).__init__(connection, + super(LibvirtDISCOVolumeDriver, self).__init__(host, is_block_dev=False) self.connector = connector.InitiatorConnector.factory( 'DISCO', utils.get_root_helper(), diff --git a/nova/virt/libvirt/volume/fibrechannel.py b/nova/virt/libvirt/volume/fibrechannel.py index 376ffb2adf..a84e7d4757 100644 --- a/nova/virt/libvirt/volume/fibrechannel.py +++ b/nova/virt/libvirt/volume/fibrechannel.py @@ -25,9 +25,9 @@ LOG = logging.getLogger(__name__) class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): """Driver to attach Fibre Channel Network volumes to libvirt.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtFibreChannelVolumeDriver, - self).__init__(connection, is_block_dev=False) + self).__init__(host, is_block_dev=False) # Call the factory here so we can support # more than x86 architectures. diff --git a/nova/virt/libvirt/volume/fs.py b/nova/virt/libvirt/volume/fs.py index 55cfc8c0f0..df84f068a1 100644 --- a/nova/virt/libvirt/volume/fs.py +++ b/nova/virt/libvirt/volume/fs.py @@ -26,9 +26,9 @@ class LibvirtBaseFileSystemVolumeDriver( libvirt_volume.LibvirtBaseVolumeDriver): """The base class for file system type volume drivers""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtBaseFileSystemVolumeDriver, - self).__init__(connection, is_block_dev=False) + self).__init__(host, is_block_dev=False) @abc.abstractmethod def _get_mount_point_base(self): diff --git a/nova/virt/libvirt/volume/hgst.py b/nova/virt/libvirt/volume/hgst.py index b446fae681..e5df5bea01 100644 --- a/nova/virt/libvirt/volume/hgst.py +++ b/nova/virt/libvirt/volume/hgst.py @@ -25,9 +25,9 @@ CONF = nova.conf.CONF class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): """Driver to attach HGST volumes to libvirt.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtHGSTVolumeDriver, - self).__init__(connection, is_block_dev=True) + self).__init__(host, is_block_dev=True) self.connector = connector.InitiatorConnector.factory( 'HGST', utils.get_root_helper(), device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries) diff --git a/nova/virt/libvirt/volume/iscsi.py b/nova/virt/libvirt/volume/iscsi.py index 18d66ee394..1bd9a3c825 100644 --- a/nova/virt/libvirt/volume/iscsi.py +++ b/nova/virt/libvirt/volume/iscsi.py @@ -28,8 +28,8 @@ CONF = nova.conf.CONF class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): """Driver to attach Network volumes to libvirt.""" - def __init__(self, connection): - super(LibvirtISCSIVolumeDriver, self).__init__(connection, + def __init__(self, host): + super(LibvirtISCSIVolumeDriver, self).__init__(host, is_block_dev=True) # Call the factory here so we can support diff --git a/nova/virt/libvirt/volume/net.py b/nova/virt/libvirt/volume/net.py index a8e698137d..d6ded97822 100644 --- a/nova/virt/libvirt/volume/net.py +++ b/nova/virt/libvirt/volume/net.py @@ -22,19 +22,19 @@ CONF = nova.conf.CONF class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): """Driver to attach Network volumes to libvirt.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtNetVolumeDriver, - self).__init__(connection, is_block_dev=False) + self).__init__(host, is_block_dev=False) def _get_secret_uuid(self, conf, password=None): # TODO(mriedem): Add delegation methods to connection (LibvirtDriver) # to call through for these secret CRUD operations so the volume driver # doesn't need to know the internal attributes of the connection # object. - secret = self.connection._host.find_secret(conf.source_protocol, + secret = self.host.find_secret(conf.source_protocol, conf.source_name) if secret is None: - secret = self.connection._host.create_secret(conf.source_protocol, + secret = self.host.create_secret(conf.source_protocol, conf.source_name, password) return secret.UUIDString() @@ -48,7 +48,7 @@ class LibvirtNetVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): usage_type = 'iscsi' usage_name = ("%(target_iqn)s/%(target_lun)s" % netdisk_properties) - self.connection._host.delete_secret(usage_type, usage_name) + self.host.delete_secret(usage_type, usage_name) def get_config(self, connection_info, disk_info): """Returns xml for libvirt.""" diff --git a/nova/virt/libvirt/volume/scaleio.py b/nova/virt/libvirt/volume/scaleio.py index 5f2ea218a7..b97152eb05 100644 --- a/nova/virt/libvirt/volume/scaleio.py +++ b/nova/virt/libvirt/volume/scaleio.py @@ -33,8 +33,8 @@ class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver): Implements Libvirt part of volume driver for ScaleIO cinder driver. Uses the ScaleIO connector from the os-brick projects """ - def __init__(self, connection): - super(LibvirtScaleIOVolumeDriver, self).__init__(connection, + def __init__(self, host): + super(LibvirtScaleIOVolumeDriver, self).__init__(host, is_block_dev=False) self.connector = connector.InitiatorConnector.factory( 'SCALEIO', utils.get_root_helper(), diff --git a/nova/virt/libvirt/volume/volume.py b/nova/virt/libvirt/volume/volume.py index 2efc0f5e06..fff56c7931 100644 --- a/nova/virt/libvirt/volume/volume.py +++ b/nova/virt/libvirt/volume/volume.py @@ -37,15 +37,15 @@ SHOULD_LOG_DISCARD_WARNING = True class LibvirtBaseVolumeDriver(object): """Base class for volume drivers.""" - def __init__(self, connection, is_block_dev): - self.connection = connection + def __init__(self, host, is_block_dev): + self.host = host self.is_block_dev = is_block_dev def get_config(self, connection_info, disk_info): """Returns xml for libvirt.""" conf = vconfig.LibvirtConfigGuestDisk() conf.driver_name = libvirt_utils.pick_disk_driver_name( - self.connection._host.get_version(), + self.host.get_version(), self.is_block_dev ) @@ -95,7 +95,7 @@ class LibvirtBaseVolumeDriver(object): # Configure usage of discard if data.get('discard', False) is True: min_qemu = nova.virt.libvirt.driver.MIN_QEMU_DISCARD_VERSION - if self.connection._host.has_min_version( + if self.host.has_min_version( hv_ver=min_qemu, hv_type=host.HV_DRIVER_QEMU): conf.driver_discard = 'unmap' @@ -125,9 +125,9 @@ class LibvirtBaseVolumeDriver(object): class LibvirtVolumeDriver(LibvirtBaseVolumeDriver): """Class for volumes backed by local file.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtVolumeDriver, - self).__init__(connection, is_block_dev=True) + self).__init__(host, is_block_dev=True) def get_config(self, connection_info, disk_info): """Returns xml for libvirt.""" @@ -140,9 +140,9 @@ class LibvirtVolumeDriver(LibvirtBaseVolumeDriver): class LibvirtFakeVolumeDriver(LibvirtBaseVolumeDriver): """Driver to attach fake volumes to libvirt.""" - def __init__(self, connection): + def __init__(self, host): super(LibvirtFakeVolumeDriver, - self).__init__(connection, is_block_dev=True) + self).__init__(host, is_block_dev=True) def get_config(self, connection_info, disk_info): """Returns xml for libvirt.""" |