Search in sources :

Example 11 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class HP3PARApi method createVVsetPhysicalCopy.

public VVSetVolumeClone[] createVVsetPhysicalCopy(String nativeId, String vVsetNameForClone, List<VolumeClone> clones, Boolean saveSnapshot) throws Exception {
    _log.info("3PARDriver:createVVsetPhysicalCopy enter");
    _log.info(" 3PARDriver:createVVsetPhysicalCopy CG name {} for cloning , corresponding CG clone name {} ", nativeId, vVsetNameForClone);
    ClientResponse clientResp = null;
    String vvSetClones = "";
    // for snapshot creation
    String payload = "{\"action\":\"createPhysicalCopy\", \"parameters\": { \"destVolume\": \"" + vVsetNameForClone + "\" , \"saveSnapshot\": " + saveSnapshot + "} }";
    final String path = MessageFormat.format(URI_CLONE_CG, nativeId);
    _log.info(" 3PARDriver: createVVsetPhysicalCopy uri = {} payload {} ", path, payload);
    try {
        // get Vipr generated clone name and create corresponding volumes
        for (VolumeClone clone : clones) {
            _log.info("3PARDriver: createVVsetPhysicalCopy generated clone native id {}, display name {} - start", clone.getParentId(), clone.getDisplayName());
            String generatedCloneName = clone.getDisplayName();
            String baseVolumeName = clone.getParentId();
            // create new volume , CG clone will fail if already exists
            VolumeDetailsCommandResult volResult = null;
            volResult = getVolumeDetails(baseVolumeName);
            if (volResult != null) {
                // UserCPG will be absent for clones, hence using snapCPG here. We might need to re-look CPG selection later
                String baseVolumeUserCPG = volResult.getUserCPG();
                String baseVolumeSnapCPG = volResult.getSnapCPG();
                Boolean tpvv = true;
                Boolean tdvv = false;
                if (volResult.getProvisioningType() == 6) {
                    tdvv = true;
                    tpvv = false;
                }
                _log.info("3PARDriver: createVolumeClone base volume exists, id {}, baseVolumeSnapCPG {} , baseVolumeUserCPG {} , copyOf {}, copyType {} , name {}, volume type {} - ", baseVolumeName, baseVolumeSnapCPG, baseVolumeUserCPG, volResult.getCopyOf(), volResult.getCopyType(), volResult.getName(), volResult.getProvisioningType());
                createVolume(generatedCloneName, baseVolumeSnapCPG, tpvv, tdvv, volResult.getSizeMiB());
                vvSetClones = vvSetClones + "\"" + generatedCloneName + "\",";
            }
        }
        if (vvSetClones != "") {
            vvSetClones = vvSetClones.substring(0, vvSetClones.lastIndexOf(","));
            // for VV set addition {"action":1,"setmembers":["vol-name","vol-name2"]}
            String vvsetPayload = "{\"name\": \"" + vVsetNameForClone + "\", \"setmembers\": [ \"" + vvSetClones + "\" ] }";
            // final String path = MessageFormat.format(URI_CREATE_CG);
            _log.info(" 3PARDriver: createVVsetPhysicalCopy uri = {} vvsetPayload {} ", URI_CREATE_CG.toString(), vvsetPayload);
            // Create and update Clone CG object and volumes
            try {
                clientResp = post(URI_CREATE_CG, vvsetPayload);
                if (clientResp == null) {
                    _log.error("3PARDriver: createVVsetPhysicalCopy There is no response from 3PAR");
                    throw new HP3PARException("There is no response from 3PAR");
                } else if (clientResp.getStatus() != 201) {
                    String errResp = getResponseDetails(clientResp);
                    _log.error("3PARDriver: createVVsetPhysicalCopy There is error response from 3PAR = {}", errResp);
                    throw new HP3PARException(errResp);
                } else {
                    _log.info("3PARDriver: createVVsetPhysicalCopy vvset created");
                }
            } catch (Exception e) {
                throw e;
            } finally {
                if (clientResp != null) {
                    clientResp.close();
                }
                _log.info("3PARDriver: createVVsetPhysicalCopy execute vvset");
            }
            // Executing CG clone
            try {
                clientResp = post(path, payload);
                if (clientResp == null) {
                    _log.error("3PARDriver:There is no response from 3PAR");
                    throw new HP3PARException("There is no response from 3PAR");
                } else if (clientResp.getStatus() != 201) {
                    String errResp = getResponseDetails(clientResp);
                    throw new HP3PARException(errResp);
                } else {
                    String responseString = clientResp.getEntity(String.class);
                    // String customerResponseString = "{\"Altered\":"+responseString+"}";
                    _log.info("3PARDriver:createVVsetVirtualCopy success , response ", responseString);
                    VVSetVolumeClone[] output = new Gson().fromJson(sanitize(responseString), VVSetVolumeClone[].class);
                    return output;
                }
            } catch (Exception e) {
                throw e;
            } finally {
                if (clientResp != null) {
                    clientResp.close();
                }
                _log.info("3PARDriver:createVVsetVirtualCopy leave");
            }
        // end try/catch/finally
        }
    } catch (Exception e) {
        _log.info("3PARDriver:createVVsetVirtualCopy ERROR ");
        throw e;
    }
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Gson(com.google.gson.Gson) VVSetVolumeClone(com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)

Example 12 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class StorageDriverSimulator method getVolumeClones.

@Override
public List<VolumeClone> getVolumeClones(StorageVolume volume) {
    List<VolumeClone> clones = new ArrayList<>();
    for (int i = 0; i < NUMBER_OF_CLONES_FOR_VOLUME; i++) {
        VolumeClone clone = new VolumeClone();
        clone.setParentId(volume.getNativeId());
        clone.setNativeId(volume.getNativeId() + "clone-" + i);
        clone.setDeviceLabel(volume.getNativeId() + "clone-" + i);
        clone.setStorageSystemId(volume.getStorageSystemId());
        clone.setStoragePoolId(volume.getStoragePoolId());
        clone.setAccessStatus(StorageObject.AccessStatus.READ_WRITE);
        if (CLONES_IN_CG) {
            clone.setConsistencyGroup(volume.getConsistencyGroup() + "cloneGroup-" + i);
        }
        clone.setAllocatedCapacity(volume.getAllocatedCapacity());
        clone.setProvisionedCapacity(volume.getProvisionedCapacity());
        clone.setThinlyProvisioned(true);
        clone.setWwn(String.format("%s%s", clone.getStorageSystemId(), clone.getNativeId()));
        clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
        clones.add(clone);
        if (GENERATE_EXPORT_DATA) {
            // generate export data for this clone --- the same export data as for its parent volume
            generateExportDataForVolumeReplica(volume, clone);
        }
    }
    return clones;
}
Also used : ArrayList(java.util.ArrayList) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 13 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class CreateGroupCloneSimulatorOperation method getSuccessMessage.

@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
    List<VolumeClone> clones;
    if ((args != null) && (args.length > 0)) {
        clones = (List<VolumeClone>) args[0];
    } else {
        // Must be asynchronous, so updated clones are in the task.
        CreateGroupCloneDriverTask createCloneTask = (CreateGroupCloneDriverTask) _task;
        clones = createCloneTask.getClones();
    }
    return String.format("StorageDriver: createGroupClone information for group %s on storage system %s, clones nativeIds %s - end", clones.get(0).getConsistencyGroup(), clones.get(0).getStorageSystemId(), clones.toString());
}
Also used : CreateGroupCloneDriverTask(com.emc.storageos.storagedriver.task.CreateGroupCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 14 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class CreateGroupCloneSimulatorOperation method updateOnAsynchronousSuccess.

@Override
public void updateOnAsynchronousSuccess() {
    CreateGroupCloneDriverTask createCloneTask = (CreateGroupCloneDriverTask) _task;
    List<VolumeClone> clones = createCloneTask.getClones();
    VolumeConsistencyGroup consistencyGroup = createCloneTask.getConsistencyGroup();
    updateGroupCloneInfo(consistencyGroup, clones);
}
Also used : VolumeConsistencyGroup(com.emc.storageos.storagedriver.model.VolumeConsistencyGroup) CreateGroupCloneDriverTask(com.emc.storageos.storagedriver.task.CreateGroupCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 15 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class CreateVolumeCloneSimulatorOperation method updateCloneInfo.

/**
 * Update the clone information after successfully being created.
 *
 * @param clones A list of the clones to be updated.
 */
public void updateCloneInfo(List<VolumeClone> clones) {
    for (VolumeClone clone : clones) {
        clone.setNativeId("clone-" + clone.getParentId() + clone.getDisplayName());
        clone.setWwn(String.format("%s%s", clone.getStorageSystemId(), clone.getNativeId()));
        clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
        clone.setProvisionedCapacity(clone.getRequestedCapacity());
        clone.setAllocatedCapacity(clone.getRequestedCapacity());
        clone.setDeviceLabel(clone.getNativeId());
    }
}
Also used : VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Aggregations

VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)27 Volume (com.emc.storageos.db.client.model.Volume)13 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)10 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 ArrayList (java.util.ArrayList)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)7 DriverTask (com.emc.storageos.storagedriver.DriverTask)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 IOException (java.io.IOException)7 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 StorageBlockObject (com.emc.storageos.storagedriver.model.StorageBlockObject)6 VolumeDetailsCommandResult (com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)4 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 CreateGroupCloneDriverTask (com.emc.storageos.storagedriver.task.CreateGroupCloneDriverTask)3 RestoreFromCloneDriverTask (com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2