def test_get_device(self): devices_list = common.ReplicationDeviceList(self.configuration) device = devices_list.get_device('array_id_1') self.assertIsNotNone(device) self.assertEqual('192.168.1.1', device.san_ip) self.assertEqual('admin', device.san_login) self.assertEqual('admin', device.san_password) self.assertEqual('global', device.storage_vnx_authentication_type) self.assertEqual('/home/stack/', device.storage_vnx_security_file_dir)
def get_remote_pool(config, volume): """Select remote pool name for replication. Prefer configured remote pool name, or same pool name as the source volume. """ pool_name = get_pool_from_host(volume.host) rep_list = common.ReplicationDeviceList(config) remote_pool_name = rep_list[0].pool_name return remote_pool_name if remote_pool_name else pool_name
def append_replication_stats(self, stats): if self.mirror_view: stats['replication_enabled'] = True stats['group_replication_enabled'] = False stats['consistent_group_replication_enabled'] = True stats['replication_count'] = 1 stats['replication_type'] = ['sync'] else: stats['replication_enabled'] = False stats['replication_targets'] = [ device.backend_id for device in common.ReplicationDeviceList( self.config)]
def build_mirror_view(self, configuration, failover=True): """Builds a mirror view operation class. :param configuration: driver configuration :param failover: True if from primary to configured array, False if from configured array to primary. """ rep_devices = configuration.replication_device if not rep_devices: LOG.info('Replication is not configured on backend: %s.', configuration.config_group) return None elif len(rep_devices) == 1: if not self.client.is_mirror_view_enabled(): error_msg = _('Replication is configured, ' 'but no MirrorView/S enabler installed on VNX.') raise exception.InvalidInput(reason=error_msg) rep_list = common.ReplicationDeviceList(configuration) device = rep_list[0] # primary_client always points to the configed VNX. primary_client = self._build_client_from_config(self.config) # secondary_client always points to the VNX in replication_device. secondary_client = client.Client( ip=device.san_ip, username=device.san_login, password=device.san_password, scope=device.storage_vnx_authentication_type, naviseccli=self.client.naviseccli, sec_file=device.storage_vnx_security_file_dir) if failover: mirror_view = common.VNXMirrorView(primary_client, secondary_client) else: # For fail-back, we need to take care of reversed ownership. mirror_view = common.VNXMirrorView(secondary_client, primary_client) return mirror_view else: error_msg = _('VNX Cinder driver does not support ' 'multiple replication targets.') raise exception.InvalidInput(reason=error_msg)
def test_devices(self): devices_list = common.ReplicationDeviceList(self.configuration) self.assertEqual(1, len(devices_list.devices)) self.assertEqual(1, len(devices_list)) self.assertIsNotNone(devices_list[0])
def test_get_device_not_found(self): devices_list = common.ReplicationDeviceList(self.configuration) device = devices_list.get_device('array_id_not_existed') self.assertIsNone(device)
def test_device_no_secfile(self): device = {'backend_id': 'test_id', 'san_ip': '192.168.1.2'} config = FakeConfiguration() config.replication_device = [device] rep_list = common.ReplicationDeviceList(config) self.assertIsNone(rep_list[0].storage_vnx_security_file_dir)