use of com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method addAutoTieringPolicyCapability.
/**
* Create the auto tiering policy capability and add it to the passed
* storage capabilities
*
* @param storageCapabilities A reference to all storage capabilities.
* @param autoTieringPolicyURI The URI of the AutoTieringPolicy or null.
*/
private void addAutoTieringPolicyCapability(StorageCapabilities storageCapabilities, URI autoTieringPolicyURI) {
if (!NullColumnValueGetter.isNullURI(autoTieringPolicyURI)) {
AutoTieringPolicy autoTieringPolicy = dbClient.queryObject(AutoTieringPolicy.class, autoTieringPolicyURI);
if (autoTieringPolicy == null) {
throw DeviceControllerException.exceptions.objectNotFound(autoTieringPolicyURI);
}
// Create the auto tiering policy capability.
AutoTieringPolicyCapabilityDefinition capabilityDefinition = new AutoTieringPolicyCapabilityDefinition();
Map<String, List<String>> capabilityProperties = new HashMap<>();
capabilityProperties.put(AutoTieringPolicyCapabilityDefinition.PROPERTY_NAME.POLICY_ID.name(), Arrays.asList(autoTieringPolicy.getPolicyName()));
capabilityProperties.put(AutoTieringPolicyCapabilityDefinition.PROPERTY_NAME.PROVISIONING_TYPE.name(), Arrays.asList(autoTieringPolicy.getProvisioningType()));
CapabilityInstance autoTieringCapability = new CapabilityInstance(capabilityDefinition.getId(), autoTieringPolicy.getPolicyName(), capabilityProperties);
// Get the common capabilities for the passed storage capabilities.
// If null, create and set it.
CommonStorageCapabilities commonCapabilities = storageCapabilities.getCommonCapabilitis();
if (commonCapabilities == null) {
commonCapabilities = new CommonStorageCapabilities();
storageCapabilities.setCommonCapabilitis(commonCapabilities);
}
// Get the data storage service options for the common capabilities.
// If null, create it and set it.
List<DataStorageServiceOption> dataStorageSvcOptions = commonCapabilities.getDataStorage();
if (dataStorageSvcOptions == null) {
dataStorageSvcOptions = new ArrayList<>();
commonCapabilities.setDataStorage(dataStorageSvcOptions);
}
// Create a new data storage service option for the AutoTiering policy capability
// and add it to the list.
DataStorageServiceOption dataStorageSvcOption = new DataStorageServiceOption(Arrays.asList(autoTieringCapability));
dataStorageSvcOptions.add(dataStorageSvcOption);
}
}
use of com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance 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.storagecapabilities.CapabilityInstance 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.storagedriver.storagecapabilities.CapabilityInstance in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method discoverDeduplicationCapabilityForStoragePool.
/**
* Discover deduplication capability for storage pool.
* If driver does not report "deduplication" for storage pool, we assume that deduplication is disabled.
* If driver reports "deduplication" for storage pool, we assume that it is enabled, unless its ENABLED property is set to false.
*
* @param driverStorageSystem A reference to the driver storage system.
* @param driverPool A reference to the driver storage pool.
* @param dbPool A reference to the system storage pool representing the driver storage pool.
*/
private void discoverDeduplicationCapabilityForStoragePool(StorageSystem driverStorageSystem, StoragePool driverPool, com.emc.storageos.db.client.model.StoragePool dbPool) {
// Get the capabilities specified for the storage pool and
// process and process deduplication capability if reported by driver
List<CapabilityInstance> capabilities = driverPool.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(), driverPool.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, driverPool.getNativeId(), driverStorageSystem.getNativeId()));
continue;
}
if (DeduplicationCapabilityDefinition.CAPABILITY_UID.equals(capabilityDefinitionUid)) {
// Handle dedup capability.
// Check if dedup is enabled; we assume that if driver reports deduplication in pool capabilities,
// it is enabled by default, unless it is explicitly disabled.
String isEnabled = capability.getPropertyValue(DeduplicationCapabilityDefinition.PROPERTY_NAME.ENABLED.name());
if (isEnabled != null && isEnabled.equalsIgnoreCase("false")) {
_log.info(String.format("StoragePool %s of storage system %s has deduplication disabled", driverPool.getNativeId(), driverStorageSystem.getNativeId()));
dbPool.setDedupCapable(false);
} else {
_log.info(String.format("Enable deduplication for StoragePool %s of storage system %s ", driverPool.getNativeId(), driverStorageSystem.getNativeId()));
dbPool.setDedupCapable(true);
}
}
}
}
use of com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance 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