use of com.emc.storageos.storagedriver.model.StoragePool in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method discoverAutoTieringPoliciesForStoragePool.
/**
* Discovers the auto tiering policies supported by the passed driver storage pool
* and updates the passed auto tiering policy maps.
*
* @param driverStorageSystem A reference to the driver storage system.
* @param storagePool A reference to the driver storage pool.
* @param pool A reference to the controller storage pool representing the driver storage pool.
* @param autoTieringPolicyPoolMap A map of unique policy ids and controller storage pools that support the policy.
* @param autoTieringPolicyPropertiesMap A map of unique policy ids and the policy properties.
*/
private void discoverAutoTieringPoliciesForStoragePool(StorageSystem driverStorageSystem, StoragePool storagePool, com.emc.storageos.db.client.model.StoragePool pool, Map<String, List<com.emc.storageos.db.client.model.StoragePool>> autoTieringPolicyPoolMap, Map<String, Map<String, List<String>>> autoTieringPolicyPropertiesMap) {
// Get the capabilities specified for the storage pool and
// process any auto tiering policy capabilities.
List<CapabilityInstance> capabilities = storagePool.getCapabilities();
if (capabilities == null) {
return;
}
for (CapabilityInstance capability : capabilities) {
// Get the capability definition for the capability.
String capabilityDefinitionUid = capability.getCapabilityDefinitionUid();
if ((capabilityDefinitionUid == null) || (capabilityDefinitionUid.isEmpty())) {
_log.error(String.format("Skipping capability %s with no capability definition UID for storage pool %s on system %s", capability.getName(), storagePool.getNativeId(), driverStorageSystem.getNativeId()));
continue;
}
// Get the capability definition from the map of supported capability definitions.
CapabilityDefinition capabilityDefinition = capabilityDefinitions.get(capabilityDefinitionUid);
if (capabilityDefinition == null) {
_log.info(String.format("Skipping unsupported capability of type %s for storage pool %s on system %s", capabilityDefinitionUid, storagePool.getNativeId(), driverStorageSystem.getNativeId()));
continue;
}
// Handle auto tiering policy capability.
if (AutoTieringPolicyCapabilityDefinition.CAPABILITY_UID.equals(capabilityDefinitionUid)) {
// Get the policy id.
String policyId = capability.getPropertyValue(AutoTieringPolicyCapabilityDefinition.PROPERTY_NAME.POLICY_ID.name());
if (policyId == null) {
_log.error(String.format("Skipping auto tiering policy capability %s with no policy id for storage pool %s on system %s", capability.getName(), storagePool.getNativeId(), driverStorageSystem.getNativeId()));
continue;
}
// Add the pool to the set of storage pools for this auto tiering policy.
if (autoTieringPolicyPoolMap.containsKey(policyId)) {
List<com.emc.storageos.db.client.model.StoragePool> autoTieringPolicyPools = autoTieringPolicyPoolMap.get(policyId);
autoTieringPolicyPools.add(pool);
} else {
List<com.emc.storageos.db.client.model.StoragePool> autoTieringPolicyPools = new ArrayList<>();
autoTieringPolicyPools.add(pool);
autoTieringPolicyPoolMap.put(policyId, autoTieringPolicyPools);
}
// Also, save the properties for this auto tiering policy.
if (!autoTieringPolicyPropertiesMap.containsKey(policyId)) {
autoTieringPolicyPropertiesMap.put(policyId, capability.getProperties());
}
}
}
}
use of com.emc.storageos.storagedriver.model.StoragePool 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.storagedriver.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method getStorageObject.
@Override
public <T extends StorageObject> T getStorageObject(String storageSystemId, String objectId, Class<T> type) {
if (StorageVolume.class.getSimpleName().equals(type.getSimpleName())) {
StorageVolume obj = new StorageVolume();
obj.setAllocatedCapacity(200L);
_log.info("getStorageObject: storage volume allocated capacity: {}", obj.getAllocatedCapacity());
return (T) obj;
} else if (VolumeConsistencyGroup.class.getSimpleName().equals(type.getSimpleName())) {
VolumeConsistencyGroup cg = new VolumeConsistencyGroup();
cg.setStorageSystemId(storageSystemId);
cg.setNativeId(objectId);
cg.setDeviceLabel(objectId);
_log.info("Return volume cg {} from array {}", objectId, storageSystemId);
return (T) cg;
} else if (StoragePool.class.getSimpleName().equals(type.getSimpleName())) {
StoragePool pool = new StoragePool();
// 40 GB
pool.setFreeCapacity(40000000L);
// 10 GB
pool.setSubscribedCapacity(10000000L);
pool.setNativeId(objectId);
pool.setStorageSystemId(storageSystemId);
_log.info("getStorageObject: storage pool free capacity: {}, subscribed capacity: {}", pool.getFreeCapacity(), pool.getSubscribedCapacity());
return (T) pool;
} else {
_log.error("getStorageObject: not supported for type: {}", type.getSimpleName());
return null;
}
}
use of com.emc.storageos.storagedriver.model.StoragePool in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method discoverStoragePools.
private List<com.emc.storageos.db.client.model.StoragePool> discoverStoragePools(DiscoveryDriver driver, AccessProfile accessProfile) throws BaseCollectionException {
// Discover storage pools and associated auto tiering policies.
List<StoragePool> driverStoragePools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> allPools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> newPools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> existingPools = new ArrayList<>();
Map<String, List<com.emc.storageos.db.client.model.StoragePool>> autoTieringPolicyPoolMap = new HashMap<>();
Map<String, Map<String, List<String>>> autoTieringPolicyPropertiesMap = new HashMap<>();
com.emc.storageos.db.client.model.StorageSystem storageSystem = _dbClient.queryObject(com.emc.storageos.db.client.model.StorageSystem.class, accessProfile.getSystemId());
URI storageSystemId = storageSystem.getId();
StorageSystem driverStorageSystem = initStorageSystem(storageSystem);
try {
_log.info("discoverPools for storage system {} - start", storageSystemId);
DriverTask task = driver.discoverStoragePools(driverStorageSystem, driverStoragePools);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
// discovery completed
for (StoragePool storagePool : driverStoragePools) {
com.emc.storageos.db.client.model.StoragePool pool;
// Check if this storage pool was already discovered
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, storagePool.getNativeId(), NativeGUIDGenerator.POOL);
List<com.emc.storageos.db.client.model.StoragePool> pools = queryActiveResourcesByAltId(_dbClient, com.emc.storageos.db.client.model.StoragePool.class, "nativeGuid", poolNativeGuid);
if (pools.isEmpty()) {
_log.info("Pool {} is new, native GUID {}", storagePool.getNativeId(), poolNativeGuid);
pool = new com.emc.storageos.db.client.model.StoragePool();
pool.setId(URIUtil.createId(com.emc.storageos.db.client.model.StoragePool.class));
pool.setIsDriverManaged(true);
pool.setStorageDevice(accessProfile.getSystemId());
pool.setNativeId(storagePool.getNativeId());
pool.setNativeGuid(poolNativeGuid);
pool.setPoolName(storagePool.getPoolName());
pool.addProtocols(storagePool.getProtocols());
pool.setPoolServiceType(storagePool.getPoolServiceType());
pool.setCompatibilityStatus(storageSystem.getCompatibilityStatus());
if (storagePool.getMaximumThickVolumeSize() != null) {
pool.setMaximumThickVolumeSize(storagePool.getMaximumThickVolumeSize());
} else {
pool.setMaximumThickVolumeSize(Long.MAX_VALUE);
}
if (storagePool.getMinimumThickVolumeSize() != null) {
pool.setMinimumThickVolumeSize(storagePool.getMinimumThickVolumeSize());
} else {
pool.setMinimumThickVolumeSize(0L);
}
if (storagePool.getMaximumThinVolumeSize() != null) {
pool.setMaximumThinVolumeSize(storagePool.getMaximumThinVolumeSize());
} else {
pool.setMaximumThinVolumeSize(Long.MAX_VALUE);
}
if (storagePool.getMinimumThinVolumeSize() != null) {
pool.setMinimumThinVolumeSize(storagePool.getMinimumThinVolumeSize());
} else {
pool.setMinimumThinVolumeSize(0L);
}
pool.setSupportedResourceTypes(storagePool.getSupportedResourceType());
pool.setInactive(false);
newPools.add(pool);
} else if (pools.size() == 1) {
_log.info("Pool {} was previously discovered, native GUID {}", storagePool.getNativeId(), poolNativeGuid);
pool = pools.get(0);
existingPools.add(pool);
} else {
_log.warn(String.format("There are %d StoragePools with nativeGuid = %s", pools.size(), poolNativeGuid));
continue;
}
// applicable to new and existing storage pools
pool.setSubscribedCapacity(storagePool.getSubscribedCapacity());
pool.setFreeCapacity(storagePool.getFreeCapacity());
pool.setTotalCapacity(storagePool.getTotalCapacity());
pool.setOperationalStatus(storagePool.getOperationalStatus());
pool.addDriveTypes(storagePool.getSupportedDriveTypes());
pool.addSupportedRaidLevels(storagePool.getSupportedRaidLevels());
pool.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
// Discover the auto tiering policies supported by the storage pool.
discoverAutoTieringPoliciesForStoragePool(driverStorageSystem, storagePool, pool, autoTieringPolicyPoolMap, autoTieringPolicyPropertiesMap);
// Discover deduplication capability for storage pool.
discoverDeduplicationCapabilityForStoragePool(driverStorageSystem, storagePool, pool);
}
// Now that all storage pools have been process we can create or update
// as necessary the auto tiering policy instances in the controller.
createOrUpdateAutoTierPolicies(storageSystem, autoTieringPolicyPoolMap, autoTieringPolicyPropertiesMap);
_log.info("No of newly discovered pools {}", newPools.size());
_log.info("No of existing discovered pools {}", existingPools.size());
_dbClient.createObject(newPools);
_dbClient.updateObject(existingPools);
allPools.addAll(newPools);
allPools.addAll(existingPools);
} else {
String errorMsg = String.format("Failed to discover storage pools for system %s of type %s . \n" + " Driver task message: %s", accessProfile.getSystemId(), accessProfile.getSystemType(), task.getMessage());
storageSystem.setLastDiscoveryStatusMessage(errorMsg);
throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
}
String message = String.format("Storage pools of storage array %s with native id %s were discovered successfully.", storageSystem.getId(), storageSystem.getNativeGuid());
_log.info(message);
return allPools;
} catch (Exception e) {
String message = String.format("Failed to discover storage pools of storage array %s with native id %s : %s .", storageSystem.getId(), storageSystem.getNativeGuid(), e.getMessage());
_log.error(message, e);
storageSystem.setLastDiscoveryStatusMessage(message);
throw e;
} finally {
_dbClient.updateObject(storageSystem);
_log.info("Discovery of storage pools of storage system {} of type {} - end", accessProfile.getSystemId(), accessProfile.getSystemType());
}
}
use of com.emc.storageos.storagedriver.model.StoragePool 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;
}
Aggregations