def test_veryfy_debug_level(self): # check the default HostActions() self.assertEqual( host_actions.LOG.level, getattr(host_actions.logging, DEFAULT_DEBUG_LEVEL)) # check with specific level HostActions("ERROR") self.assertEqual( host_actions.LOG.level, getattr(host_actions.logging, "ERROR"))
def test_get_multipath_device_not_exit_device(self, ospathexist, check_output_mock): check_output_mock.return_value = MULTIPATH_OUTPUT ospathexist.return_value = True hostops = HostActions() with self.assertRaises(MultipathDeviceNotFound): hostops.get_multipath_device('fake-vol-wwn')
def test_get_multipath_device_redhat_exist_device(self, ospathexist, check_output_mock): check_output_mock.return_value = REDHAT_MULTIPATH_OUTPUT ospathexist.return_value = True hostops = HostActions() self.assertEqual(hostops.get_multipath_device(REDHAT_MULTIPATH_WWN), '{}/{}'.format(PREFIX_DEVICE_PATH, REDHAT_MULTIPATH_MPATH))
def test_get_multipath_device_exist2_device(self, ospathexist, check_output_mock): check_output_mock.return_value = MULTIPATH_OUTPUT2 ospathexist.return_value = True hostops = HostActions() self.assertEqual(hostops.get_multipath_device(MULTIPATH_OUTPUT_WWN2), '{}/{}'.format(PREFIX_DEVICE_PATH, WWN_PREFIX + MULTIPATH_OUTPUT_WWN2))
def __init__(self, cluster_id, backend_client, driver_conf): """ Initialize new instance of the IBM Storage Flocker driver. :param backend_client: IBMStorageAbsClient :param UUID cluster_id: The Flocker cluster ID :param driver_conf: dict with default resource to provision and default hostname for attach / detach operations. :raises MultipathCmdNotFound, RescanCmdNotFound: in case mandatory commands are missing """ self._client = backend_client self._cluster_id = cluster_id self._storage_resource = driver_conf[CONF_PARAM_DEFAULT_SERVICE] self._instance_id = self._get_host(driver_conf) self._cluster_id_slug = uuid2slug(self._cluster_id) self._host_ops = HostActions(backend_client.con_info.debug_level) self._is_multipathing = self._host_ops.is_multipath_active() LOG.info(messages.DRIVER_INITIALIZATION.format( backend_type=self._client.backend_type, backend_ip=self._client.con_info.management_ip, username=self._client.con_info.credential['username'], ))
def test_no_multipath_exist(self, find_executable): find_executable.side_effect = [None, 'rescan', 'iscsiadm', None] with self.assertRaises(MultipathCmdNotFound): HostActions()
def test_no_rescaan_cmd_exist(self, find_executable): find_executable.side_effect = [None, None] with self.assertRaises(RescanCmdNotFound): HostActions()
def test_rescan(self, check_output_mock): check_output_mock.return_value = None hostops = HostActions() hostops.rescan_scsi()