Example #1
0
 def test_setup_missing_controller_ip(self):
     configuration = self._set_config(self.create_configuration())
     configuration.netapp_controller_ips = None
     driver = common.NetAppDriver(configuration=configuration)
     self.assertRaises(exception.InvalidInput,
                       driver.do_setup,
                       context='context')
Example #2
0
 def test_do_setup_all_default(self):
     configuration = self._set_config(self.create_configuration())
     driver = common.NetAppDriver(configuration=configuration)
     driver.library._check_mode_get_or_register_storage_system = mock.Mock()
     mock_invoke = self.mock_object(client, 'RestClient')
     driver.do_setup(context='context')
     mock_invoke.assert_called_with(**fakes.FAKE_CLIENT_PARAMS)
Example #3
0
 def test_embedded_mode(self):
     configuration = self._set_config(create_configuration())
     configuration.netapp_controller_ips = '127.0.0.1,127.0.0.3'
     driver = common.NetAppDriver(configuration=configuration)
     driver.do_setup(context='context')
     self.assertEqual(driver._client.get_system_id(),
                      '1fa6efb5-f07b-4de4-9f0e-52e5f7ff5d1b')
Example #4
0
 def test_incorrect_family(self):
     configuration = create_configuration()
     configuration.netapp_storage_family = 'xyz_abc'
     try:
         driver = common.NetAppDriver(configuration=configuration)
         raise AssertionError('Wrong storage family is getting accepted.')
     except exception.InvalidInput:
         pass
Example #5
0
 def _custom_setup(self):
     configuration = self._set_config(create_configuration())
     driver = common.NetAppDriver(configuration=configuration)
     self.stubs.Set(httplib, 'HTTPConnection',
                    FakeDirect7modeHTTPConnection)
     driver.do_setup(context='')
     client = driver.client
     client.set_api_version(1, 7)
     self.driver = driver
Example #6
0
 def test_incorrect_protocol(self):
     configuration = create_configuration()
     configuration.netapp_storage_family = 'ontap'
     configuration.netapp_storage_protocol = 'ontap'
     try:
         driver = common.NetAppDriver(configuration=configuration)
         raise AssertionError('Wrong storage protocol is getting accepted.')
     except InvalidInput:
         pass
Example #7
0
 def test_do_setup_http_non_default_port(self):
     configuration = self._set_config(self.create_configuration())
     configuration.netapp_server_port = 81
     driver = common.NetAppDriver(configuration=configuration)
     driver.library._check_mode_get_or_register_storage_system = mock.Mock()
     mock_invoke = self.mock_object(client, 'RestClient')
     driver.do_setup(context='context')
     FAKE_EXPECTED_PARAMS = dict(fakes.FAKE_CLIENT_PARAMS, port=81)
     mock_invoke.assert_called_with(**FAKE_EXPECTED_PARAMS)
Example #8
0
    def test_setup_error_invalid_both_controller_ips(self):
        configuration = self._set_config(self.create_configuration())
        configuration.netapp_controller_ips = '564.124.1231.1,987.65.43.21'
        driver = common.NetAppDriver(configuration=configuration)
        self.mock_object(na_utils, 'resolve_hostname',
                         mock.Mock(side_effect=socket.gaierror))

        self.assertRaises(
            exception.NoValidHost,
            driver.library._check_mode_get_or_register_storage_system)
Example #9
0
 def test_do_setup_all_default(self):
     configuration = self._set_config(create_configuration())
     driver = common.NetAppDriver(configuration=configuration)
     driver._check_mode_get_or_register_storage_system = mock.Mock()
     driver.do_setup(context='context')
     url = urlparse.urlparse(driver._client._endpoint)
     port = url.port
     scheme = url.scheme
     self.assertEqual(8080, port)
     self.assertEqual('http', scheme)
    def test_setup_error_invalid_first_controller_ip(self):
        configuration = self._set_config(self.create_configuration())
        configuration.netapp_controller_ips = '987.65.43.21,127.0.0.1'
        driver = common.NetAppDriver(configuration=configuration)
        self.mock_object(na_utils, 'resolve_hostname',
                         side_effect=socket.gaierror)

        self.assertRaises(
            exception.NoValidBackend,
            driver.library._check_mode_get_or_register_storage_system)
Example #11
0
    def _custom_setup(self):
        self.mock_object(na_utils, 'OpenStackInfo')

        configuration = self._set_config(self.create_configuration())
        self.driver = common.NetAppDriver(configuration=configuration)
        self.library = self.driver.library
        self.mock_object(self.library,
                         '_check_mode_get_or_register_storage_system')
        self.mock_object(self.driver.library, '_check_storage_system')
        self.driver.do_setup(context='context')
        self.driver.library._client._endpoint = fakes.FAKE_ENDPOINT_HTTP
Example #12
0
 def _custom_setup(self):
     self.stubs.Set(ssc_utils, 'refresh_cluster_ssc', lambda a, b, c: None)
     configuration = self._set_config(create_configuration())
     driver = common.NetAppDriver(configuration=configuration)
     self.stubs.Set(httplib, 'HTTPConnection',
                    FakeDirectCmodeHTTPConnection)
     driver.do_setup(context='')
     client = driver.client
     client.set_api_version(1, 15)
     self.driver = driver
     self.driver.ssc_vols = self.ssc_map
Example #13
0
 def test_do_setup_https_non_default_port(self):
     configuration = self._set_config(create_configuration())
     configuration.netapp_transport_type = 'https'
     configuration.netapp_server_port = 446
     driver = common.NetAppDriver(configuration=configuration)
     driver._check_mode_get_or_register_storage_system = mock.Mock()
     driver.do_setup(context='context')
     url = urlparse.urlparse(driver._client._endpoint)
     port = url.port
     scheme = url.scheme
     self.assertEqual(446, port)
     self.assertEqual('https', scheme)
Example #14
0
    def test_embedded_mode(self):
        self.mock_object(client.RestClient, '_init_features')
        configuration = self._set_config(self.create_configuration())
        configuration.netapp_controller_ips = '127.0.0.1,127.0.0.3'
        driver = common.NetAppDriver(configuration=configuration)
        self.mock_object(driver.library, '_version_check')
        self.mock_object(client.RestClient, 'list_storage_systems',
                         mock.Mock(return_value=[fakes.STORAGE_SYSTEM]))
        driver.do_setup(context='context')

        self.assertEqual('1fa6efb5-f07b-4de4-9f0e-52e5f7ff5d1b',
                         driver.library._client.get_system_id())
Example #15
0
 def test_non_netapp_driver(self):
     configuration = create_configuration()
     common.netapp_unified_plugin_registry['test_family'] =\
         {'iscsi': 'cinder.volume.drivers.arbitrary.IscsiDriver'}
     configuration.netapp_storage_family = 'test_family'
     configuration.netapp_storage_protocol = 'iscsi'
     try:
         driver = common.NetAppDriver(configuration=configuration)
         raise AssertionError('Non NetApp driver is getting instantiated.')
     except exception.InvalidInput:
         pass
     finally:
         common.netapp_unified_plugin_registry.pop('test_family')
Example #16
0
    def test_new(self):

        self.mock_object(na_utils.OpenStackInfo, 'info',
                         mock.Mock(return_value='fake_info'))
        mock_create_driver = self.mock_object(na_common.NetAppDriver,
                                              'create_driver')

        config = na_fakes.create_configuration()
        config.netapp_storage_family = 'fake_family'
        config.netapp_storage_protocol = 'fake_protocol'

        kwargs = {'configuration': config}
        na_common.NetAppDriver(**kwargs)

        kwargs['app_version'] = 'fake_info'
        mock_create_driver.assert_called_with('fake_family', 'fake_protocol',
                                              *(), **kwargs)
Example #17
0
 def test_setup_good_controller_ips(self):
     configuration = self._set_config(self.create_configuration())
     configuration.netapp_controller_ips = '127.0.0.2,127.0.0.1'
     driver = common.NetAppDriver(configuration=configuration)
     driver.library._check_mode_get_or_register_storage_system
Example #18
0
 def test_check_host_type_default(self):
     configuration = self._set_config(self.create_configuration())
     driver = common.NetAppDriver(configuration=configuration)
     driver.library._check_host_type()
     self.assertEqual('LnxALUA', driver.library.host_type)
 def _custom_setup(self):
     configuration = self._set_config(create_configuration())
     self.driver = common.NetAppDriver(configuration=configuration)
     requests.Session = mock.Mock(wraps=FakeEseriesHTTPSession)
     self.driver.do_setup(context='context')
     self.driver.check_for_setup_error()
 def test_setup_error_unsupported_host_type(self):
     configuration = self._set_config(create_configuration())
     configuration.netapp_eseries_host_type = 'garbage'
     driver = common.NetAppDriver(configuration=configuration)
     self.assertRaises(exception.NetAppDriverException,
                       driver.check_for_setup_error)
Example #21
0
 def _custom_setup(self):
     configuration = self._set_config(create_configuration())
     self.driver = common.NetAppDriver(configuration=configuration)
     self.mock_object(requests, 'Session', FakeEseriesHTTPSession)
     self.driver.do_setup(context='context')
     self.driver.check_for_setup_error()