Exemple #1
0
    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 setUp(self):
     super(TestVNXMirrorView, self).setUp()
     self.primary_client = mock.create_autospec(client.Client)
     self.secondary_client = mock.create_autospec(client.Client)
     self.mirror_view = common.VNXMirrorView(self.primary_client,
                                             self.secondary_client)