Example #1
0
    def failback(self, volumes):
        """Failover volumes back to primary backend.

        The main steps:
        1. Switch the role of replication pairs.
        2. Copy the second LUN data back to primary LUN.
        3. Split replication pairs.
        4. Switch the role of replication pairs.
        5. Enable replications.
        """
        volumes_update = []
        for v in volumes:
            v_update = {}
            v_update['volume_id'] = v.id
            drv_data = get_replication_driver_data(v)
            pair_id = drv_data.get('pair_id')
            if not pair_id:
                LOG.warning("No pair id in volume %s.", v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            rmt_lun_id = drv_data.get('rmt_lun_id')
            if not rmt_lun_id:
                LOG.warning("No remote lun id in volume %s.", v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            # Switch replication pair role, and start synchronize.
            self.local_driver.enable(pair_id)

            # Wait for synchronize complete.
            self.local_driver.wait_replica_ready(pair_id)

            # Split replication pair again
            self.rmt_driver.failover(pair_id)

            # Switch replication pair role, and start synchronize.
            self.rmt_driver.enable(pair_id)

            lun_info = self.rmt_client.get_lun_info(rmt_lun_id)
            admin_metadata = huawei_utils.get_admin_metadata(v)
            admin_metadata.update({'huawei_lun_wwn': lun_info['WWN']})
            new_drv_data = {
                'pair_id': pair_id,
                'rmt_lun_id': v.provider_location
            }
            new_drv_data = to_string(new_drv_data)
            v_update['updates'] = {
                'provider_location': rmt_lun_id,
                'replication_status': 'available',
                'replication_driver_data': new_drv_data,
                'admin_metadata': admin_metadata
            }
            volumes_update.append(v_update)

        return volumes_update
Example #2
0
    def failback(self, volumes):
        """Failover volumes back to primary backend.

        The main steps:
        1. Switch the role of replication pairs.
        2. Copy the second LUN data back to primary LUN.
        3. Split replication pairs.
        4. Switch the role of replication pairs.
        5. Enable replications.
        """
        volumes_update = []
        for v in volumes:
            v_update = {}
            v_update['volume_id'] = v['id']
            drv_data = get_replication_driver_data(v)
            pair_id = drv_data.get('pair_id')
            if not pair_id:
                LOG.warning(_LW("No pair id in volume %s."), v['id'])
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            rmt_lun_id = drv_data.get('rmt_lun_id')
            if not rmt_lun_id:
                LOG.warning(_LW("No remote lun id in volume %s."), v['id'])
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            # Switch replication pair role, and start synchronize.
            self.local_driver.enable(pair_id)

            # Wait for synchronize complete.
            self.local_driver.wait_replica_ready(pair_id)

            # Split replication pair again
            self.rmt_driver.failover(pair_id)

            # Switch replication pair role, and start synchronize.
            self.rmt_driver.enable(pair_id)

            lun_info = self.rmt_client.get_lun_info(rmt_lun_id)
            admin_metadata = huawei_utils.get_admin_metadata(v)
            admin_metadata.update({'huawei_lun_wwn': lun_info['WWN']})
            new_drv_data = {'pair_id': pair_id,
                            'rmt_lun_id': v['provider_location']}
            new_drv_data = to_string(new_drv_data)
            v_update['updates'] = {'provider_location': rmt_lun_id,
                                   'replication_status': 'available',
                                   'replication_driver_data': new_drv_data,
                                   'admin_metadata': admin_metadata}
            volumes_update.append(v_update)

        return volumes_update
Example #3
0
    def failover(self, volumes):
        """Failover volumes back to secondary array.

        Split the replication pairs and make the secondary LUNs R&W.
        """
        volumes_update = []
        cgid_list = set()
        replicacg = ReplicaCG(self.local_client, self.rmt_client, self.conf)
        for v in volumes:
            v_update = {}
            v_update['volume_id'] = v.id
            drv_data = get_replication_driver_data(v)
            pair_id = drv_data.get('pair_id')
            if not pair_id:
                LOG.warning(_LW("No pair id in volume %s."), v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            rmt_lun_id = drv_data.get('rmt_lun_id')
            if not rmt_lun_id:
                LOG.warning(_LW("No remote lun id in volume %s."), v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            replica_info = self.rmt_op.get_replica_info(pair_id)
            consisgroup_id = replica_info.get('CGID')
            if consisgroup_id:
                if consisgroup_id not in cgid_list:
                    replicacg.failover(consisgroup_id)
                    cgid_list.add(consisgroup_id)
            else:
                self.rmt_driver.failover(pair_id)

            lun_info = self.rmt_client.get_lun_info(rmt_lun_id)
            admin_metadata = huawei_utils.get_admin_metadata(v)
            admin_metadata.update({'huawei_lun_wwn': lun_info['WWN']})

            new_drv_data = {
                'pair_id': pair_id,
                'rmt_lun_id': v.provider_location
            }
            new_drv_data = to_string(new_drv_data)
            v_update['updates'] = {
                'provider_location': rmt_lun_id,
                'replication_status': 'failed-over',
                'replication_driver_data': new_drv_data,
                'admin_metadata': admin_metadata
            }
            volumes_update.append(v_update)

        return volumes_update
Example #4
0
    def failover(self, volumes):
        """Failover volumes back to secondary array.

        Split the replication pairs and make the secondary LUNs R&W.
        """
        volumes_update = []
        for v in volumes:
            v_update = {}
            v_update['volume_id'] = v.id
            drv_data = get_replication_driver_data(v)
            pair_id = drv_data.get('pair_id')
            if not pair_id:
                LOG.warning("No pair id in volume %s.", v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            rmt_lun_id = drv_data.get('rmt_lun_id')
            if not rmt_lun_id:
                LOG.warning("No remote lun id in volume %s.", v.id)
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            self.rmt_driver.failover(pair_id)

            lun_info = self.rmt_client.get_lun_info(rmt_lun_id)
            admin_metadata = huawei_utils.get_admin_metadata(v)
            admin_metadata.update({'huawei_lun_wwn': lun_info['WWN']})

            new_drv_data = {
                'pair_id': pair_id,
                'rmt_lun_id': v.provider_location
            }
            new_drv_data = to_string(new_drv_data)
            v_update['updates'] = {
                'provider_location': rmt_lun_id,
                'replication_status': 'failed-over',
                'replication_driver_data': new_drv_data,
                'admin_metadata': admin_metadata
            }
            volumes_update.append(v_update)

        return volumes_update
Example #5
0
    def failover(self, volumes):
        """Failover volumes back to secondary array.

        Split the replication pairs and make the secondary LUNs R&W.
        """
        volumes_update = []
        for v in volumes:
            v_update = {}
            v_update['volume_id'] = v['id']
            drv_data = get_replication_driver_data(v)
            pair_id = drv_data.get('pair_id')
            if not pair_id:
                LOG.warning(_LW("No pair id in volume %s."), v['id'])
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            rmt_lun_id = drv_data.get('rmt_lun_id')
            if not rmt_lun_id:
                LOG.warning(_LW("No remote lun id in volume %s."), v['id'])
                v_update['updates'] = {'replication_status': 'error'}
                volumes_update.append(v_update)
                continue

            self.rmt_driver.failover(pair_id)

            lun_info = self.rmt_client.get_lun_info(rmt_lun_id)
            admin_metadata = huawei_utils.get_admin_metadata(v)
            admin_metadata.update({'huawei_lun_wwn': lun_info['WWN']})

            new_drv_data = {'pair_id': pair_id,
                            'rmt_lun_id': v['provider_location']}
            new_drv_data = to_string(new_drv_data)
            v_update['updates'] = {'provider_location': rmt_lun_id,
                                   'replication_status': 'failed-over',
                                   'replication_driver_data': new_drv_data,
                                   'admin_metadata': admin_metadata}
            volumes_update.append(v_update)

        return volumes_update