use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult 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;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARCGHelper method createConsistencyGroupSnapshot.
public DriverTask createConsistencyGroupSnapshot(VolumeConsistencyGroup consistencyGroup, List<VolumeSnapshot> snapshots, List<CapabilityInstance> capabilities, DriverTask task, Registry driverRegistry) {
_log.info("3PARDriver: createConsistencyGroupSnapshot for storage system id {}, display name {} , native id {} - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
String VVsetSnapshotName = consistencyGroup.getDisplayName();
VolumeDetailsCommandResult volResult = null;
try {
Boolean readOnly = true;
int noOfSnaps = snapshots.size();
// get Vipr generated Snapshot name
for (VolumeSnapshot snap : snapshots) {
// native id = null ,
_log.info("3PARDriver: createConsistencyGroupSnapshot for volume native id {}, snap shot name generated is {} ", snap.getParentId(), snap.getDisplayName());
if (snap.getAccessStatus() != AccessStatus.READ_ONLY) {
readOnly = false;
}
String generatedSnapshotName = snap.getDisplayName();
if (noOfSnaps > 1) {
VVsetSnapshotName = generatedSnapshotName.substring(0, generatedSnapshotName.lastIndexOf("-")) + "-";
} else {
VVsetSnapshotName = generatedSnapshotName;
}
_log.info("3PARDriver: createConsistencyGroupSnapshot VVsetSnapshotName {} ", VVsetSnapshotName);
break;
}
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
// Create vvset snapshot
hp3parApi.createVVsetVirtualCopy(consistencyGroup.getNativeId(), VVsetSnapshotName, readOnly);
int volumeNumber = 0;
int snapVolumeCount = snapshots.size();
while (volumeNumber < snapVolumeCount) {
String snapshotCreated = VVsetSnapshotName + volumeNumber;
_log.info("3PARDriver: createConsistencyGroupSnapshot snapshotCreated {}, volumeNumber {} , snapVolumeCount {} ", snapshotCreated, volumeNumber, snapVolumeCount);
volResult = hp3parApi.getVolumeDetails(VVsetSnapshotName + volumeNumber);
if (volResult != null) {
String baseVolume = volResult.getCopyOf();
if (baseVolume != null) {
for (VolumeSnapshot snap : snapshots) {
String parentName = snap.getParentId();
if (parentName.equals(baseVolume)) {
_log.info("createConsistencyGroupSnapshot Snapshot system native id {}, Parent id {}, base volume {}, " + "access status {}, display name {}, native Name {}, DeviceLabel {}, wwn {} - Before ", snap.getStorageSystemId(), snap.getParentId(), baseVolume, snap.getAccessStatus(), snap.getDisplayName(), snap.getNativeId(), snap.getDeviceLabel(), snap.getWwn());
snap.setWwn(volResult.getWwn());
snap.setNativeId(volResult.getName());
snap.setDeviceLabel(volResult.getName());
// snap.setAccessStatus(volResult.getAccessStatus());
snap.setDisplayName(volResult.getName());
_log.info("createConsistencyGroupSnapshot Snapshot system native id {}, Parent Volume {}, access status {}, display name {}," + " native Name {}, DeviceLabel {}, wwn {} - After", snap.getStorageSystemId(), snap.getParentId(), snap.getAccessStatus(), snap.getDisplayName(), snap.getNativeId(), snap.getDeviceLabel(), snap.getWwn());
}
}
} else {
_log.info("3PARDriver: createConsistencyGroupSnapshot baseVolume is null");
}
}
volumeNumber++;
}
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createConsistencyGroupSnapshot for storage system native id {}, CG display Name {}, CG native id {} - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to create vv set snap name %s and its native id %s whose storage system id is %s; Error: %s.\n", VVsetSnapshotName, consistencyGroup.getNativeId(), consistencyGroup.getStorageSystemId(), e.getMessage());
_log.error(msg);
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
e.printStackTrace();
}
return task;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARIngestHelper method getVolumeSnapshots.
/**
* Identifying snapshots of the given parent base volume. NOTE: Intermediate
* virtual copies of 3PAR generated from other snapshots/clone are shown as
* snapshots of base volume itself
*/
public List<VolumeSnapshot> getVolumeSnapshots(StorageVolume volume, Registry registry) {
_log.info("3PARDriver: getVolumeSnapshots Running ");
List<VolumeSnapshot> snapshots = new ArrayList<>();
try {
Map<String, List<String>> vvolAssociations = registry.getDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, volume.getStorageSystemId() + "____VVOL_ASSOCIATIONS");
_log.info("vvolAssociations is {}", vvolAssociations.toString());
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(volume.getStorageSystemId(), registry);
ArrayList<String> listOfChildVols = null;
listOfChildVols = (ArrayList<String>) vvolAssociations.get(volume.getNativeId());
_log.info("listOfChildVols.size() is {}", listOfChildVols.size());
for (String childName : listOfChildVols) {
// VolumeDetailsCommandResult is the data structure used for representation of
// the HP3PAR virtual volume
// VolumeSnapshot is the CoprHD southbound freamework's
// datastructure
VolumeSnapshot driverSnapshot = new VolumeSnapshot();
VolumeDetailsCommandResult resultSnap = hp3parApi.getVolumeDetails(childName);
if (resultSnap.getCopyType() == copyType.VIRTUAL_COPY.getValue()) {
driverSnapshot.setParentId(volume.getNativeId());
driverSnapshot.setNativeId(resultSnap.getName());
driverSnapshot.setDeviceLabel(resultSnap.getName());
driverSnapshot.setStorageSystemId(volume.getStorageSystemId());
driverSnapshot.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
if (volume.getConsistencyGroup() != null) {
driverSnapshot.setConsistencyGroup(volume.getConsistencyGroup());
}
driverSnapshot.setWwn(resultSnap.getWwn());
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = resultSnap.getUserSpace().getReservedMiB();
allocatedCapacity += resultSnap.getSnapshotSpace().getReservedMiB();
allocatedCapacity += resultSnap.getAdminSpace().getReservedMiB();
driverSnapshot.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
driverSnapshot.setProvisionedCapacity(resultSnap.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
snapshots.add(driverSnapshot);
}
}
_log.info("3PARDriver: getVolumeSnapshots Leaving");
return snapshots;
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get snapshot of volume with storage system %s and volume native id %s; Error: %s.\n", volume.getStorageSystemId(), volume.getNativeId(), e.getMessage());
_log.error(msg);
e.printStackTrace();
}
_log.info("3PARDriver: getVolumeSnapshots Leaving");
return null;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARIngestHelper method getStorageVolumes.
public DriverTask getStorageVolumes(StorageSystem storageSystem, List<StorageVolume> storageVolumes, MutableInt token, DriverTask task, Registry driverRegistry) {
_log.info("3PARDriver: getStorageVolumes Running ");
Map<String, List<String>> vvolAssociations = new HashMap<String, List<String>>();
Map<String, List<String>> vvolAncestryMap = new HashMap<String, List<String>>();
HashMap<Long, String> vvolNamesMap = new HashMap<Long, String>();
try {
HashMap<String, ArrayList<String>> volumesToVolSetsMap = generateVolumeSetToVolumeMap(storageSystem, driverRegistry);
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystem.getNativeId(), driverRegistry);
VolumesCommandResult objStorageVolumes = hp3parApi.getStorageVolumes();
// first we build HashMap of volume id , volume name
for (VolumeDetailsCommandResult objVolMember : objStorageVolumes.getMembers()) {
vvolNamesMap.put(new Long(objVolMember.getId()), objVolMember.getName());
}
_log.info("vvolNamesMap is {}", vvolNamesMap);
// We build a hashmap of volume names and their respective ancestors.
for (VolumeDetailsCommandResult objVolMember : objStorageVolumes.getMembers()) {
if (objVolMember.getCopyType() == HP3PARConstants.copyType.VIRTUAL_COPY.getValue()) {
ArrayList<String> arrLst = new ArrayList<String>();
arrLst.add(vvolNamesMap.get(objVolMember.getBaseId()));
vvolAncestryMap.put(new String(objVolMember.getId()), arrLst);
} else if (objVolMember.getCopyType() == HP3PARConstants.copyType.PHYSICAL_COPY.getValue()) {
ArrayList<String> arrLst = new ArrayList<String>();
arrLst.add(vvolNamesMap.get(objVolMember.getPhysParentId()));
vvolAncestryMap.put(new String(objVolMember.getId()), arrLst);
}
}
_log.info("vvolAncestryMap is {}", vvolAncestryMap);
_log.info("Total Volumes returned by API call {}", objStorageVolumes.getTotal());
for (VolumeDetailsCommandResult objVolMember : objStorageVolumes.getMembers()) {
_log.info("objVolMember is {}", objVolMember.getAllValues());
StorageVolume driverVolume = new StorageVolume();
driverVolume.setStorageSystemId(storageSystem.getNativeId());
driverVolume.setStoragePoolId(objVolMember.getUserCPG());
driverVolume.setNativeId(objVolMember.getName());
driverVolume.setProvisionedCapacity(objVolMember.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = objVolMember.getUserSpace().getReservedMiB();
allocatedCapacity += objVolMember.getSnapshotSpace().getReservedMiB();
allocatedCapacity += objVolMember.getAdminSpace().getReservedMiB();
driverVolume.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
driverVolume.setWwn(objVolMember.getWwn());
driverVolume.setNativeId(objVolMember.getName());
driverVolume.setDeviceLabel(objVolMember.getName());
// teminology)
if (volumesToVolSetsMap.containsKey(objVolMember.getName())) {
driverVolume.setConsistencyGroup(volumesToVolSetsMap.get(objVolMember.getName()).get(0));
} else {
_log.debug("Unmanaged volume volume {} not part of any consistency group", driverVolume);
}
if (objVolMember.isReadOnly()) {
driverVolume.setAccessStatus(StorageVolume.AccessStatus.READ_ONLY);
} else {
driverVolume.setAccessStatus(StorageVolume.AccessStatus.READ_WRITE);
}
if (objVolMember.getProvisioningType() == HP3PARConstants.provisioningType.TPVV.getValue()) {
driverVolume.setThinlyProvisioned(true);
} else {
driverVolume.setThinlyProvisioned(false);
}
// TODO: how much should the thin volume preallocation size be.
driverVolume.setThinVolumePreAllocationSize(3000L);
if (objVolMember.getCopyOf() != null) {
_log.info("skipping adding the volume {} to storagevolumes array", objVolMember.getName());
} else {
_log.info("Adding to storagevolumes array the volume {}", objVolMember.getName());
storageVolumes.add(driverVolume);
}
_log.info("Unmanaged volume info: pool {}, volume {}", driverVolume.getStoragePoolId(), driverVolume);
if (objVolMember.getCopyOf() != null) {
String ancestorId = null;
String ancestorName = null;
if (objVolMember.getCopyType() == copyType.VIRTUAL_COPY.getValue()) {
ancestorName = vvolAncestryMap.get(objVolMember.getId()).get(0);
} else if (objVolMember.getCopyType() == copyType.PHYSICAL_COPY.getValue()) {
ancestorName = vvolAncestryMap.get(objVolMember.getId()).get(0);
}
// ancestorName = vvolNamesMap.get(ancestorId);
if (vvolAssociations.containsKey(ancestorName)) {
ArrayList<String> listOfChildren = (ArrayList<String>) vvolAssociations.get(ancestorName);
listOfChildren.add(objVolMember.getName());
} else {
ArrayList<String> listOfChildren = new ArrayList<String>();
listOfChildren.add(objVolMember.getName());
vvolAssociations.put(ancestorName, listOfChildren);
}
_log.debug("objAncestor name is {}", ancestorName);
_log.debug("objVolMember being added is {} ", objVolMember.getName());
}
}
_log.info("The vvolAssociations being returned by GetStorageVolumes is {}", vvolAssociations);
task.setStatus(DriverTask.TaskStatus.READY);
driverRegistry.setDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, storageSystem.getNativeId() + "____VVOL_ASSOCIATIONS", vvolAssociations);
driverRegistry.setDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, storageSystem.getNativeId() + "____VVOL_ANCESTORS", vvolAncestryMap);
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get storagevolumes for storage system %s native id %s; Error: %s.\n", storageSystem.getSystemName(), storageSystem.getNativeId(), e.getMessage());
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.FAILED);
e.printStackTrace();
}
_log.info("3PARDriver: getStorageVolumes Leaving");
return task;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARSnapshotHelper method createVolumeSnapshot.
public DriverTask createVolumeSnapshot(List<VolumeSnapshot> snapshots, StorageCapabilities capabilities, DriverTask task, Registry driverRegistry) {
for (VolumeSnapshot snap : snapshots) {
try {
// native id = null ,
_log.info("3PARDriver: createVolumeSnapshot for storage system native id {}, snapshot name {}, parent id {}- start", snap.getNativeId(), snap.getDisplayName(), snap.getParentId());
Boolean readOnly = true;
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(snap.getStorageSystemId(), driverRegistry);
VolumeDetailsCommandResult volResult = null;
if (snap.getAccessStatus() != AccessStatus.READ_ONLY) {
readOnly = false;
}
// Create volume snapshot
hp3parApi.createVirtualCopy(snap.getParentId(), snap.getDisplayName(), readOnly);
volResult = hp3parApi.getVolumeDetails(snap.getDisplayName());
// Actual size of the volume in array
snap.setProvisionedCapacity(volResult.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
snap.setWwn(volResult.getWwn());
// required for volume
snap.setNativeId(snap.getDisplayName());
// delete
snap.setDeviceLabel(snap.getDisplayName());
snap.setAccessStatus(snap.getAccessStatus());
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createVolumeSnapshot for storage system native id {}, snapshot name {}, parent id {} - end", snap.getStorageSystemId(), snap.getDisplayName(), snap.getParentId());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to create volume snap name %s for parent base volume id %s whose storage system native id is %s; Error: %s.\n", snap.getDisplayName(), snap.getParentId(), snap.getStorageSystemId(), e.getMessage());
_log.error(msg);
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
e.printStackTrace();
}
}
return task;
}
Aggregations