use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARCloneHelper method createVolumeClone.
public DriverTask createVolumeClone(List<VolumeClone> clones, StorageCapabilities capabilities, DriverTask task, Registry driverRegistry) {
String storageSystemId = null;
HP3PARApi hp3parApi = null;
for (VolumeClone clone : clones) {
try {
// native id = null ,
_log.info("3PARDriver: createVolumeClone for storage system native id {}, clone parent name {} , clone name {} - start", clone.toString(), clone.getParentId(), clone.getDisplayName());
String localStorageSystemId = clone.getStorageSystemId();
// get Api client
if (storageSystemId == null || storageSystemId != localStorageSystemId) {
storageSystemId = localStorageSystemId;
hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(localStorageSystemId, driverRegistry);
}
VolumeDetailsCommandResult volResult = null;
// Create volume clone
hp3parApi.createPhysicalCopy(clone.getParentId(), clone.getDisplayName(), clone.getStoragePoolId());
volResult = hp3parApi.getVolumeDetails(clone.getDisplayName());
// Actual size of the volume in array
clone.setProvisionedCapacity(volResult.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
clone.setWwn(volResult.getWwn());
// required for volume
clone.setNativeId(volResult.getName());
// delete
clone.setDeviceLabel(clone.getDisplayName());
clone.setAccessStatus(clone.getAccessStatus());
clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("createVolumeClone for storage system native id {}, volume clone name {} - end", clone.getStorageSystemId(), clone.getDisplayName());
} catch (Exception e) {
String msg = String.format("3PARDriver: createVolumeClone Unable to create volume clone name %s for parent base volume id %s whose storage system native id is %s; Error: %s.\n", clone.getDisplayName(), clone.getParentId(), clone.getStorageSystemId(), e.getMessage());
_log.info("createVolumeClone exception message {} ", 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 getVolumeClones.
/**
* Identifying clones of the given parent base volume. NOTE: Intermediate
* physical copies of 3PAR generated from other snapshots/clone are shown as
* clone of base volume itself
*/
public List<VolumeClone> getVolumeClones(StorageVolume volume, Registry registry) {
_log.info("3PARDriver: getVolumeClones Running ");
List<VolumeClone> clones = new ArrayList<>();
try {
Map<String, List<String>> vvolAssociations = registry.getDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, volume.getStorageSystemId() + "____VVOL_ASSOCIATIONS");
_log.debug("vvolAssociations is {}", vvolAssociations.toString());
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(volume.getStorageSystemId(), registry);
// VolumesCommandResult snapsResult =
// hp3parApi.getClonesOfVolume(volume.getNativeId());
ArrayList<String> listOfChildVols = null;
listOfChildVols = (ArrayList<String>) vvolAssociations.get(volume.getNativeId());
for (String childName : listOfChildVols) {
// VolumeDetailsCommandResult is the data structure used for representation of
// the HP3PAR virtual volume
VolumeDetailsCommandResult objClone = hp3parApi.getVolumeDetails(childName);
if (objClone.getCopyType() == copyType.PHYSICAL_COPY.getValue()) {
// VolumeClone is the CoprHD southbound freamework's data
// structure
VolumeClone driverClone = new VolumeClone();
driverClone.setParentId(volume.getNativeId());
driverClone.setNativeId(objClone.getName());
driverClone.setDeviceLabel(objClone.getName());
driverClone.setStorageSystemId(volume.getStorageSystemId());
driverClone.setStoragePoolId(volume.getStoragePoolId());
driverClone.setAccessStatus(StorageObject.AccessStatus.READ_ONLY);
if (volume.getConsistencyGroup() != null) {
driverClone.setConsistencyGroup(volume.getConsistencyGroup());
}
driverClone.setWwn(objClone.getWwn());
driverClone.setThinlyProvisioned(volume.getThinlyProvisioned());
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = objClone.getUserSpace().getReservedMiB();
allocatedCapacity += objClone.getSnapshotSpace().getReservedMiB();
allocatedCapacity += objClone.getAdminSpace().getReservedMiB();
driverClone.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
driverClone.setProvisionedCapacity(objClone.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
driverClone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
clones.add(driverClone);
}
}
_log.info("3PARDriver: getVolumeClones Leaving");
return clones;
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get clone 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();
}
return null;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARProvisioningHelper method createVolumes.
public DriverTask createVolumes(List<StorageVolume> volumes, StorageCapabilities capabilities, DriverTask task, Registry driverRegistry) {
int volumesCreated = 0;
boolean IsDeDupEnabled = false;
// get deduplicationCapability
CommonStorageCapabilities commonCapabilities = capabilities.getCommonCapabilitis();
if (commonCapabilities != null) {
List<DataStorageServiceOption> dataService = commonCapabilities.getDataStorage();
if (dataService != null) {
for (DataStorageServiceOption dataServiceOption : dataService) {
List<CapabilityInstance> capabilityList = dataServiceOption.getCapabilities();
if (capabilityList != null) {
for (CapabilityInstance ci : capabilityList) {
String provTypeValue = ci.getPropertyValue(DeduplicationCapabilityDefinition.PROPERTY_NAME.ENABLED.name());
if (provTypeValue != null && provTypeValue.equalsIgnoreCase(Boolean.TRUE.toString())) {
IsDeDupEnabled = true;
}
}
}
}
}
}
// For each requested volume
for (StorageVolume volume : volumes) {
try {
_log.info("3PARDriver:createVolumes for storage system native id {}, volume name {} - start", volume.getStorageSystemId(), volume.getDisplayName());
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(volume.getStorageSystemId(), driverRegistry);
// Create volume
VolumeDetailsCommandResult volResult = null;
Boolean isThin = volume.getThinlyProvisioned();
if (IsDeDupEnabled) {
isThin = false;
}
hp3parApi.createVolume(volume.getDisplayName(), volume.getStoragePoolId(), isThin, IsDeDupEnabled, volume.getRequestedCapacity() / HP3PARConstants.MEGA_BYTE);
volResult = hp3parApi.getVolumeDetails(volume.getDisplayName());
// Attributes of the volume in array
volume.setProvisionedCapacity(volResult.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = volResult.getUserSpace().getReservedMiB();
allocatedCapacity += volResult.getSnapshotSpace().getReservedMiB();
allocatedCapacity += volResult.getAdminSpace().getReservedMiB();
volume.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
volume.setWwn(volResult.getWwn());
// required for volume delete
volume.setNativeId(volume.getDisplayName());
volume.setDeviceLabel(volume.getDisplayName());
volume.setAccessStatus(AccessStatus.READ_WRITE);
// Update Consistency Group
String volumeCGName = volume.getConsistencyGroup();
if (volumeCGName != null && !volumeCGName.isEmpty()) {
_log.info("3PARDriver:createVolumes Adding volume {} to consistency group {} ", volume.getDisplayName(), volumeCGName);
int addMember = 1;
hp3parApi.updateVVset(volumeCGName, volume.getNativeId(), addMember);
}
volumesCreated++;
_log.info("3PARDriver:createVolumes for storage system native id {}, volume name {} - end", volume.getStorageSystemId(), volume.getDisplayName());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to create volume name %s with pool id %s for storage system native id %s; Error: %s.\n", volume.getDisplayName(), volume.getStoragePoolId(), volume.getStorageSystemId(), e);
_log.error(msg);
_log.error(CompleteError.getStackTrace(e));
task.setMessage(msg);
e.printStackTrace();
}
}
if (volumes.size() != 0) {
if (volumesCreated == volumes.size()) {
task.setMessage("Successful");
task.setStatus(DriverTask.TaskStatus.READY);
} else if (volumesCreated == 0) {
task.setStatus(DriverTask.TaskStatus.FAILED);
} else {
task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
}
}
return task;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARProvisioningHelper method expandVolume.
public DriverTask expandVolume(StorageVolume volume, long newCapacity, DriverTask task, Registry driverRegistry) {
// For this volume
try {
_log.info("3PARDriver:expandVolume for storage system native id {}, volume name {} - start", volume.getStorageSystemId(), volume.getDisplayName());
if (newCapacity < volume.getProvisionedCapacity()) {
throw new HP3PARException("New capacity is less than original capcity");
}
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(volume.getStorageSystemId(), driverRegistry);
// expand volume
Long additionalSize = newCapacity - volume.getProvisionedCapacity();
hp3parApi.expandVolume(volume.getDisplayName(), additionalSize / HP3PARConstants.MEGA_BYTE);
volume.setRequestedCapacity(newCapacity);
// actual size of the volume in array
VolumeDetailsCommandResult volResult = hp3parApi.getVolumeDetails(volume.getDisplayName());
volume.setProvisionedCapacity(volResult.getSizeMiB() * HP3PARConstants.MEGA_BYTE);
// Allocated capacity is the sum of user, snapshot and admin reserved space
Long allocatedCapacity = volResult.getUserSpace().getReservedMiB();
allocatedCapacity += volResult.getSnapshotSpace().getReservedMiB();
allocatedCapacity += volResult.getAdminSpace().getReservedMiB();
volume.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("3PARDriver:expandVolumes for storage system native id {}, volume name {} - end", volume.getStorageSystemId(), volume.getDisplayName());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to expand volume name %s with pool id %s for storage system native id %s; Error: %s.\n", volume.getDisplayName(), volume.getStoragePoolId(), volume.getStorageSystemId(), e);
_log.error(msg);
_log.error(CompleteError.getStackTrace(e));
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.FAILED);
e.printStackTrace();
}
return task;
}
use of com.emc.storageos.hp3par.command.VolumeDetailsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApi method createPhysicalCopy.
/**
* Vipr UI doesn't provide offline (Attached volume) / online options while creating clone, so
* below logic will be followed:
* First, to check destination volume exists we execute create clone creation as offline volume.
* if error, destination clone volume doesn't exist, so create a new volume with clone name by
* using its base volume parameters like TPVV,CPG. Then create a offline
* volume clone using newly created volume clone
* Note: A offline clone creates a attached clone, which actually creates
* a intermediate snapshot which can be utilized for restore/update.
* We are not using online option, as it creates detached volume with no way to restore/update.
*/
public void createPhysicalCopy(String baseVolumeName, String cloneName, String cloneCPG) throws Exception {
_log.info("3PARDriver: createPhysicalCopy enter");
String baseVolumeSnapCPG = cloneCPG;
String baseVolumeUserCPG = cloneCPG;
ClientResponse clientResp = null;
String payload = null;
String secondPayload = null;
// clone creation, check if destination volume exists as expected by this API
payload = "{\"action\":\"createPhysicalCopy\", \"parameters\": { \"destVolume\": \"" + cloneName + "\" , \"saveSnapshot\": " + true + "} }";
final String path = MessageFormat.format(URI_CREATE_VOLUME_CLONE, baseVolumeName);
_log.info(" 3PARDriver: createPhysicalCopy uri = {} payload {} secondPayload {}", path, payload, secondPayload);
try {
// create clone considering destination volume already created
clientResp = post(path, payload);
if (clientResp == null || clientResp.getStatus() != 201) {
if (clientResp != null) {
String errResp = getResponseDetails(clientResp);
_log.info(" 3PARDriver: createPhysicalCopy destination clone volume absent, hence creating new volume for clone. Error Info : {}", errResp);
}
VolumeDetailsCommandResult volResult = null;
try {
volResult = getVolumeDetails(baseVolumeName);
} catch (Exception e) {
_log.info("3PARDriver: createVolumeClone the specified volume {} for clone creation not found, its parent {}; continue with clone creation: {}.\n", baseVolumeName, cloneName, e.getMessage());
}
if (volResult != null) {
// UserCPG will be absent for clones, hence using snapCPG here. We might need to re-look CPG selection later
baseVolumeUserCPG = volResult.getUserCPG();
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(cloneName, baseVolumeSnapCPG, tpvv, tdvv, volResult.getSizeMiB());
try {
volResult = getVolumeDetails(baseVolumeName);
} catch (Exception e) {
_log.info("3PARDriver: createVolumeClone the specified clone volume {} not created successfully yet. error {}", cloneName, e.getMessage());
}
if (volResult != null) {
clientResp = post(path, payload);
} else {
_log.info("3PARDriver: createVolumeClone unable to find the newly created volume, volResult is null");
}
} else {
_log.info("3PARDriver: createVolumeClone base volume not found, volResult is null");
}
}
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);
_log.info("3PARDriver: createPhysicalCopy error resopnse : {} ", errResp);
throw new HP3PARException(errResp);
} else {
_log.info("3PARDriver: createPhysicalCopy success");
}
} catch (Exception e) {
throw e;
} finally {
if (clientResp != null) {
clientResp.close();
}
_log.info("3PARDriver: createPhysicalCopy leave");
}
// end try/catch/finally
}
Aggregations