Remove usage of CONF from DISCO driver
DISCO driver takes options directly from CONF instead of using self.configuration. This prevents it from working in multi-backend configuration. In addition to that, the commit renames some options to match pattern of <driver_name>_<option_name> that is commonly used in [<backend_name>] sections. Change-Id: I592515c0a076b1fee22c3a3c96e3862909cc9836 Closes-Bug: 1684133
This commit is contained in:
parent
ad54657026
commit
7999271653
|
@ -20,7 +20,6 @@ import mock
|
|||
from suds import client
|
||||
|
||||
from os_brick.initiator import connector
|
||||
from oslo_config import cfg
|
||||
|
||||
from cinder import context
|
||||
from cinder import test
|
||||
|
@ -52,18 +51,14 @@ class TestDISCODriver(test.TestCase):
|
|||
self.cfg.disco_client = '127.0.0.1'
|
||||
self.cfg.disco_client_port = '9898'
|
||||
self.cfg.disco_wsdl_path = 'somewhere'
|
||||
self.cfg.volume_name_prefix = 'openstack-'
|
||||
self.cfg.num_volume_device_scan_tries = 1
|
||||
self.cfg.snapshot_check_timeout = 3600
|
||||
self.cfg.restore_check_timeout = 3600
|
||||
self.cfg.clone_check_timeout = 3600
|
||||
self.cfg.snapshot_reserve_days = -1
|
||||
self.cfg.retry_interval = 2
|
||||
self.cfg.disco_volume_name_prefix = 'openstack-'
|
||||
self.cfg.disco_snapshot_check_timeout = 3600
|
||||
self.cfg.disco_restore_check_timeout = 3600
|
||||
self.cfg.disco_clone_check_timeout = 3600
|
||||
self.cfg.disco_retry_interval = 2
|
||||
self.cfg.num_volume_device_scan_tries = 3
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.choice_client = 'SOAP'
|
||||
CONF.rest_ip = '127.0.0.1'
|
||||
self.cfg.disco_choice_client = 'SOAP'
|
||||
self.cfg.disco_rest_ip = '127.0.0.1'
|
||||
|
||||
self.FAKE_RESPONSE = {
|
||||
'standard': {
|
||||
|
@ -87,7 +82,7 @@ class TestDISCODriver(test.TestCase):
|
|||
configuration=self.cfg)
|
||||
self.driver.do_setup(None)
|
||||
|
||||
self.attach_detach = attach_detach.AttachDetachDiscoVolume()
|
||||
self.attach_detach = attach_detach.AttachDetachDiscoVolume(self.cfg)
|
||||
|
||||
self.ctx = context.RequestContext('fake', 'fake', auth_token=True)
|
||||
self.volume = fake_volume.fake_volume_obj(self.ctx)
|
||||
|
|
|
@ -144,7 +144,7 @@ class CreateCloneVolumeTestCase(disco.TestDISCODriver):
|
|||
"""Clone request timeout."""
|
||||
timeout = 3
|
||||
mock_time.side_effect = utils.generate_timeout_series(timeout)
|
||||
self.driver.configuration.clone_check_timeout = timeout
|
||||
self.driver.configuration.disco_clone_check_timeout = timeout
|
||||
self.response = self.FAKE_RESPONSE['standard']['success']
|
||||
self.response_detail = (
|
||||
self.FAKE_RESPONSE['clone_detail']['pending'])
|
||||
|
|
|
@ -145,7 +145,7 @@ class CreateSnapshotTestCase(disco.TestDISCODriver):
|
|||
"""Snapshot request timeout."""
|
||||
timeout = 3
|
||||
mock_time.side_effect = utils.generate_timeout_series(timeout)
|
||||
self.driver.configuration.snapshot_check_timeout = timeout
|
||||
self.driver.configuration.disco_snapshot_check_timeout = timeout
|
||||
self.response = self.FAKE_RESPONSE['standard']['success']
|
||||
self.response_detail = (
|
||||
self.FAKE_RESPONSE['snapshot_detail']['pending'])
|
||||
|
|
|
@ -152,7 +152,7 @@ class CreateVolumeFromSnapshotTestCase(disco.TestDISCODriver):
|
|||
"""Create volume from snapshot task timeout."""
|
||||
timeout = 3
|
||||
mock_time.side_effect = utils.generate_timeout_series(timeout)
|
||||
self.driver.configuration.restore_check_timeout = timeout
|
||||
self.driver.configuration.disco_restore_check_timeout = timeout
|
||||
self.response = self.FAKE_RESPONSE['standard']['success']
|
||||
self.response_detail = (
|
||||
self.FAKE_RESPONSE['restore_detail']['pending'])
|
||||
|
|
|
@ -41,45 +41,55 @@ LOG = logging.getLogger(__name__)
|
|||
disco_opts = [
|
||||
cfg.IPOpt('disco_client',
|
||||
default='127.0.0.1',
|
||||
help='The IP of DMS client socket server'),
|
||||
help='The IP of DMS client socket server',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.PortOpt('disco_client_port',
|
||||
default='9898',
|
||||
help='The port to connect DMS client socket server'),
|
||||
help='The port to connect DMS client socket server',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.StrOpt('disco_wsdl_path',
|
||||
default='/etc/cinder/DISCOService.wsdl',
|
||||
deprecated_for_removal=True,
|
||||
help='Path to the wsdl file '
|
||||
'to communicate with DISCO request manager'),
|
||||
cfg.IPOpt('rest_ip',
|
||||
help='The IP address of the REST server'),
|
||||
cfg.StrOpt('choice_client',
|
||||
cfg.IPOpt('disco_rest_ip',
|
||||
help='The IP address of the REST server',
|
||||
deprecated_name='rest_ip', deprecated_group='DEFAULT'),
|
||||
cfg.StrOpt('disco_choice_client',
|
||||
help='Use soap client or rest client for communicating '
|
||||
'with DISCO. Possible values are "soap" or '
|
||||
'"rest".'),
|
||||
'"rest".', choices=['soap', 'rest'],
|
||||
deprecated_name='choice_client', deprecated_group='DEFAULT'),
|
||||
cfg.PortOpt('disco_src_api_port',
|
||||
default='8080',
|
||||
help='The port of DISCO source API'),
|
||||
cfg.StrOpt('volume_name_prefix',
|
||||
help='The port of DISCO source API',
|
||||
deprecated_group='DEFAULT'),
|
||||
cfg.StrOpt('disco_volume_name_prefix',
|
||||
default='openstack-',
|
||||
help='Prefix before volume name to differentiate '
|
||||
'DISCO volume created through openstack '
|
||||
'and the other ones'),
|
||||
cfg.IntOpt('snapshot_check_timeout',
|
||||
'and the other ones',
|
||||
deprecated_name='volume_name_prefix'),
|
||||
cfg.IntOpt('disco_snapshot_check_timeout',
|
||||
default=3600,
|
||||
help='How long we check whether a snapshot '
|
||||
'is finished before we give up'),
|
||||
cfg.IntOpt('restore_check_timeout',
|
||||
'is finished before we give up',
|
||||
deprecated_name='snapshot_check_timeout'),
|
||||
cfg.IntOpt('disco_restore_check_timeout',
|
||||
default=3600,
|
||||
help='How long we check whether a restore '
|
||||
'is finished before we give up'),
|
||||
cfg.IntOpt('clone_check_timeout',
|
||||
'is finished before we give up',
|
||||
deprecated_name='restore_check_timeout'),
|
||||
cfg.IntOpt('disco_clone_check_timeout',
|
||||
default=3600,
|
||||
help='How long we check whether a clone '
|
||||
'is finished before we give up'),
|
||||
cfg.IntOpt('retry_interval',
|
||||
'is finished before we give up',
|
||||
deprecated_name='clone_check_timeout'),
|
||||
cfg.IntOpt('disco_retry_interval',
|
||||
default=1,
|
||||
help='How long we wait before retrying to '
|
||||
'get an item detail')
|
||||
'get an item detail',
|
||||
deprecated_name='retry_interval')
|
||||
]
|
||||
|
||||
DISCO_CODE_MAPPING = {
|
||||
|
@ -113,14 +123,15 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
self.configuration.append_config_values(disco_opts)
|
||||
self.ctxt = context.get_admin_context()
|
||||
self.attach_detach_volume = (
|
||||
disco_attach_detach.AttachDetachDiscoVolume())
|
||||
disco_attach_detach.AttachDetachDiscoVolume(self.configuration))
|
||||
|
||||
def do_setup(self, context):
|
||||
"""Create client for DISCO request manager."""
|
||||
LOG.debug("Enter in DiscoDriver do_setup.")
|
||||
if CONF.choice_client.lower() == "rest":
|
||||
if self.configuration.disco_choice_client.lower() == "rest":
|
||||
self.client = disco_api.DiscoApi(
|
||||
CONF.rest_ip, CONF.disco_src_api_port)
|
||||
self.configuration.disco_rest_ip,
|
||||
self.configuration.disco_src_api_port)
|
||||
else:
|
||||
path = ''.join(['file:', self.configuration.disco_wsdl_path])
|
||||
init_client = client.Client(path, cache=None)
|
||||
|
@ -128,7 +139,8 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
|
||||
def check_for_setup_error(self):
|
||||
"""Make sure we have the pre-requisites."""
|
||||
if not CONF.rest_ip and CONF.choice_client.lower() == "rest":
|
||||
if (not self.configuration.disco_rest_ip and
|
||||
self.configuration.disco_choice_client.lower() == "rest"):
|
||||
msg = _("Could not find the IP address of the REST server.")
|
||||
raise exception.VolumeBackendAPIException(data=msg)
|
||||
else:
|
||||
|
@ -139,7 +151,7 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
|
||||
def create_volume(self, volume):
|
||||
"""Create a disco volume."""
|
||||
name = self.configuration.volume_name_prefix, volume["id"]
|
||||
name = self.configuration.disco_volume_name_prefix, volume["id"]
|
||||
vol_name = ''.join(name)
|
||||
vol_size = volume['size'] * units.Ki
|
||||
LOG.debug("Create volume : [name] %(vname)s - [size] %(vsize)s.",
|
||||
|
@ -210,8 +222,9 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
snapshot_request = DISCOCheck(self.client,
|
||||
params,
|
||||
start_time,
|
||||
"snapshot_detail")
|
||||
timeout = self.configuration.snapshot_check_timeout
|
||||
"snapshot_detail",
|
||||
self.configuration)
|
||||
timeout = self.configuration.disco_snapshot_check_timeout
|
||||
snapshot_request._monitor_request(timeout)
|
||||
|
||||
snapshot['provider_location'] = result
|
||||
|
@ -241,7 +254,7 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
|
||||
def create_volume_from_snapshot(self, volume, snapshot):
|
||||
"""Create a volume from a snapshot."""
|
||||
name = self.configuration.volume_name_prefix, volume['id']
|
||||
name = self.configuration.disco_volume_name_prefix, volume['id']
|
||||
snap_id = snapshot['provider_location']
|
||||
vol_name = ''.join(name)
|
||||
# Trigger an asynchronous restore operation
|
||||
|
@ -271,8 +284,9 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
restore_request = DISCOCheck(self.client,
|
||||
params,
|
||||
start_time,
|
||||
"restore_detail")
|
||||
timeout = self.configuration.restore_check_timeout
|
||||
"restore_detail",
|
||||
self.configuration)
|
||||
timeout = self.configuration.disco_restore_check_timeout
|
||||
restore_request._monitor_request(timeout)
|
||||
reply = self.client.volumeDetailByName(vol_name)
|
||||
status = reply['status']
|
||||
|
@ -292,7 +306,7 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
def create_cloned_volume(self, volume, src_vref):
|
||||
"""Create a clone of the specified volume."""
|
||||
LOG.debug("Creating clone of volume: %s.", src_vref['id'])
|
||||
name = self.configuration.volume_name_prefix, volume['id']
|
||||
name = self.configuration.disco_volume_name_prefix, volume['id']
|
||||
vol_name = ''.join(name)
|
||||
vol_size = volume['size'] * units.Ki
|
||||
src_vol_id = src_vref['provider_location']
|
||||
|
@ -322,8 +336,10 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
clone_request = DISCOCheck(self.client,
|
||||
params,
|
||||
start_time,
|
||||
"clone_detail")
|
||||
clone_request._monitor_request(self.configuration.clone_check_timeout)
|
||||
"clone_detail",
|
||||
self.configuration)
|
||||
clone_request._monitor_request(
|
||||
self.configuration.disco_clone_check_timeout)
|
||||
reply = self.client.volumeDetailByName(vol_name)
|
||||
status = reply['status']
|
||||
new_vol_id = reply['volumeInfoResult']['volumeId']
|
||||
|
@ -346,7 +362,8 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
|
||||
try:
|
||||
attach_detach_volume = (
|
||||
disco_attach_detach.AttachDetachDiscoVolume())
|
||||
disco_attach_detach.AttachDetachDiscoVolume(
|
||||
self.configuration))
|
||||
device_info = attach_detach_volume._attach_volume(volume)
|
||||
image_utils.fetch_to_raw(context,
|
||||
image_service,
|
||||
|
@ -362,7 +379,8 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
LOG.debug("Enter in copy image to volume for disco.")
|
||||
try:
|
||||
attach_detach_volume = (
|
||||
disco_attach_detach.AttachDetachDiscoVolume())
|
||||
disco_attach_detach.AttachDetachDiscoVolume(
|
||||
self.configuration))
|
||||
device_info = attach_detach_volume._attach_volume(volume)
|
||||
image_utils.upload_volume(context,
|
||||
image_service,
|
||||
|
@ -534,12 +552,13 @@ class DiscoDriver(driver.VolumeDriver):
|
|||
class DISCOCheck(object):
|
||||
"""Used to monitor DISCO operations."""
|
||||
|
||||
def __init__(self, client, param, start_time, function):
|
||||
def __init__(self, client, param, start_time, function, configuration):
|
||||
"""Init some variables for checking some requests done in DISCO."""
|
||||
self.start_time = start_time
|
||||
self.function = function
|
||||
self.client = client
|
||||
self.param = param
|
||||
self.configuration = configuration
|
||||
|
||||
def is_timeout(self, start_time, timeout):
|
||||
"""Check whether we reach the timeout."""
|
||||
|
@ -609,4 +628,4 @@ class DISCOCheck(object):
|
|||
timeout,
|
||||
self.function,
|
||||
self.param)
|
||||
timer.start(interval=CONF.retry_interval).wait()
|
||||
timer.start(interval=self.configuration.disco_retry_interval).wait()
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
"""Class for DISCO to attach and detach volume."""
|
||||
|
||||
from os_brick.initiator import connector
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from cinder import utils
|
||||
|
@ -24,23 +23,22 @@ from cinder import utils
|
|||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class AttachDetachDiscoVolume(object):
|
||||
"""Class for attach and detach a DISCO volume."""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, configuration):
|
||||
"""Init volume attachment class."""
|
||||
self.configuration = configuration
|
||||
self.connector = connector.InitiatorConnector.factory(
|
||||
self._get_connector_identifier(), utils.get_root_helper(),
|
||||
device_scan_attempts=(
|
||||
CONF.num_volume_device_scan_tries)
|
||||
self.configuration.num_volume_device_scan_tries)
|
||||
)
|
||||
self.connection_conf = {}
|
||||
self.connection_conf['server_ip'] = CONF.disco_client
|
||||
self.connection_conf['server_ip'] = self.configuration.disco_client
|
||||
self.connection_conf['server_port'] = (
|
||||
CONF.disco_client_port)
|
||||
self.configuration.disco_client_port)
|
||||
|
||||
self.connection_properties = {}
|
||||
self.connection_properties['name'] = None
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
upgrade:
|
||||
- |
|
||||
Some of DISCO driver options were incorrectly read from ``[DEFAULT]``
|
||||
section in the cinder.conf. Now those are correctly read from
|
||||
``[<backend_id>]`` section. This includes following options:
|
||||
|
||||
* ``disco_client``
|
||||
* ``disco_client_port``
|
||||
* ``rest_ip``
|
||||
* ``choice_client``
|
||||
* ``disco_src_api_port``
|
||||
* ``retry_interval``
|
||||
|
||||
Also some options are renamed (note that 3 of them were both moved and
|
||||
renamed):
|
||||
|
||||
* ``rest_ip`` to ``disco_rest_ip``
|
||||
* ``choice_client`` to ``disco_choice_client``
|
||||
* ``volume_name_prefix`` to ``disco_volume_name_prefix``
|
||||
* ``snapshot_check_timeout`` to ``disco_snapshot_check_timeout``
|
||||
* ``restore_check_timeout`` to ``disco_restore_check_timeout``
|
||||
* ``clone_check_timeout`` to ``disco_clone_check_timeout``
|
||||
* ``retry_interval`` to ``disco_retry_interval``
|
||||
|
||||
Old names and locations are still supported but support will be removed in
|
||||
the future.
|
Loading…
Reference in New Issue