FakeDirect7modeHTTPConnection)
driver.do_setup(context='')
client = driver.client
- client.set_api_version(1, 7)
+ client.set_api_version(1, 9)
self.driver = driver
def _set_config(self, configuration):
if not success:
raise AssertionError('Failed creating on selected volumes')
+ def test_check_for_setup_error_version(self):
+ drv = self.driver
+ delattr(drv.client, '_api_version')
+
+ # check exception raises when version not found
+ self.assertRaises(exception.VolumeBackendAPIException,
+ drv.check_for_setup_error)
+
+ drv.client.set_api_version(1, 8)
+
+ # check exception raises when not supported version
+ self.assertRaises(exception.VolumeBackendAPIException,
+ drv.check_for_setup_error)
+
class NetAppDirect7modeISCSIDriverTestCase_WV(
NetAppDirect7modeISCSIDriverTestCase_NV):
FakeDirect7modeHTTPConnection)
driver.do_setup(context='')
client = driver.client
- client.set_api_version(1, 7)
+ client.set_api_version(1, 9)
self.driver = driver
def _set_config(self, configuration):
drv = self._driver
mox.StubOutWithMock(netapp_nfs.NetAppNFSDriver, 'do_setup')
- mox.StubOutWithMock(drv, 'check_for_setup_error')
mox.StubOutWithMock(drv, '_get_client')
mox.StubOutWithMock(drv, '_do_custom_setup')
netapp_nfs.NetAppNFSDriver.do_setup(IgnoreArg())
- drv.check_for_setup_error()
drv._get_client()
drv._do_custom_setup(IgnoreArg())
self._driver = netapp_nfs.NetAppDirect7modeNfsDriver(
configuration=create_configuration())
+ def test_check_for_setup_error_version(self):
+ drv = self._driver
+ drv._client = api.NaServer("127.0.0.1")
+
+ # check exception raises when version not found
+ self.assertRaises(exception.VolumeBackendAPIException,
+ drv.check_for_setup_error)
+
+ drv._client.set_api_version(1, 8)
+
+ # check exception raises when not supported version
+ self.assertRaises(exception.VolumeBackendAPIException,
+ drv.check_for_setup_error)
+
def test_check_for_setup_error(self):
mox = self.mox
drv = self._driver
+ drv._client = api.NaServer("127.0.0.1")
+ drv._client.set_api_version(1, 9)
required_flags = [
'netapp_transport_type',
'netapp_login',
mox = self.mox
drv = self._driver
mox.StubOutWithMock(netapp_nfs.NetAppNFSDriver, 'do_setup')
- mox.StubOutWithMock(drv, 'check_for_setup_error')
mox.StubOutWithMock(drv, '_get_client')
mox.StubOutWithMock(drv, '_do_custom_setup')
netapp_nfs.NetAppNFSDriver.do_setup(IgnoreArg())
- drv.check_for_setup_error()
drv._get_client()
drv._do_custom_setup(IgnoreArg())
self._refresh_conn = True
def get_api_version(self):
- """Gets the api version."""
+ """Gets the api version tuple."""
if hasattr(self, '_api_version'):
- return self._api_version
- return self._api_version
+ return (self._api_major_version, self._api_minor_version)
+ return None
def set_port(self, port):
"""Set the server communication port."""
if self.volume_list:
self.volume_list = self.volume_list.split(',')
self.volume_list = [el.strip() for el in self.volume_list]
+ (major, minor) = self._get_ontapi_version()
+ self.client.set_api_version(major, minor)
if self.vfiler:
- (major, minor) = self._get_ontapi_version()
- self.client.set_api_version(major, minor)
self.client.set_vfiler(self.vfiler)
+ def check_for_setup_error(self):
+ """Check that the driver is working and can communicate."""
+ api_version = self.client.get_api_version()
+ if api_version:
+ major, minor = api_version
+ if major == 1 and minor < 9:
+ msg = _("Unsupported ONTAP version."
+ " ONTAP version 7.3.1 and above is supported.")
+ raise exception.VolumeBackendAPIException(data=msg)
+ else:
+ msg = _("Api version could not be determined.")
+ raise exception.VolumeBackendAPIException(data=msg)
+ super(NetAppDirect7modeISCSIDriver, self).check_for_setup_error()
+
def _create_lun_on_eligible_vol(self, name, size, metadata,
extra_specs=None):
"""Creates an actual lun on filer."""
def do_setup(self, context):
super(NetAppDirectNfsDriver, self).do_setup(context)
self._context = context
- self.check_for_setup_error()
self._client = self._get_client()
self._do_custom_setup(self._client)
(major, minor) = self._get_ontapi_version()
client.set_api_version(major, minor)
+ def check_for_setup_error(self):
+ """Checks if setup occured properly."""
+ api_version = self._client.get_api_version()
+ if api_version:
+ major, minor = api_version
+ if major == 1 and minor < 9:
+ msg = _("Unsupported ONTAP version."
+ " ONTAP version 7.3.1 and above is supported.")
+ raise exception.VolumeBackendAPIException(data=msg)
+ else:
+ msg = _("Api version could not be determined.")
+ raise exception.VolumeBackendAPIException(data=msg)
+ super(NetAppDirect7modeNfsDriver, self).check_for_setup_error()
+
def _invoke_successfully(self, na_element, vfiler=None):
"""Invoke the api for successful result.