use of com.emc.storageos.hp3par.command.VolumesCommandResult in project coprhd-controller by CoprHD.
the class HP3PARStorageDriver method getStorageObject.
/*
* objectid is nothing but the native id of the storage object. For
* consistency group it would be the native id of consistency group, which
* on the HP3PAR array is nothing but the name of the volume set.
*/
@Override
public <T extends StorageObject> T getStorageObject(String storageSystemId, String objectId, Class<T> type) {
// TODO Auto-generated method stub
_log.info("3PARDriver: getStorageObject enter ");
try {
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystemId, this.driverRegistry);
ConsistencyGroupResult cgResult = null;
if (VolumeConsistencyGroup.class.getSimpleName().equals(type.getSimpleName())) {
cgResult = hp3parApi.getVVsetDetails(objectId);
VolumeConsistencyGroup cg = new VolumeConsistencyGroup();
cg.setStorageSystemId(storageSystemId);
cg.setNativeId(cgResult.getName());
cg.setDeviceLabel(objectId);
_log.info("3PARDriver: getStorageObject leaving ");
return (T) cg;
} else if (StoragePool.class.getSimpleName().equals(type.getSimpleName())) {
CPGMember cpgResult = null;
cpgResult = hp3parApi.getCPGDetails(objectId);
StoragePool sp = new StoragePool();
String cpgName = cpgResult.getName();
sp.setNativeId(cpgName);
CPGSpaceCommandResult cpgSpaceResult = hp3parApi.getCPGSpaceDetails(cpgName);
// CPG common space is space available to the CPG from the common pool
Long cpgCommonSpace = cpgSpaceResult.getUsableFreeMiB().longValue();
// CPG allocated capacity is what is currently allocated to the CPG
Long cpgAllocatedCapacity = cpgResult.getUsrUsage().getTotalMiB().longValue() + cpgResult.getSAUsage().getTotalMiB().longValue() + cpgResult.getSDUsage().getTotalMiB().longValue();
// CPG used capacity is what is currently used within the CPG
Long cpgUsedCapacity = cpgResult.getUsrUsage().getUsedMiB().longValue() + cpgResult.getSAUsage().getUsedMiB().longValue() + cpgResult.getSDUsage().getUsedMiB().longValue();
// CPG Free capacity is what is currently free within the CPG
Long cpgFreeCapacity = cpgAllocatedCapacity - cpgUsedCapacity;
// CPG total potentially usable capacity is the sum of these two
// Here we are assuming that the CPG can potentially use all of the common capacity
// Although in practice this is shared with all CPGs of the same type
Long cpgTotalCapacity = cpgAllocatedCapacity + cpgCommonSpace;
// We add the common space to the free capacity because it can also be used by the CPG
cpgFreeCapacity += cpgCommonSpace;
sp.setTotalCapacity(cpgTotalCapacity * HP3PARConstants.KILO_BYTE);
sp.setFreeCapacity(cpgFreeCapacity * HP3PARConstants.KILO_BYTE);
VolumesCommandResult volumesOfCpg = hp3parApi.getVolumesofCPG(cpgName);
Long cpgSubscribedCapacity = (long) 0;
Iterator<VolumeDetailsCommandResult> volIter = volumesOfCpg.getMembers().iterator();
while (volIter.hasNext()) {
cpgSubscribedCapacity += volIter.next().getSizeMiB();
}
sp.setSubscribedCapacity(cpgSubscribedCapacity * HP3PARConstants.KILO_BYTE);
_log.info("3PARDriver: For CPG {}:", cpgName);
_log.info("Number of volumes in CPG = {}", volumesOfCpg.getTotal());
_log.info("Total Capacity = {} MB, Subscribed Capacity = {} MB, Free Capacity = {} MB", cpgTotalCapacity, cpgSubscribedCapacity, cpgFreeCapacity);
// Note that subscribed capacity need not be equal to (total - free capacity) for thin pools
_log.info("3PARDriver: StoragePool getStorageObject leaving ");
return (T) sp;
}
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to get Stroage Object for id %s; Error: %s.\n", objectId, e.getMessage());
_log.error(msg);
e.printStackTrace();
_log.error(CompleteError.getStackTrace(e));
return (T) null;
}
return null;
}
use of com.emc.storageos.hp3par.command.VolumesCommandResult 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.VolumesCommandResult in project coprhd-controller by CoprHD.
the class HP3PARStorageDriver method discoverStoragePools.
/**
* Get storage pool information and its capabilities
*/
@Override
public DriverTask discoverStoragePools(StorageSystem storageSystem, List<StoragePool> storagePools) {
// For this 3PAR system
_log.info("3PARDriver: discoverStoragePools information for storage system {}, nativeId {} - start", storageSystem.getIpAddress(), storageSystem.getNativeId());
DriverTask task = createDriverTask(HP3PARConstants.TASK_TYPE_DISCOVER_STORAGE_POOLS);
DeduplicationCapabilityDefinition dedupCapabilityDefinition = new DeduplicationCapabilityDefinition();
try {
// get Api client
HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystem.getNativeId(), this.driverRegistry);
// get storage pool details
CPGCommandResult cpgResult = hp3parApi.getAllCPGDetails();
// for each ViPR Storage pool = 3PAR CPG
for (CPGMember currMember : cpgResult.getMembers()) {
StoragePool pool = new StoragePool();
String cpgName = currMember.getName();
pool.setPoolName(cpgName);
pool.setStorageSystemId(storageSystem.getNativeId());
Set<Protocols> supportedProtocols = new HashSet<>();
supportedProtocols.add(Protocols.iSCSI);
supportedProtocols.add(Protocols.FC);
pool.setProtocols(supportedProtocols);
CPGSpaceCommandResult cpgSpaceResult = hp3parApi.getCPGSpaceDetails(cpgName);
// CPG common space is space available to the CPG from the common pool
Long cpgCommonSpace = cpgSpaceResult.getUsableFreeMiB().longValue();
// CPG allocated capacity is what is currently allocated to the CPG
Long cpgAllocatedCapacity = currMember.getUsrUsage().getTotalMiB().longValue() + currMember.getSAUsage().getTotalMiB().longValue() + currMember.getSDUsage().getTotalMiB().longValue();
// CPG used capacity is what is currently used within the CPG
Long cpgUsedCapacity = currMember.getUsrUsage().getUsedMiB().longValue() + currMember.getSAUsage().getUsedMiB().longValue() + currMember.getSDUsage().getUsedMiB().longValue();
// CPG Free capacity is what is currently free within the CPG
Long cpgFreeCapacity = cpgAllocatedCapacity - cpgUsedCapacity;
// CPG total potentially usable capacity is the sum of these two
// Here we are assuming that the CPG can potentially use all of the common capacity
// Although in practice this is shared with all CPGs of the same type
Long cpgTotalCapacity = cpgAllocatedCapacity + cpgCommonSpace;
// We add the common space to the free capacity because it can also be used by the CPG
cpgFreeCapacity += cpgCommonSpace;
pool.setTotalCapacity(cpgTotalCapacity * HP3PARConstants.KILO_BYTE);
pool.setFreeCapacity(cpgFreeCapacity * HP3PARConstants.KILO_BYTE);
VolumesCommandResult volumesOfCpg = hp3parApi.getVolumesofCPG(cpgName);
Long cpgSubscribedCapacity = (long) 0;
Iterator<VolumeDetailsCommandResult> volIter = volumesOfCpg.getMembers().iterator();
while (volIter.hasNext()) {
cpgSubscribedCapacity += volIter.next().getSizeMiB();
}
pool.setSubscribedCapacity(cpgSubscribedCapacity * HP3PARConstants.KILO_BYTE);
_log.info("3PARDriver: For CPG {}:", cpgName);
_log.info("Number of volumes in CPG = {}", volumesOfCpg.getTotal());
_log.info("Total Capacity = {} MB, Subscribed Capacity = {} MB, Free Capacity = {} MB", cpgTotalCapacity, cpgSubscribedCapacity, cpgFreeCapacity);
// Note that subscribed capacity need not be equal to (total - free capacity) for thin pools
pool.setOperationalStatus(currMember.getState() == 1 ? PoolOperationalStatus.READY : PoolOperationalStatus.NOTREADY);
Set<RaidLevels> supportedRaidLevels = new HashSet<>();
switch(currMember.getSDGrowth().getLDLayout().getRAIDType()) {
case 1:
supportedRaidLevels.add(RaidLevels.RAID0);
break;
case 2:
supportedRaidLevels.add(RaidLevels.RAID1);
break;
case 3:
supportedRaidLevels.add(RaidLevels.RAID5);
break;
case 4:
supportedRaidLevels.add(RaidLevels.RAID6);
break;
}
pool.setSupportedRaidLevels(supportedRaidLevels);
if (currMember.getSDGrowth().getLDLayout().getDiskPatterns() == null) {
_log.warn("3PARDriver: Neglecting storage pool {} as there is no disk associated with it", currMember.getName());
continue;
}
Set<SupportedDriveTypes> supportedDriveTypes = new HashSet<>();
for (int j = 0; j < currMember.getSDGrowth().getLDLayout().getDiskPatterns().size(); j++) {
switch(currMember.getSDGrowth().getLDLayout().getDiskPatterns().get(j).getDiskType()) {
case 1:
supportedDriveTypes.add(SupportedDriveTypes.FC);
break;
case 2:
supportedDriveTypes.add(SupportedDriveTypes.NL_SAS);
break;
case 3:
supportedDriveTypes.add(SupportedDriveTypes.SSD);
break;
}
}
pool.setSupportedDriveTypes(supportedDriveTypes);
pool.setMaximumThinVolumeSize(16 * HP3PARConstants.MEGA_BYTE);
pool.setMinimumThinVolumeSize(256 * HP3PARConstants.KILO_BYTE);
pool.setMaximumThickVolumeSize(16 * HP3PARConstants.MEGA_BYTE);
pool.setMinimumThickVolumeSize(256 * HP3PARConstants.KILO_BYTE);
pool.setSupportedResourceType(SupportedResourceType.THIN_AND_THICK);
pool.setPoolServiceType(PoolServiceType.block);
// Storage object properties
// SB SDK is not sending pool name in volume creation
pool.setNativeId(currMember.getName());
pool.setDeviceLabel(currMember.getName());
pool.setDisplayName(currMember.getName());
storageSystem.setAccessStatus(AccessStatus.READ_WRITE);
// SDK requires initialization
List<CapabilityInstance> capabilities = new ArrayList<>();
// setting appropriate capability for dedup supported pool
if (currMember.isDedupCapable()) {
Boolean dedupEnabled = true;
Map<String, List<String>> props = new HashMap<>();
props.put(DeduplicationCapabilityDefinition.PROPERTY_NAME.ENABLED.name(), Arrays.asList(dedupEnabled.toString()));
CapabilityInstance capabilityInstance = new CapabilityInstance(dedupCapabilityDefinition.getId(), dedupCapabilityDefinition.getId(), props);
capabilities.add(capabilityInstance);
}
pool.setCapabilities(capabilities);
_log.info("3PARDriver: added storage pool {}, native id {}", pool.getPoolName(), pool.getNativeId());
storagePools.add(pool);
}
// for each storage pool
task.setStatus(DriverTask.TaskStatus.READY);
_log.info("3PARDriver: discoverStoragePools information for storage system {}, nativeId {} - end", storageSystem.getIpAddress(), storageSystem.getNativeId());
} catch (Exception e) {
String msg = String.format("3PARDriver: Unable to discover the storage pool information for storage system %s native id %s; Error: %s.\n", storageSystem.getSystemName(), storageSystem.getNativeId(), 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.VolumesCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApi method getVolumesofCPG.
public VolumesCommandResult getVolumesofCPG(String cpgName) throws Exception {
_log.info("3PARDriver:getVolumesOfCPG enter");
ClientResponse clientResp = null;
final String path = MessageFormat.format(URI_VOLUMES_OF_CPG, cpgName);
try {
clientResp = get(path);
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() != 200) {
String errResp = getResponseDetails(clientResp);
throw new HP3PARException(errResp);
} else {
String responseString = clientResp.getEntity(String.class);
_log.info("3PARDriver:getVolumesOfCPG 3PAR response is {}", responseString);
VolumesCommandResult storageVolsResult = new Gson().fromJson(sanitize(responseString), VolumesCommandResult.class);
return storageVolsResult;
}
} catch (Exception e) {
throw e;
} finally {
if (clientResp != null) {
clientResp.close();
}
_log.info("3PARDriver:getVolumesOfCPG leave");
}
// end try/catch/finally
}
use of com.emc.storageos.hp3par.command.VolumesCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApi method getStorageVolumes.
public VolumesCommandResult getStorageVolumes() throws Exception {
_log.info("3PARDriver:getVolumeDetails enter");
ClientResponse clientResp = null;
final String path = URI_STORAGE_VOLUMES;
try {
clientResp = get(path);
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() != 200) {
String errResp = getResponseDetails(clientResp);
throw new HP3PARException(errResp);
} else {
String responseString = clientResp.getEntity(String.class);
_log.info("3PARDriver:getVolumeDetails 3PAR response is {}", responseString);
VolumesCommandResult storageVolsResult = new Gson().fromJson(sanitize(responseString), VolumesCommandResult.class);
return storageVolsResult;
}
} catch (Exception e) {
throw e;
} finally {
if (clientResp != null) {
clientResp.close();
}
_log.info("3PARDriver:getVolumeDetails leave");
}
// end try/catch/finally
}
Aggregations