Search in sources :

Example 11 with XtremIOConsistencyGroup

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doRemoveFromConsistencyGroup.

@Override
public void doRemoveFromConsistencyGroup(StorageSystem storage, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} doRemoveFromConsistencyGroup START ...", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    String groupName = null;
    try {
        // get the group name from one of the block objects; we expect all of them to be the same group
        Iterator<URI> itr = blockObjects.iterator();
        while (itr.hasNext()) {
            BlockObject blockObject = BlockObject.fetch(dbClient, itr.next());
            if (blockObject != null && !blockObject.getInactive() && !NullColumnValueGetter.isNullValue(blockObject.getReplicationGroupInstance())) {
                groupName = blockObject.getReplicationGroupInstance();
                break;
            }
        }
        // Check if the replication group exists
        if (groupName != null) {
            // Check if the consistency group exists
            XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
            if (!client.isVersion2()) {
                _log.info("Nothing to remove from consistency group {}", consistencyGroup.getLabel());
                taskCompleter.ready(dbClient);
                return;
            }
            String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
            XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, groupName, clusterName);
            if (cg == null) {
                _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
                taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(groupName, consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
                return;
            }
            for (URI uri : blockObjects) {
                BlockObject blockObject = BlockObject.fetch(dbClient, uri);
                if (blockObject != null) {
                    client.removeVolumeFromConsistencyGroup(blockObject.getLabel(), blockObject.getReplicationGroupInstance(), clusterName);
                    blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                    blockObject.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
                    dbClient.updateObject(blockObject);
                }
            }
        }
        taskCompleter.ready(dbClient);
        _log.info("{} doRemoveFromConsistencyGroup END ...", storage.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Remove from Consistency Group operation failed %s", e));
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
    }
}
Also used : XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

XtremIOConsistencyGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup)11 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)6 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)6 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)4 Volume (com.emc.storageos.db.client.model.Volume)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 URI (java.net.URI)4 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 XtremIOCGResponse (com.emc.storageos.xtremio.restapi.model.response.XtremIOCGResponse)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 HashMap (java.util.HashMap)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 UnManagedConsistencyGroup (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1