Use self.configuration to support the multi-backend case
Use self.configuration instead of using FLAGS directly to make
the driver work in a multi backend environment.
And remove three repeated lines:en = out.split('\r\n')
Fixes bug: 1154125
Change-Id: I6e08706104eabb71677ec8583b9abb9711553504
This commit is contained in:
@@ -23,6 +23,7 @@ from xml.etree import ElementTree as ET
|
||||
from cinder import exception
|
||||
from cinder.openstack.common import log as logging
|
||||
from cinder import test
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.drivers.huawei import huawei_iscsi
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -184,7 +185,7 @@ class HuaweiVolumeTestCase(test.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HuaweiVolumeTestCase, self).__init__(*args, **kwargs)
|
||||
self.driver = FakeHuaweiStorage()
|
||||
self.driver = FakeHuaweiStorage(configuration=conf.Configuration(None))
|
||||
self.driver.do_setup({})
|
||||
self.driver._test_flg = 'check_for_fail'
|
||||
self._test_check_for_setup_errors()
|
||||
|
||||
@@ -26,7 +26,6 @@ from oslo.config import cfg
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from cinder import exception
|
||||
from cinder import flags
|
||||
from cinder.openstack.common import excutils
|
||||
from cinder.openstack.common import log as logging
|
||||
from cinder import utils
|
||||
@@ -39,9 +38,6 @@ huawei_opt = [
|
||||
default='/etc/cinder/cinder_huawei_conf.xml',
|
||||
help='config data for cinder huawei plugin')]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.register_opts(huawei_opt)
|
||||
|
||||
HOST_GROUP_NAME = 'HostGroup_OpenStack'
|
||||
HOST_NAME_PREFIX = 'Host_'
|
||||
HOST_PORT_PREFIX = 'HostPort_'
|
||||
@@ -107,6 +103,7 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HuaweiISCSIDriver, self).__init__(*args, **kwargs)
|
||||
self.configuration.append_config_values(huawei_opt)
|
||||
self.device_type = {}
|
||||
self.login_info = {}
|
||||
self.hostgroup_id = None
|
||||
@@ -542,7 +539,7 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
|
||||
|
||||
def _read_xml(self):
|
||||
"""Open xml file."""
|
||||
filename = FLAGS.cinder_huawei_conf_file
|
||||
filename = self.configuration.cinder_huawei_conf_file
|
||||
try:
|
||||
tree = ET.parse(filename)
|
||||
root = tree.getroot()
|
||||
@@ -875,7 +872,6 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
|
||||
if len(en) < 6:
|
||||
return None
|
||||
|
||||
en = out.split('\r\n')
|
||||
for i in range(6, len(en) - 2):
|
||||
r = en[i].split()
|
||||
if r[1] == hostname:
|
||||
@@ -894,7 +890,6 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
|
||||
hostportinfo = []
|
||||
list_key = ['id', 'name', 'info', 'type', 'hostid',
|
||||
'linkstatus', 'multioathtype']
|
||||
en = out.split('\r\n')
|
||||
for i in range(6, len(en) - 2):
|
||||
list_val = en[i].split()
|
||||
hostport_dic = dict(map(None, list_key, list_val))
|
||||
@@ -1087,7 +1082,6 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
|
||||
mapinfo = []
|
||||
list_tmp = []
|
||||
list_key = ['mapid', 'devlunid', 'hostlunid']
|
||||
en = out.split('\r\n')
|
||||
for i in range(6, len(en) - 2):
|
||||
list_tmp = en[i].split()
|
||||
list_val = [list_tmp[0], list_tmp[2], list_tmp[4]]
|
||||
|
||||
Reference in New Issue
Block a user