Search in sources :

Example 6 with XtremIOConsistencyGroup

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

the class XtremIOUnManagedVolumeDiscoverer method addObjectToUnManagedConsistencyGroup.

/**
 * Adds the passed in unmanaged volume or unmanaged snapshot
 * to an unmanaged consistency group object
 *
 * @param xtremIOClient - connection to xtremio REST interface
 * @param unManagedVolume - either and unmanaged volume or unmanaged snapshot
 *            associated with a consistency group
 * @param cgNameToProcess - consistency group being processed
 * @param storageSystem - storage system the objects are on
 * @param xioClusterName - name of the xtremio cluster being managed by the xtremio XMS
 * @param dbClient - dbclient
 * @throws Exception
 */
private void addObjectToUnManagedConsistencyGroup(XtremIOClient xtremIOClient, UnManagedVolume unManagedVolume, String cgNameToProcess, StorageSystem storageSystem, String xioClusterName, DbClient dbClient) throws Exception {
    // Check if the current CG is in the list of unsupported CGs
    if (!unSupportedCG.isEmpty() && unSupportedCG.contains(cgNameToProcess.toString())) {
        // leave the for loop and do nothing
        log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
        return;
    }
    log.info("Unmanaged volume {} belongs to consistency group {} on the array", unManagedVolume.getLabel(), cgNameToProcess);
    // Update the unManagedVolume object with CG information
    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.TRUE.toString());
    // Get the unmanaged CG details from the array
    XtremIOConsistencyGroup xioCG = xtremIOClient.getConsistencyGroupDetails(cgNameToProcess.toString(), xioClusterName);
    // determine the native guid for the unmanaged CG (storage system id + xio cg guid)
    String unManagedCGNativeGuid = NativeGUIDGenerator.generateNativeGuidForCG(storageSystem.getNativeGuid(), xioCG.getGuid());
    // determine if the unmanaged CG already exists in the unManagedCGToUpdateMap or in the database
    // if the the unmanaged CG is not in either create a new one
    UnManagedConsistencyGroup unManagedCG = null;
    if (unManagedCGToUpdateMap.containsKey(unManagedCGNativeGuid)) {
        unManagedCG = unManagedCGToUpdateMap.get(unManagedCGNativeGuid);
        log.info("Unmanaged consistency group {} was previously added to the unManagedCGToUpdateMap", unManagedCG.getLabel());
    } else {
        unManagedCG = DiscoveryUtils.checkUnManagedCGExistsInDB(dbClient, unManagedCGNativeGuid);
        if (null == unManagedCG) {
            // unmanaged CG does not exist in the database, create it
            unManagedCG = createUnManagedCG(unManagedCGNativeGuid, xioCG, storageSystem.getId(), dbClient);
            log.info("Created unmanaged consistency group: {}", unManagedCG.getId().toString());
        } else {
            log.info("Unmanaged consistency group {} was previously added to the database", unManagedCG.getLabel());
            // clean out the list of unmanaged volumes if this unmanaged cg was already
            // in the database and its first time being used in this discovery operation
            // the list should be re-populated by the current discovery operation
            log.info("Cleaning out unmanaged volume map from unmanaged consistency group: {}", unManagedCG.getLabel());
            unManagedCG.getUnManagedVolumesMap().clear();
        }
    }
    log.info("Adding unmanaged volume {} to unmanaged consistency group {}", unManagedVolume.getLabel(), unManagedCG.getLabel());
    // set the uri of the unmanaged CG in the unmanaged volume object
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), unManagedCG.getId().toString());
    // add the unmanaged volume object to the unmanaged CG
    unManagedCG.getUnManagedVolumesMap().put(unManagedVolume.getNativeGuid(), unManagedVolume.getId().toString());
    // add the unmanaged CG to the map of unmanaged CGs to be updated in the database once all volumes have been processed
    unManagedCGToUpdateMap.put(unManagedCGNativeGuid, unManagedCG);
    // add the unmanaged CG to the current set of CGs being discovered on the array. This is for book keeping later.
    allCurrentUnManagedCgURIs.add(unManagedCG.getId());
}
Also used : XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)

Example 7 with XtremIOConsistencyGroup

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

the class XtremIOSnapshotOperations method createGroupSnapshots.

@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        List<BlockSnapshot> snapObjs = dbClient.queryObject(BlockSnapshot.class, snapshotList);
        BlockSnapshot snapshotObj = snapObjs.get(0);
        BlockConsistencyGroup blockCG = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
        // Check if the CG for which we are creating snapshot exists on the array
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String snapsetLabel = snapshotObj.getSnapsetLabel();
        String cgName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, dbClient);
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(cgName, blockCG.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        String snapType = readOnly ? XtremIOConstants.XTREMIO_READ_ONLY_TYPE : XtremIOConstants.XTREMIO_REGULAR_TYPE;
        String snapshotSetTagName = XtremIOProvUtils.createTagsForVolumeAndSnaps(client, getVolumeFolderName(snapshotObj.getProject().getURI(), storage), clusterName).get(XtremIOConstants.SNAPSHOT_KEY);
        snapsetLabel = snapsetLabel + "_" + new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date());
        client.createConsistencyGroupSnapshot(cgName, snapsetLabel, "", snapType, clusterName);
        // tag the created the snapshotSet
        client.tagObject(snapshotSetTagName, XTREMIO_ENTITY_TYPE.SnapshotSet.name(), snapsetLabel, clusterName);
        _log.info("Snapset label :{}", snapsetLabel);
        // Create mapping of volume.deviceLabel to BlockSnapshot object
        Map<String, BlockSnapshot> volumeToSnapMap = new HashMap<String, BlockSnapshot>();
        for (BlockSnapshot snapshot : snapObjs) {
            Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
            volumeToSnapMap.put(volume.getDeviceLabel(), snapshot);
        }
        // Get the snapset details
        XtremIOConsistencyGroup snapset = client.getSnapshotSetDetails(snapsetLabel, clusterName);
        for (List<Object> snapDetails : snapset.getVolList()) {
            XtremIOVolume xioSnap = client.getSnapShotDetails(snapDetails.get(1).toString(), clusterName);
            _log.info("XIO Snap : {}", xioSnap);
            BlockSnapshot snapshot = volumeToSnapMap.get(xioSnap.getAncestoVolInfo().get(1));
            if (snapshot != null) {
                processSnapshot(xioSnap, snapshot, storage);
                snapshot.setReplicationGroupInstance(snapsetLabel);
                dbClient.updateObject(snapshot);
            }
        }
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error("Snapshot creation failed", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Date(java.util.Date) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) Volume(com.emc.storageos.db.client.model.Volume) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 8 with XtremIOConsistencyGroup

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

the class XtremIOSnapshotOperations method restoreGroupSnapshots.

@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        BlockConsistencyGroup group = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
        // Check if the CG exists on the array
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, dbClient);
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(cgName, group.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        client.restoreCGFromSnapshot(clusterName, cgName, snapshotObj.getReplicationGroupInstance());
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error("Snapshot restore failed", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 9 with XtremIOConsistencyGroup

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

the class XtremIOSnapshotOperations method resyncGroupSnapshots.

@Override
public void resyncGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
        BlockConsistencyGroup group = dbClient.queryObject(BlockConsistencyGroup.class, snapshotObj.getConsistencyGroup());
        // Check if the CG exists on the array
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, dbClient);
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(cgName, group.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        // So for pre 4.0.2 version, do not use noBackup option.
        if (XtremIOProvUtils.isXtremIOVersion402OrGreater(storage.getFirmwareVersion())) {
            client.refreshSnapshotFromCG(clusterName, cgName, snapshotObj.getReplicationGroupInstance(), true);
        } else {
            client.refreshSnapshotFromCG(clusterName, cgName, snapshotObj.getReplicationGroupInstance(), false);
        }
        String newSnapsetName = null;
        // Now get the new snapshot set name by querying back the snapshot
        XtremIOVolume xioSnap = client.getSnapShotDetails(snapshotObj.getDeviceLabel(), clusterName);
        if (xioSnap != null && xioSnap.getSnapSetList() != null && !xioSnap.getSnapSetList().isEmpty()) {
            List<Object> snapsetDetails = xioSnap.getSnapSetList().get(0);
            // The REST response for the snapsetList will contain 3 elements.
            // Example - {"00a07269b55e42fa91c1aabadb6ea85c","SnapshotSet.1458111462198",27}
            // We need the 2nd element which is the snapset name.
            newSnapsetName = snapsetDetails.get(1).toString();
        }
        // Update the new snapshot set name in all the CG snapshots
        if (NullColumnValueGetter.isNotNullValue(newSnapsetName)) {
            List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, dbClient);
            for (BlockSnapshot snap : snapshots) {
                _log.info("Updating replicationGroupInstance to {} in snapshot- {}:{}", newSnapsetName, snap.getLabel(), snap.getId());
                snap.setReplicationGroupInstance(newSnapsetName);
                dbClient.updateObject(snap);
            }
        }
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        _log.error("Snapshot resync failed", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 10 with XtremIOConsistencyGroup

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

the class XtremIOStorageDevice method doAddToConsistencyGroup.

@Override
public void doAddToConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} doAddToConsistencyGroup START ...", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    try {
        // Check if the consistency group exists
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        if (!client.isVersion2()) {
            _log.info("Nothing to add to consistency group {}", consistencyGroup.getLabel());
            taskCompleter.ready(dbClient);
            return;
        }
        String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
        String cgName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
        XtremIOConsistencyGroup cg = XtremIOProvUtils.isCGAvailableInArray(client, cgName, clusterName);
        if (cg == null) {
            _log.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
            taskCompleter.error(dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
            return;
        }
        List<BlockObject> updatedBlockObjects = new ArrayList<BlockObject>();
        for (URI uri : blockObjects) {
            BlockObject blockObject = BlockObject.fetch(dbClient, uri);
            if (blockObject != null) {
                if (blockObject.getClass().isInstance(Volume.class)) {
                    Volume volume = (Volume) blockObject;
                    if (volume.checkForRp() || RPHelper.isAssociatedToRpVplexType(volume, dbClient, PersonalityTypes.METADATA, PersonalityTypes.TARGET)) {
                        // This causes issues with local array snapshots of RP+VPlex volumes.
                        continue;
                    }
                }
                client.addVolumeToConsistencyGroup(blockObject.getLabel(), cgName, clusterName);
                blockObject.setConsistencyGroup(consistencyGroupId);
                updatedBlockObjects.add(blockObject);
            }
        }
        dbClient.updateAndReindexObject(updatedBlockObjects);
        taskCompleter.ready(dbClient);
        _log.info("{} doAddToConsistencyGroup END ...", storage.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Add To Consistency Group operation failed %s", e));
        // Remove any references to the consistency group
        for (URI blockObjectURI : blockObjects) {
            BlockObject blockObject = BlockObject.fetch(dbClient, blockObjectURI);
            if (blockObject != null) {
                blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
            }
            dbClient.persistObject(blockObject);
        }
        taskCompleter.error(dbClient, DeviceControllerException.exceptions.failedToAddMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getLabel(), e.getMessage()));
    }
}
Also used : XtremIOConsistencyGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOConsistencyGroup) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) Volume(com.emc.storageos.db.client.model.Volume) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) ArrayList(java.util.ArrayList) 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