From 80c8d32f09634a18e28c3ac63740fd24863fb3eb Mon Sep 17 00:00:00 2001 From: Navneet Singh Date: Fri, 15 Feb 2013 04:41:42 -0800 Subject: [PATCH] NetApp bug fix for multibackend scenario. The multibackend scenario using filter scheduler did not work with NetApp drivers because of use of FLAGS. Changed to use configuration to support the multibackend scenario. bug 1132637 Change-Id: I8ac5bd6d4269f703c3b3b0aa062c92f4412c25af --- cinder/tests/test_netapp.py | 22 ++++++-- cinder/tests/test_netapp_nfs.py | 59 ++++++++++++-------- cinder/volume/drivers/netapp/iscsi.py | 65 ++++++++++++---------- cinder/volume/drivers/netapp/nfs.py | 80 +++++++++++++-------------- 4 files changed, 125 insertions(+), 101 deletions(-) diff --git a/cinder/tests/test_netapp.py b/cinder/tests/test_netapp.py index f13ab6a4a..c1b52d8fc 100644 --- a/cinder/tests/test_netapp.py +++ b/cinder/tests/test_netapp.py @@ -30,7 +30,9 @@ from lxml import etree from cinder.exception import VolumeBackendAPIException from cinder.openstack.common import log as logging from cinder import test +from cinder.volume import configuration as conf from cinder.volume.drivers.netapp import iscsi +from cinder.volume.drivers.netapp.iscsi import netapp_opts LOG = logging.getLogger("cinder.volume.driver") @@ -596,6 +598,12 @@ iter_count = 0 iter_table = {} +def create_configuration(): + configuration = conf.Configuration(None) + configuration.append_config_values(netapp_opts) + return configuration + + class FakeDfmServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): """HTTP handler that fakes enough stuff to allow the driver to run.""" @@ -979,7 +987,7 @@ class NetAppDriverTestCase(test.TestCase): super(NetAppDriverTestCase, self).setUp() self.tempdir = tempfile.mkdtemp() self.flags(lock_path=self.tempdir) - driver = iscsi.NetAppISCSIDriver() + driver = iscsi.NetAppISCSIDriver(configuration=create_configuration()) self.stubs.Set(httplib, 'HTTPConnection', FakeHTTPConnection) driver._create_client(wsdl_url='http://localhost:8088/dfm.wsdl', login='root', password='password', @@ -1403,7 +1411,8 @@ class NetAppCmodeISCSIDriverTestCase(test.TestCase): self._custom_setup() def _custom_setup(self): - driver = iscsi.NetAppCmodeISCSIDriver() + driver = iscsi.NetAppCmodeISCSIDriver( + configuration=create_configuration()) self.stubs.Set(httplib, 'HTTPConnection', FakeCmodeHTTPConnection) driver._create_client(wsdl_url='http://localhost:8080/ntap_cloud.wsdl', login='root', password='password', @@ -1849,7 +1858,8 @@ class NetAppDirectCmodeISCSIDriverTestCase(NetAppCmodeISCSIDriverTestCase): super(NetAppDirectCmodeISCSIDriverTestCase, self).setUp() def _custom_setup(self): - driver = iscsi.NetAppDirectCmodeISCSIDriver() + driver = iscsi.NetAppDirectCmodeISCSIDriver( + configuration=create_configuration()) self.stubs.Set(httplib, 'HTTPConnection', FakeDirectCmodeHTTPConnection) driver._create_client(transport_type='http', @@ -2280,7 +2290,8 @@ class NetAppDirect7modeISCSIDriverTestCase_NV( super(NetAppDirect7modeISCSIDriverTestCase_NV, self).setUp() def _custom_setup(self): - driver = iscsi.NetAppDirect7modeISCSIDriver() + driver = iscsi.NetAppDirect7modeISCSIDriver( + configuration=create_configuration()) self.stubs.Set(httplib, 'HTTPConnection', FakeDirect7modeHTTPConnection) driver._create_client(transport_type='http', @@ -2320,7 +2331,8 @@ class NetAppDirect7modeISCSIDriverTestCase_WV( super(NetAppDirect7modeISCSIDriverTestCase_WV, self).setUp() def _custom_setup(self): - driver = iscsi.NetAppDirect7modeISCSIDriver() + driver = iscsi.NetAppDirect7modeISCSIDriver( + configuration=create_configuration()) self.stubs.Set(httplib, 'HTTPConnection', FakeDirect7modeHTTPConnection) driver._create_client(transport_type='http', diff --git a/cinder/tests/test_netapp_nfs.py b/cinder/tests/test_netapp_nfs.py index 5e5f4bf87..b7476d5d6 100644 --- a/cinder/tests/test_netapp_nfs.py +++ b/cinder/tests/test_netapp_nfs.py @@ -22,7 +22,6 @@ from cinder import test from cinder.volume import configuration as conf from cinder.volume.drivers.netapp import api -from cinder.volume.drivers.netapp import iscsi from cinder.volume.drivers.netapp import nfs as netapp_nfs from cinder.volume.drivers import nfs from lxml import etree @@ -81,7 +80,7 @@ class NetappNfsDriverTestCase(test.TestCase): def setUp(self): self._mox = mox.Mox() self._driver = netapp_nfs.NetAppNFSDriver( - configuration=create_configuration()) + configuration=create_configuration()) def tearDown(self): self._mox.UnsetStubs() @@ -95,13 +94,17 @@ class NetappNfsDriverTestCase(test.TestCase): 'netapp_server_hostname', 'netapp_server_port'] + # set required flags + for flag in required_flags: + setattr(drv.configuration, flag, None) + # check exception raises when flags are not set self.assertRaises(exception.CinderException, drv.check_for_setup_error) # set required flags for flag in required_flags: - setattr(iscsi.FLAGS, flag, 'val') + setattr(drv.configuration, flag, 'val') mox.StubOutWithMock(nfs.NfsDriver, 'check_for_setup_error') nfs.NfsDriver.check_for_setup_error() @@ -113,17 +116,17 @@ class NetappNfsDriverTestCase(test.TestCase): # restore initial FLAGS for flag in required_flags: - delattr(iscsi.FLAGS, flag) + delattr(drv.configuration, flag) def test_do_setup(self): mox = self._mox drv = self._driver mox.StubOutWithMock(drv, 'check_for_setup_error') - mox.StubOutWithMock(netapp_nfs.NetAppNFSDriver, '_get_client') + mox.StubOutWithMock(drv, '_get_client') drv.check_for_setup_error() - netapp_nfs.NetAppNFSDriver._get_client() + drv._get_client() mox.ReplayAll() @@ -240,7 +243,8 @@ class NetappNfsDriverTestCase(test.TestCase): def test_successfull_clone_volume(self): drv = self._driver mox = self._prepare_clone_mock('passed') - + # set required flags + setattr(drv.configuration, 'synchronous_snapshot_create', False) mox.ReplayAll() volume_name = 'volume_name' @@ -287,7 +291,7 @@ class NetappCmodeNfsDriverTestCase(test.TestCase): def _custom_setup(self): self._driver = netapp_nfs.NetAppCmodeNfsDriver( - configuration=create_configuration()) + configuration=create_configuration()) def tearDown(self): self._mox.UnsetStubs() @@ -302,13 +306,16 @@ class NetappCmodeNfsDriverTestCase(test.TestCase): 'netapp_server_hostname', 'netapp_server_port'] + # set required flags + for flag in required_flags: + setattr(drv.configuration, flag, None) # check exception raises when flags are not set self.assertRaises(exception.CinderException, drv.check_for_setup_error) # set required flags for flag in required_flags: - setattr(iscsi.FLAGS, flag, 'val') + setattr(drv.configuration, flag, 'val') mox.ReplayAll() @@ -318,17 +325,17 @@ class NetappCmodeNfsDriverTestCase(test.TestCase): # restore initial FLAGS for flag in required_flags: - delattr(iscsi.FLAGS, flag) + delattr(drv.configuration, flag) def test_do_setup(self): mox = self._mox drv = self._driver mox.StubOutWithMock(drv, 'check_for_setup_error') - mox.StubOutWithMock(netapp_nfs.NetAppCmodeNfsDriver, '_get_client') + mox.StubOutWithMock(drv, '_get_client') drv.check_for_setup_error() - netapp_nfs.NetAppCmodeNfsDriver._get_client() + drv._get_client() mox.ReplayAll() @@ -470,7 +477,7 @@ class NetappDirectCmodeNfsDriverTestCase(NetappCmodeNfsDriverTestCase): """Test direct NetApp C Mode driver""" def _custom_setup(self): self._driver = netapp_nfs.NetAppDirectCmodeNfsDriver( - configuration=create_configuration()) + configuration=create_configuration()) def test_check_for_setup_error(self): mox = self._mox @@ -482,13 +489,16 @@ class NetappDirectCmodeNfsDriverTestCase(NetappCmodeNfsDriverTestCase): 'netapp_server_hostname', 'netapp_server_port'] + # set required flags + for flag in required_flags: + setattr(drv.configuration, flag, None) # check exception raises when flags are not set self.assertRaises(exception.CinderException, drv.check_for_setup_error) # set required flags for flag in required_flags: - setattr(iscsi.FLAGS, flag, 'val') + setattr(drv.configuration, flag, 'val') mox.ReplayAll() @@ -498,19 +508,18 @@ class NetappDirectCmodeNfsDriverTestCase(NetappCmodeNfsDriverTestCase): # restore initial FLAGS for flag in required_flags: - delattr(iscsi.FLAGS, flag) + delattr(drv.configuration, flag) def test_do_setup(self): mox = self._mox drv = self._driver mox.StubOutWithMock(drv, 'check_for_setup_error') - mox.StubOutWithMock(netapp_nfs.NetAppDirectCmodeNfsDriver, - '_get_client') + mox.StubOutWithMock(drv, '_get_client') mox.StubOutWithMock(drv, '_do_custom_setup') drv.check_for_setup_error() - netapp_nfs.NetAppDirectNfsDriver._get_client() + drv._get_client() drv._do_custom_setup(IgnoreArg()) mox.ReplayAll() @@ -590,7 +599,7 @@ class NetappDirect7modeNfsDriverTestCase(NetappDirectCmodeNfsDriverTestCase): """Test direct NetApp C Mode driver""" def _custom_setup(self): self._driver = netapp_nfs.NetAppDirect7modeNfsDriver( - configuration=create_configuration()) + configuration=create_configuration()) def test_check_for_setup_error(self): mox = self._mox @@ -602,13 +611,16 @@ class NetappDirect7modeNfsDriverTestCase(NetappDirectCmodeNfsDriverTestCase): 'netapp_server_hostname', 'netapp_server_port'] + # set required flags + for flag in required_flags: + setattr(drv.configuration, flag, None) # check exception raises when flags are not set self.assertRaises(exception.CinderException, drv.check_for_setup_error) # set required flags for flag in required_flags: - setattr(iscsi.FLAGS, flag, 'val') + setattr(drv.configuration, flag, 'val') mox.ReplayAll() @@ -618,19 +630,18 @@ class NetappDirect7modeNfsDriverTestCase(NetappDirectCmodeNfsDriverTestCase): # restore initial FLAGS for flag in required_flags: - delattr(iscsi.FLAGS, flag) + delattr(drv.configuration, flag) def test_do_setup(self): mox = self._mox drv = self._driver mox.StubOutWithMock(drv, 'check_for_setup_error') - mox.StubOutWithMock(netapp_nfs.NetAppDirect7modeNfsDriver, - '_get_client') + mox.StubOutWithMock(drv, '_get_client') mox.StubOutWithMock(drv, '_do_custom_setup') drv.check_for_setup_error() - netapp_nfs.NetAppDirectNfsDriver._get_client() + drv._get_client() drv._do_custom_setup(IgnoreArg()) mox.ReplayAll() diff --git a/cinder/volume/drivers/netapp/iscsi.py b/cinder/volume/drivers/netapp/iscsi.py index ec6898e32..bdcd0cfcb 100644 --- a/cinder/volume/drivers/netapp/iscsi.py +++ b/cinder/volume/drivers/netapp/iscsi.py @@ -32,7 +32,6 @@ from suds import client from suds.sax import text from cinder import exception -from cinder import flags from cinder.openstack.common import lockutils from cinder.openstack.common import log as logging from cinder.volume import driver @@ -84,9 +83,6 @@ netapp_opts = [ help='Comma separated eligible volumes for provisioning on' ' 7 mode'), ] -FLAGS = flags.FLAGS -FLAGS.register_opts(netapp_opts) - class DfmDataset(object): def __init__(self, id, name, project, type): @@ -113,6 +109,7 @@ class NetAppISCSIDriver(driver.ISCSIDriver): def __init__(self, *args, **kwargs): super(NetAppISCSIDriver, self).__init__(*args, **kwargs) + self.configuration.append_config_values(netapp_opts) self.discovered_luns = [] self.discovered_datasets = [] self.lun_table = {} @@ -167,10 +164,10 @@ class NetAppISCSIDriver(driver.ISCSIDriver): required_flags = ['netapp_wsdl_url', 'netapp_login', 'netapp_password', 'netapp_server_hostname', 'netapp_server_port'] for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): raise exception.InvalidInput(reason=_('%s is not set') % flag) - if not (FLAGS.netapp_storage_service or - FLAGS.netapp_storage_service_prefix): + if not (self.configuration.netapp_storage_service or + self.configuration.netapp_storage_service_prefix): raise exception.InvalidInput( reason=_('Either ' 'netapp_storage_service or ' @@ -186,13 +183,15 @@ class NetAppISCSIDriver(driver.ISCSIDriver): """ self._check_flags() self._create_client( - wsdl_url=FLAGS.netapp_wsdl_url, - login=FLAGS.netapp_login, password=FLAGS.netapp_password, - hostname=FLAGS.netapp_server_hostname, - port=FLAGS.netapp_server_port, cache=True) - self._set_storage_service(FLAGS.netapp_storage_service) - self._set_storage_service_prefix(FLAGS.netapp_storage_service_prefix) - self._set_vfiler(FLAGS.netapp_vfiler) + wsdl_url=self.configuration.netapp_wsdl_url, + login=self.configuration.netapp_login, + password=self.configuration.netapp_password, + hostname=self.configuration.netapp_server_hostname, + port=self.configuration.netapp_server_port, cache=True) + self._set_storage_service(self.configuration.netapp_storage_service) + self._set_storage_service_prefix( + self.configuration.netapp_storage_service_prefix) + self._set_vfiler(self.configuration.netapp_vfiler) def check_for_setup_error(self): """Check that the driver is working and can communicate. @@ -1153,6 +1152,7 @@ class NetAppCmodeISCSIDriver(driver.ISCSIDriver): def __init__(self, *args, **kwargs): super(NetAppCmodeISCSIDriver, self).__init__(*args, **kwargs) + self.configuration.append_config_values(netapp_opts) self.lun_table = {} def _create_client(self, **kwargs): @@ -1177,7 +1177,7 @@ class NetAppCmodeISCSIDriver(driver.ISCSIDriver): required_flags = ['netapp_wsdl_url', 'netapp_login', 'netapp_password', 'netapp_server_hostname', 'netapp_server_port'] for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): msg = _('%s is not set') % flag raise exception.InvalidInput(data=msg) @@ -1190,10 +1190,11 @@ class NetAppCmodeISCSIDriver(driver.ISCSIDriver): """ self._check_flags() self._create_client( - wsdl_url=FLAGS.netapp_wsdl_url, - login=FLAGS.netapp_login, password=FLAGS.netapp_password, - hostname=FLAGS.netapp_server_hostname, - port=FLAGS.netapp_server_port, cache=True) + wsdl_url=self.configuration.netapp_wsdl_url, + login=self.configuration.netapp_login, + password=self.configuration.netapp_password, + hostname=self.configuration.netapp_server_hostname, + port=self.configuration.netapp_server_port, cache=True) def check_for_setup_error(self): """Check that the driver is working and can communicate. @@ -1494,6 +1495,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver): def __init__(self, *args, **kwargs): super(NetAppDirectISCSIDriver, self).__init__(*args, **kwargs) + self.configuration.append_config_values(netapp_opts) self.lun_table = {} def _create_client(self, **kwargs): @@ -1522,7 +1524,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver): """Ensure that the flags we care about are set.""" required_flags = self.required_flags for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): msg = _('%s is not set') % flag raise exception.InvalidInput(data=msg) @@ -1535,10 +1537,11 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver): """ self._check_flags() self._create_client( - transport_type=FLAGS.netapp_transport_type, - login=FLAGS.netapp_login, password=FLAGS.netapp_password, - hostname=FLAGS.netapp_server_hostname, - port=FLAGS.netapp_server_port) + transport_type=self.configuration.netapp_transport_type, + login=self.configuration.netapp_login, + password=self.configuration.netapp_password, + hostname=self.configuration.netapp_server_hostname, + port=self.configuration.netapp_server_port) self._do_custom_setup() def check_for_setup_error(self): @@ -1714,7 +1717,8 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver): def _create_lun_on_eligible_vol(self, name, size, metadata): """Creates an actual lun on filer.""" - req_size = float(size) * float(FLAGS.netapp_size_multiplier) + req_size = float(size) *\ + float(self.configuration.netapp_size_multiplier) volume = self._get_avl_volume_by_size(req_size) if not volume: msg = _('Failed to get vol with required size for volume: %s') @@ -1959,7 +1963,7 @@ class NetAppDirectCmodeISCSIDriver(NetAppDirectISCSIDriver): def _do_custom_setup(self): """Does custom setup for ontap cluster.""" - self.vserver = FLAGS.netapp_vserver + self.vserver = self.configuration.netapp_vserver # Default values to run first api self.client.set_api_version(1, 15) (major, minor) = self._get_ontapi_version() @@ -2250,8 +2254,8 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver): def _do_custom_setup(self): """Does custom setup depending on the type of filer.""" - self.vfiler = FLAGS.netapp_vfiler - self.volume_list = FLAGS.netapp_volume_list + self.vfiler = self.configuration.netapp_vfiler + self.volume_list = self.configuration.netapp_volume_list if self.volume_list: self.volume_list = self.volume_list.split(',') self.volume_list = [el.strip() for el in self.volume_list] @@ -2350,9 +2354,10 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver): def _create_lun_handle(self, metadata): """Returns lun handle based on filer type.""" if self.vfiler: - owner = '%s:%s' % (FLAGS.netapp_server_hostname, self.vfiler) + owner = '%s:%s' % (self.configuration.netapp_server_hostname, + self.vfiler) else: - owner = FLAGS.netapp_server_hostname + owner = self.configuration.netapp_server_hostname return '%s:%s' % (owner, metadata['Path']) def _get_lun_list(self): diff --git a/cinder/volume/drivers/netapp/nfs.py b/cinder/volume/drivers/netapp/nfs.py index e08981e58..60a986222 100644 --- a/cinder/volume/drivers/netapp/nfs.py +++ b/cinder/volume/drivers/netapp/nfs.py @@ -26,7 +26,6 @@ import suds from suds.sax import text from cinder import exception -from cinder import flags from cinder.openstack.common import log as logging from cinder.volume.drivers.netapp.api import NaApiError from cinder.volume.drivers.netapp.api import NaElement @@ -41,10 +40,6 @@ netapp_nfs_opts = [ default=0, help='Does snapshot creation call returns immediately')] -FLAGS = flags.FLAGS -FLAGS.register_opts(netapp_opts) -FLAGS.register_opts(netapp_nfs_opts) - class NetAppNFSDriver(nfs.NfsDriver): """Executes commands relating to Volumes.""" @@ -53,6 +48,8 @@ class NetAppNFSDriver(nfs.NfsDriver): self._execute = None self._context = None super(NetAppNFSDriver, self).__init__(*args, **kwargs) + self.configuration.append_config_values(netapp_opts) + self.configuration.append_config_values(netapp_nfs_opts) def set_execute(self, execute): self._execute = execute @@ -60,11 +57,11 @@ class NetAppNFSDriver(nfs.NfsDriver): def do_setup(self, context): self._context = context self.check_for_setup_error() - self._client = NetAppNFSDriver._get_client() + self._client = self._get_client() def check_for_setup_error(self): """Returns an error if prerequisites aren't met""" - NetAppNFSDriver._check_dfm_flags() + self._check_dfm_flags() super(NetAppNFSDriver, self).check_for_setup_error() def create_volume_from_snapshot(self, volume, snapshot): @@ -98,8 +95,7 @@ class NetAppNFSDriver(nfs.NfsDriver): self._execute('rm', self._get_volume_path(nfs_mount, snapshot.name), run_as_root=True) - @staticmethod - def _check_dfm_flags(): + def _check_dfm_flags(self): """Raises error if any required configuration flag for OnCommand proxy is missing.""" required_flags = ['netapp_wsdl_url', @@ -108,17 +104,18 @@ class NetAppNFSDriver(nfs.NfsDriver): 'netapp_server_hostname', 'netapp_server_port'] for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): raise exception.CinderException(_('%s is not set') % flag) - @staticmethod - def _get_client(): + def _get_client(self): """Creates SOAP _client for ONTAP-7 DataFabric Service.""" - client = suds.client.Client(FLAGS.netapp_wsdl_url, - username=FLAGS.netapp_login, - password=FLAGS.netapp_password) - soap_url = 'http://%s:%s/apis/soap/v1' % (FLAGS.netapp_server_hostname, - FLAGS.netapp_server_port) + client = suds.client.Client( + self.configuration.netapp_wsdl_url, + username=self.configuration.netapp_login, + password=self.configuration.netapp_password) + soap_url = 'http://%s:%s/apis/soap/v1' % ( + self.configuration.netapp_server_hostname, + self.configuration.netapp_server_port) client.set_options(location=soap_url) return client @@ -148,7 +145,8 @@ class NetAppNFSDriver(nfs.NfsDriver): resp = self._client.service.ApiProxy(Target=host_id, Request=request) - if resp.Status == 'passed' and FLAGS.synchronous_snapshot_create: + if (resp.Status == 'passed' and + self.configuration.synchronous_snapshot_create): clone_id = resp.Results['clone-id'][0] clone_id_info = clone_id['clone-id-info'][0] clone_operation_id = int(clone_id_info['clone-op-id'][0]) @@ -251,7 +249,7 @@ class NetAppNFSDriver(nfs.NfsDriver): return True except exception.ProcessExecutionError: tries = tries + 1 - if tries >= FLAGS.num_shell_tries: + if tries >= self.configuration.num_shell_tries: raise LOG.exception(_("Recovering from a failed execute. " "Try number %s"), tries) @@ -317,11 +315,11 @@ class NetAppCmodeNfsDriver (NetAppNFSDriver): def do_setup(self, context): self._context = context self.check_for_setup_error() - self._client = NetAppCmodeNfsDriver._get_client() + self._client = self._get_client() def check_for_setup_error(self): """Returns an error if prerequisites aren't met""" - NetAppCmodeNfsDriver._check_flags() + self._check_flags() def _clone_volume(self, volume_name, clone_name, volume_id): """Clones mounted volume with NetApp Cloud Services""" @@ -333,8 +331,7 @@ class NetAppCmodeNfsDriver (NetAppNFSDriver): self._client.service.CloneNasFile(host_ip, export_path, volume_name, clone_name) - @staticmethod - def _check_flags(): + def _check_flags(self): """Raises error if any required configuration flag for NetApp Cloud Webservices is missing.""" required_flags = ['netapp_wsdl_url', @@ -343,15 +340,15 @@ class NetAppCmodeNfsDriver (NetAppNFSDriver): 'netapp_server_hostname', 'netapp_server_port'] for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): raise exception.CinderException(_('%s is not set') % flag) - @staticmethod - def _get_client(): + def _get_client(self): """Creates SOAP _client for NetApp Cloud service.""" - client = suds.client.Client(FLAGS.netapp_wsdl_url, - username=FLAGS.netapp_login, - password=FLAGS.netapp_password) + client = suds.client.Client( + self.configuration.netapp_wsdl_url, + username=self.configuration.netapp_login, + password=self.configuration.netapp_password) return client def get_volume_stats(self, refresh=False): @@ -389,19 +386,18 @@ class NetAppDirectNfsDriver (NetAppNFSDriver): def do_setup(self, context): self._context = context self.check_for_setup_error() - self._client = NetAppDirectNfsDriver._get_client() + self._client = self._get_client() self._do_custom_setup(self._client) def check_for_setup_error(self): """Returns an error if prerequisites aren't met""" - NetAppDirectNfsDriver._check_flags() + self._check_flags() def _clone_volume(self, volume_name, clone_name, volume_id): """Clones mounted volume on NetApp filer""" raise NotImplementedError() - @staticmethod - def _check_flags(): + def _check_flags(self): """Raises error if any required configuration flag for NetApp filer is missing.""" required_flags = ['netapp_login', @@ -410,18 +406,18 @@ class NetAppDirectNfsDriver (NetAppNFSDriver): 'netapp_server_port', 'netapp_transport_type'] for flag in required_flags: - if not getattr(FLAGS, flag, None): + if not getattr(self.configuration, flag, None): raise exception.CinderException(_('%s is not set') % flag) - @staticmethod - def _get_client(): + def _get_client(self): """Creates NetApp api client.""" - client = NaServer(host=FLAGS.netapp_server_hostname, - server_type=NaServer.SERVER_TYPE_FILER, - transport_type=FLAGS.netapp_transport_type, - style=NaServer.STYLE_LOGIN_PASSWORD, - username=FLAGS.netapp_login, - password=FLAGS.netapp_password) + client = NaServer( + host=self.configuration.netapp_server_hostname, + server_type=NaServer.SERVER_TYPE_FILER, + transport_type=self.configuration.netapp_transport_type, + style=NaServer.STYLE_LOGIN_PASSWORD, + username=self.configuration.netapp_login, + password=self.configuration.netapp_password) return client def _do_custom_setup(self, client): -- 2.45.2