Skip to content

Commit

Permalink
Merge "libvirt: Remove unreachable native QEMU iSCSI initiator config…
Browse files Browse the repository at this point in the history
… code"
  • Loading branch information
Zuul authored and openstack-gerrit committed Jul 10, 2019
2 parents 8260979 + b8c55d1 commit 2722cab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 77 deletions.
23 changes: 0 additions & 23 deletions nova/tests/unit/virt/libvirt/volume/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import nova.conf
from nova.tests.unit.virt.libvirt.volume import test_volume
from nova.virt.libvirt import host
from nova.virt.libvirt.volume import net

CONF = nova.conf.CONF
Expand Down Expand Up @@ -220,28 +219,6 @@ def test_libvirt_rbd_driver_auth_disabled_flags_override(self):
libvirt_driver.disconnect_volume(connection_info,
mock.sentinel.instance)

@mock.patch.object(host.Host, 'find_secret')
@mock.patch.object(host.Host, 'create_secret')
@mock.patch.object(host.Host, 'delete_secret')
def test_libvirt_iscsi_net_driver(self, mock_delete, mock_create,
mock_find):
mock_find.return_value = test_volume.FakeSecret()
mock_create.return_value = test_volume.FakeSecret()
libvirt_driver = net.LibvirtNetVolumeDriver(self.fake_host)
connection_info = self.iscsi_connection(self.vol, self.location,
self.iqn, auth=True)
secret_type = 'iscsi'
flags_user = connection_info['data']['auth_username']
conf = libvirt_driver.get_config(connection_info, self.disk_info)
tree = conf.format_dom()
self._assertISCSINetworkAndProtocolEquals(tree)
self.assertEqual(flags_user, tree.find('./auth').get('username'))
self.assertEqual(secret_type, tree.find('./auth/secret').get('type'))
self.assertEqual(test_volume.SECRET_UUID,
tree.find('./auth/secret').get('uuid'))
libvirt_driver.disconnect_volume(connection_info,
mock.sentinel.instance)

def test_extend_volume(self):
device_path = '/dev/fake-dev'
connection_info = {'data': {'device_path': device_path}}
Expand Down
54 changes: 0 additions & 54 deletions nova/virt/libvirt/volume/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from oslo_log import log as logging

import nova.conf
from nova import exception
from nova.i18n import _
from nova import utils
from nova.virt.libvirt.volume import volume as libvirt_volume


Expand All @@ -29,30 +26,6 @@ def __init__(self, host):
super(LibvirtNetVolumeDriver,
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.host.find_secret(conf.source_protocol,
conf.source_name)
if secret is None:
secret = self.host.create_secret(conf.source_protocol,
conf.source_name,
password)
return secret.UUIDString()

def _delete_secret_by_name(self, connection_info):
source_protocol = connection_info['driver_volume_type']
netdisk_properties = connection_info['data']
if source_protocol == 'rbd':
return
elif source_protocol == 'iscsi':
usage_type = 'iscsi'
usage_name = ("%(target_iqn)s/%(target_lun)s" %
netdisk_properties)
self.host.delete_secret(usage_type, usage_name)

def _set_auth_config_rbd(self, conf, netdisk_properties):
# The rbd volume driver in cinder sets auth_enabled if the rbd_user is
# set in cinder. The rbd auth values from the cinder connection take
Expand Down Expand Up @@ -94,13 +67,6 @@ def _set_auth_config_rbd(self, conf, netdisk_properties):
# secret_type is always hard-coded to 'ceph' in cinder
conf.auth_secret_type = netdisk_properties['secret_type']

def _set_auth_config_iscsi(self, conf, netdisk_properties):
if netdisk_properties.get('auth_method') == 'CHAP':
conf.auth_secret_type = 'iscsi'
password = netdisk_properties.get('auth_password')
conf.auth_secret_uuid = self._get_secret_uuid(conf, password)
conf.auth_username = netdisk_properties['auth_username']

def get_config(self, connection_info, disk_info):
"""Returns xml for libvirt."""
conf = super(LibvirtNetVolumeDriver,
Expand All @@ -114,28 +80,8 @@ def get_config(self, connection_info, disk_info):
conf.source_ports = netdisk_properties.get('ports', [])
if conf.source_protocol == 'rbd':
self._set_auth_config_rbd(conf, netdisk_properties)
elif conf.source_protocol == 'iscsi':
try:
conf.source_name = ("%(target_iqn)s/%(target_lun)s" %
netdisk_properties)
target_portal = netdisk_properties['target_portal']
except KeyError:
raise exception.InternalError(_("Invalid volume source data"))

ip, port = utils.parse_server_string(target_portal)
if ip == '' or port == '':
raise exception.InternalError(_("Invalid target_lun"))
conf.source_hosts = [ip]
conf.source_ports = [port]
self._set_auth_config_iscsi(conf, netdisk_properties)
return conf

def disconnect_volume(self, connection_info, instance):
"""Detach the volume from instance_name."""
super(LibvirtNetVolumeDriver,
self).disconnect_volume(connection_info, instance)
self._delete_secret_by_name(connection_info)

def extend_volume(self, connection_info, instance, requested_size):
# There is nothing to do for network volumes. Cinder already extended
# the volume and there is no local block device which needs to be
Expand Down

0 comments on commit 2722cab

Please sign in to comment.