Search in sources :

Example 1 with CommonStorageCapabilities

use of com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities 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);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) HashMap(java.util.HashMap) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) CapabilityInstance(com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance) DataStorageServiceOption(com.emc.storageos.storagedriver.storagecapabilities.DataStorageServiceOption) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AutoTieringPolicyCapabilityDefinition(com.emc.storageos.storagedriver.storagecapabilities.AutoTieringPolicyCapabilityDefinition)

Example 2 with CommonStorageCapabilities

use of com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities 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;
}
Also used : CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) DataStorageServiceOption(com.emc.storageos.storagedriver.storagecapabilities.DataStorageServiceOption) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) CapabilityInstance(com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance)

Example 3 with CommonStorageCapabilities

use of com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method prepareCapabilities.

private void prepareCapabilities(ExportPathParams pathParams, StorageCapabilities capabilities) {
    ExportPathsServiceOption numPath = new ExportPathsServiceOption(pathParams.getMinPaths(), pathParams.getMaxPaths());
    List<ExportPathsServiceOption> exportPathParams = new ArrayList<>();
    exportPathParams.add(numPath);
    CommonStorageCapabilities commonCapabilities = new CommonStorageCapabilities();
    commonCapabilities.setExportPathParams(exportPathParams);
    capabilities.setCommonCapabilitis(commonCapabilities);
}
Also used : ExportPathsServiceOption(com.emc.storageos.storagedriver.storagecapabilities.ExportPathsServiceOption) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) ArrayList(java.util.ArrayList)

Example 4 with CommonStorageCapabilities

use of com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities in project coprhd-controller by CoprHD.

the class ExternalDeviceExportOperations method prepareCapabilitiesForAddInitiators.

private void prepareCapabilitiesForAddInitiators(ExportPathParams pathParams, StringSetMap existingZoningMap, URI varrayURI, List<com.emc.storageos.db.client.model.Initiator> initiators, StorageCapabilities capabilities) {
    int driverMaxPath;
    StringSetMap zoningMap = new StringSetMap();
    // Calculate existing paths (without new initiators).
    int existingPaths = 0;
    List<URI> initiatorUris = URIUtil.toUris(initiators);
    for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : existingZoningMap.entrySet()) {
        if (!initiatorUris.contains(URIUtil.uri(entry.getKey()))) {
            zoningMap.put(entry.getKey(), entry.getValue());
        }
    }
    Map<com.emc.storageos.db.client.model.Initiator, List<com.emc.storageos.db.client.model.StoragePort>> assignments = blockScheduler.generateInitiatorsToStoragePortsMap(zoningMap, varrayURI);
    existingPaths = assignments.values().size();
    log.info("Existing path number in the export mask is {}", existingPaths);
    // Otherwise we allocate the difference between max paths and existing paths
    if (existingPaths + pathParams.getPathsPerInitiator() > pathParams.getMaxPaths()) {
        // we always need at least path-per-initiator ports
        driverMaxPath = pathParams.getPathsPerInitiator();
    } else {
        driverMaxPath = pathParams.getMaxPaths() - existingPaths;
    }
    // We assume that masking view meets min path before new initiators are added. We pass ppi as a minPath
    // to driver, so we can zone at least one new initiator.
    ExportPathsServiceOption numPath = new ExportPathsServiceOption(pathParams.getPathsPerInitiator(), driverMaxPath);
    List<ExportPathsServiceOption> exportPathParams = new ArrayList<>();
    exportPathParams.add(numPath);
    CommonStorageCapabilities commonCapabilities = new CommonStorageCapabilities();
    commonCapabilities.setExportPathParams(exportPathParams);
    capabilities.setCommonCapabilitis(commonCapabilities);
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportPathsServiceOption(com.emc.storageos.storagedriver.storagecapabilities.ExportPathsServiceOption) Initiator(com.emc.storageos.storagedriver.model.Initiator) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 5 with CommonStorageCapabilities

use of com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method addDeduplicationCapability.

/**
 * Create deduplication capability and add it to the passed
 * storage capabilities
 *
 * @param storageCapabilities reference to storage capbilities
 * @param deduplication indicates if deduplication is required
 */
private void addDeduplicationCapability(StorageCapabilities storageCapabilities, Boolean deduplication) {
    if (deduplication) {
        // Create the deduplicated capability.
        DeduplicationCapabilityDefinition capabilityDefinition = new DeduplicationCapabilityDefinition();
        Map<String, List<String>> capabilityProperties = new HashMap<>();
        capabilityProperties.put(DeduplicationCapabilityDefinition.PROPERTY_NAME.ENABLED.name(), Collections.singletonList(Boolean.TRUE.toString()));
        CapabilityInstance dedupCapability = new CapabilityInstance(capabilityDefinition.getId(), capabilityDefinition.getId(), 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 auto tiering policy capability
        // and add it to the list.
        DataStorageServiceOption dataStorageSvcOption = new DataStorageServiceOption(Collections.singletonList(dedupCapability));
        dataStorageSvcOptions.add(dataStorageSvcOption);
    }
}
Also used : HashMap(java.util.HashMap) DeduplicationCapabilityDefinition(com.emc.storageos.storagedriver.storagecapabilities.DeduplicationCapabilityDefinition) CommonStorageCapabilities(com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities) CapabilityInstance(com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance) DataStorageServiceOption(com.emc.storageos.storagedriver.storagecapabilities.DataStorageServiceOption) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

CommonStorageCapabilities (com.emc.storageos.storagedriver.storagecapabilities.CommonStorageCapabilities)5 ArrayList (java.util.ArrayList)4 CapabilityInstance (com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance)3 DataStorageServiceOption (com.emc.storageos.storagedriver.storagecapabilities.DataStorageServiceOption)3 HashMap (java.util.HashMap)3 List (java.util.List)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ExportPathsServiceOption (com.emc.storageos.storagedriver.storagecapabilities.ExportPathsServiceOption)2 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)1 AutoTieringPolicy (com.emc.storageos.db.client.model.AutoTieringPolicy)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 VolumeDetailsCommandResult (com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)1 Initiator (com.emc.storageos.storagedriver.model.Initiator)1 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)1 AutoTieringPolicyCapabilityDefinition (com.emc.storageos.storagedriver.storagecapabilities.AutoTieringPolicyCapabilityDefinition)1 DeduplicationCapabilityDefinition (com.emc.storageos.storagedriver.storagecapabilities.DeduplicationCapabilityDefinition)1 URI (java.net.URI)1 Map (java.util.Map)1