Search in sources :

Example 1 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.

the class HDSSnapshotOperations method restoreSingleVolumeSnapshot.

/**
 * 1. Find pair management server.
 * 2. Get SnapshotGroup's Object Id.
 * 3. Get ReplicationInfo's Object Id.
 * 4. Perform ReplicationInfo Restore operation.
 */
@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot from = dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume to = dbClient.queryObject(Volume.class, volume);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSHost pairMgmtServer = hdsApiClient.getSnapshotGroupPairManagementServer(storage.getSerialNumber());
        if (pairMgmtServer == null) {
            log.error("Unable to find snapshot group information/pair management server for Thin Image");
            throw HDSException.exceptions.snapshotGroupNotAvailable(storage.getNativeGuid());
        }
        SnapshotGroup snapShotGrp = getViPRSnapshotGroup(pairMgmtServer, storage.getSerialNumber());
        log.debug("to.getNativeId() :{}", to.getNativeId());
        log.debug("from.getNativeId() :{}", from.getNativeId());
        ReplicationInfo repInfo = getReplicationInfo(snapShotGrp, to.getNativeId(), from.getNativeId());
        hdsApiClient.restoreThinImagePair(pairMgmtServer.getObjectID(), snapShotGrp.getObjectID(), repInfo.getObjectID(), storage.getModel());
        taskCompleter.ready(dbClient);
        log.info("Restore Snapshot volume completed");
    } catch (Exception e) {
        String message = String.format("Generic exception when trying to restore from snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
        log.error(message, e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("restoreSingleVolumeSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSHost(com.emc.storageos.hds.model.HDSHost) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) SnapshotGroup(com.emc.storageos.hds.model.SnapshotGroup) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 2 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method modifyShadowImagePair.

/**
 * Modifies pair operation to split|resync|restore
 *
 * @param storageSystem
 * @param sourceVolumeNativeId
 * @param targetVolumeNativeId
 * @param operationType
 * @throws Exception
 */
public boolean modifyShadowImagePair(StorageSystem storageSystem, String sourceVolumeNativeId, String targetVolumeNativeId, HDSApiProtectionManager.ShadowImageOperationType operationType) throws Exception {
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiProtectionManager apiProtectionManager = apiClient.getHdsApiProtectionManager();
    log.info("{} pair operation started", operationType.name());
    Map<String, String> repliMap = apiProtectionManager.getReplicationRelatedObjectIds(sourceVolumeNativeId, targetVolumeNativeId);
    log.info("Replication Obj Ids :{}", repliMap);
    String replicationGroupObjId = repliMap.get(HDSConstants.REPLICATION_GROUP_OBJ_ID);
    String replicationInfoObjId = repliMap.get(HDSConstants.REPLICATION_INFO_OBJ_ID);
    ReplicationInfo replicationInfo = apiProtectionManager.modifyShadowImagePair(replicationGroupObjId, replicationInfoObjId, operationType, storageSystem.getModel());
    log.info("{} pair operation completed", operationType.name());
    return (replicationInfo != null);
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo)

Example 3 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.

the class HDSCloneOperations method createSingleClone.

/**
 * 1. Find ReplicationGroup objId from Device Manager
 * 2. Check dummy Host Group available on Storage System. if not available create a dummy Host Group name.
 * 3. Create a secondary volume and add dummy host group on it.
 * 4. create a SI pair
 *
 * Note that if createInactive is false, then a subsequent step in the
 * full copy creation workflow will do a wait for synchronization. This
 * will split the pair, which makes the clone active.
 *
 * @param storageSystem {@link StorageSystem}
 * @param sourceVolumeURI {@link URI}
 * @param cloneVolumeURI {@link URI}
 * @param createInactive {@link Boolean}
 * @param taskCompleter {@link TaskCompleter}
 */
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceVolumeURI, URI cloneVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) {
    log.info("START createSingleClone operation");
    Volume cloneVolume = null;
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
        String replicationGroupObjectID = hdsApiClient.getHdsApiProtectionManager().getReplicationGroupObjectId();
        if (replicationGroupObjectID == null) {
            log.error("Unable to find replication group information/pair management server for pair configuration");
            throw HDSException.exceptions.replicationGroupNotAvailable();
        }
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.createSecondaryVolumeForClone(storageSystem, sourceVolumeURI, cloneVolume);
        // Need to fetch clone volume from db to get volume's nativeId
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.addDummyLunPath(hdsApiClient, cloneVolume);
        BlockObject source = BlockObject.fetch(dbClient, sourceVolumeURI);
        String pairName = hdsProtectionOperations.generatePairName(source, cloneVolume);
        log.info("Pair Name :{}", pairName);
        ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), cloneVolume.getNativeId(), storageSystem.getModel());
        log.info("Replication Info object :{}", replicationInfo.toXMLString());
        log.info("createInactive :{}", createInactive);
        cloneVolume.setSyncActive(false);
        cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
        dbClient.persistObject(cloneVolume);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolumeURI, cloneVolumeURI);
        log.error(errorMsg, e);
        Volume clone = dbClient.queryObject(Volume.class, cloneVolumeURI);
        if (clone != null) {
            clone.setInactive(true);
            dbClient.persistObject(clone);
        }
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 4 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.

the class HDSApiProtectionManager method deleteShadowImagePair.

/**
 * Deletes SI replicationInfo instance from replication group
 *
 * @param replicationGroupObjId
 * @param replicationInfoObjId
 * @return {@link ReplicationInfo}
 * @throws Exception
 */
public ReplicationInfo deleteShadowImagePair(String replicationGroupObjId, String replicationInfoObjId, String model) throws Exception {
    InputStream responseStream = null;
    ReplicationInfo replicationInfo = null;
    try {
        if (replicationGroupObjId != null && replicationInfoObjId != null) {
            Map<String, Object> attributeMap = new HashMap<String, Object>();
            Delete deleteOp = new Delete(HDSConstants.REPLICATION);
            ReplicationGroup replicationGroup = new ReplicationGroup();
            replicationGroup.setObjectID(replicationGroupObjId);
            replicationInfo = new ReplicationInfo();
            replicationInfo.setObjectID(replicationInfoObjId);
            attributeMap.put(HDSConstants.DELETE, deleteOp);
            attributeMap.put(HDSConstants.MODEL, model);
            attributeMap.put(HDSConstants.REPLICATION_GROUP, replicationGroup);
            attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
            String deletePairQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
            log.info("Query to delete shadow image pair  Query: {}", deletePairQuery);
            URI endpointURI = hdsApiClient.getBaseURI();
            ClientResponse response = hdsApiClient.post(endpointURI, deletePairQuery);
            if (HttpStatus.SC_OK == response.getStatus()) {
                responseStream = response.getEntityInputStream();
                JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_REPLICATION_CONFIG_FILE);
                verifyErrorPayload(javaResult);
                log.info("Successfully Deleted pair");
                replicationInfo = javaResult.getBean(ReplicationInfo.class);
                log.info("replicationInfo :{}", replicationInfo);
            /*
                     * if (null == replicationInfo) {
                     * throw HDSException.exceptions.notAbleToCreateShadowImagePair();
                     * }
                     */
            } else {
                throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete shadow image pair due to invalid response %1$s from server", response.getStatus()));
            }
        } else {
            log.info("Replication info is not available on pair management server");
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("IOException occurred while closing the response stream");
            }
        }
    }
    return replicationInfo;
}
Also used : Delete(com.emc.storageos.hds.model.Delete) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) IOException(java.io.IOException) ReplicationGroup(com.emc.storageos.hds.model.ReplicationGroup) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 5 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.

the class HDSApiProtectionManager method modifyShadowImagePair.

/**
 * Modify ShadowImage pair operation .
 *
 * @param replicationGroupId
 * @param replicationInfoId
 * @param operationType
 * @return {@link ReplicationInfo}
 * @throws Exception
 */
public ReplicationInfo modifyShadowImagePair(String replicationGroupId, String replicationInfoId, ShadowImageOperationType operationType, String model) throws Exception {
    InputStream responseStream = null;
    ReplicationInfo replicationInfo = null;
    try {
        if (replicationGroupId != null && replicationInfoId != null) {
            Map<String, Object> attributeMap = new HashMap<String, Object>();
            Modify modifyOp = new Modify();
            modifyOp.setTarget(HDSConstants.REPLICATION);
            modifyOp.setOption(operationType.name());
            ReplicationGroup replicationGroup = new ReplicationGroup();
            replicationGroup.setObjectID(replicationGroupId);
            replicationInfo = new ReplicationInfo();
            replicationInfo.setObjectID(replicationInfoId);
            attributeMap.put(HDSConstants.MODIFY, modifyOp);
            attributeMap.put(HDSConstants.MODEL, model);
            attributeMap.put(HDSConstants.REPLICATION_GROUP, replicationGroup);
            attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
            String modifyPairQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_SHADOW_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
            log.info("Query to {} shadow image pair  Query: {}", operationType.name(), modifyPairQuery);
            URI endpointURI = hdsApiClient.getBaseURI();
            ClientResponse response = hdsApiClient.post(endpointURI, modifyPairQuery);
            if (HttpStatus.SC_OK == response.getStatus()) {
                responseStream = response.getEntityInputStream();
                JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_REPLICATION_CONFIG_FILE);
                verifyErrorPayload(javaResult);
                log.info("Successfully {}ed pair", operationType.name());
                replicationInfo = javaResult.getBean(ReplicationInfo.class);
                log.info("replicationInfo :{}", replicationInfo);
            /*
                     * if (null == replicationInfo) {
                     * throw HDSException.exceptions.notAbleToCreateShadowImagePair();
                     * }
                     */
            } else {
                throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to modify replication info due to invalid response %1$s from server", response.getStatus()));
            }
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("IOException occurred while closing the response stream");
            }
        }
    }
    return replicationInfo;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) Modify(com.emc.storageos.hds.model.Modify) IOException(java.io.IOException) ReplicationGroup(com.emc.storageos.hds.model.ReplicationGroup) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)16 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)7 HDSHost (com.emc.storageos.hds.model.HDSHost)7 HashMap (java.util.HashMap)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 URI (java.net.URI)6 JavaResult (org.milyn.payload.JavaResult)6 Volume (com.emc.storageos.db.client.model.Volume)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 HDSException (com.emc.storageos.hds.HDSException)5 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)5 ReplicationGroup (com.emc.storageos.hds.model.ReplicationGroup)5 SnapshotGroup (com.emc.storageos.hds.model.SnapshotGroup)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 Add (com.emc.storageos.hds.model.Add)2