Search in sources :

Example 96 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class ReplicationUtils method deleteReplicationGroup.

/**
 * Deletes a replication group
 *
 * @param storage StorageSystem
 * @param groupName replication group to be deleted
 * @param dbClient
 * @param helper
 * @param cimPath
 *
 * @throws DeviceControllerException
 */
public static void deleteReplicationGroup(final StorageSystem storage, final String groupName, final DbClient dbClient, final SmisCommandHelper helper, final CIMObjectPathFactory cimPath) {
    try {
        CIMObjectPath cgPath = cimPath.getReplicationGroupPath(storage, groupName);
        CIMObjectPath replicationSvc = cimPath.getControllerReplicationSvcPath(storage);
        CIMInstance cgPathInstance = helper.checkExists(storage, cgPath, false, false);
        if (cgPathInstance != null) {
            // Invoke the deletion of the consistency group
            CIMArgument[] inArgs = helper.getDeleteReplicationGroupInputArguments(storage, groupName);
            helper.invokeMethod(storage, replicationSvc, SmisConstants.DELETE_GROUP, inArgs, new CIMArgument[5]);
        }
    } catch (Exception e) {
        _log.error("Failed to delete replication group: ", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 97 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxExportOperations method addVolumesToParkingStorageGroup.

/**
 * This method is used for VMAX3 to add volumes to parking storage group
 * once volumes are unexported.
 * For volumes which are still part of another export and if they already
 * belong to FAST managed storage group, they won't be added to parking storage group.
 *
 * @param storage
 * @param policyName
 * @param volumeDeviceIds
 * @throws Exception
 */
private void addVolumesToParkingStorageGroup(StorageSystem storage, String policyName, Set<String> volumeDeviceIds) throws Exception {
    // Don't add volumes to parking SLO which are already part of a FAST managed storage group
    volumeDeviceIds = _helper.filterVolumesPartOfAnyFASTStorageGroup(storage, volumeDeviceIds);
    if (!volumeDeviceIds.isEmpty() && !Constants.NONE.equalsIgnoreCase(policyName)) {
        String[] tokens = policyName.split(Constants.SMIS_PLUS_REGEX);
        CIMObjectPath groupPath = _helper.getVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        if (groupPath == null) {
            groupPath = _helper.createVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        }
        CIMArgument[] inArgs = _helper.getAddVolumesToMaskingGroupInputArguments(storage, groupPath, volumeDeviceIds);
        CIMArgument[] outArgs = new CIMArgument[5];
        SmisJob addVolumesToSGJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.ADD_MEMBERS);
        _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "AddMembers", inArgs, outArgs, addVolumesToSGJob);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) CIMArgument(javax.cim.CIMArgument)

Example 98 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxExportOperations method removeVolumesFromPhantomStorageGroup.

/**
 * Removes the volumes from any phantom storage group.
 *
 * Determine if the volumes are associated with any phantom storage groups.
 * If so, we need to remove volumes from those storage groups and potentially remove them.
 */
private void removeVolumesFromPhantomStorageGroup(StorageSystem storage, WBEMClient client, URI exportMaskURI, List<URI> volumeURIList, String childGroupName, boolean forceFlag) throws Exception {
    CloseableIterator<CIMObjectPath> volumePathItr = null;
    try {
        Map<StorageGroupPolicyLimitsParam, List<URI>> policyVolumeMap = _helper.groupVolumesBasedOnFastPolicy(storage, volumeURIList);
        for (StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam : policyVolumeMap.keySet()) {
            if (!_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                continue;
            }
            _log.info("Checking if volumes are associated with phantom storage groups with policy name: " + storageGroupPolicyLimitsParam);
            // See if there's a phantom group with this policy
            List<String> storageGroupNames = _helper.findPhantomStorageGroupAssociatedWithFastPolicy(storage, storageGroupPolicyLimitsParam);
            // We found a phantom storage group
            if (storageGroupNames != null) {
                for (String storageGroupName : storageGroupNames) {
                    List<URI> volumesToRemove = new ArrayList<URI>();
                    List<Volume> volumes = _dbClient.queryObject(Volume.class, policyVolumeMap.get(storageGroupPolicyLimitsParam));
                    // Get the volumes associated with this storage group. Match up with our volumes.
                    volumePathItr = _helper.getAssociatorNames(storage, _cimPath.getStorageGroupObjectPath(storageGroupName, storage), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
                    while (volumePathItr.hasNext()) {
                        CIMObjectPath volumePath = volumePathItr.next();
                        for (Volume volume : volumes) {
                            if (volume.getNativeGuid().equalsIgnoreCase(_helper.getVolumeNativeGuid(volumePath))) {
                                _log.info("Found volume " + volume.getLabel() + " is in phantom storage group " + storageGroupName);
                                volumesToRemove.add(volume.getId());
                            }
                        }
                    }
                    // Check to see if the volumes are associated with other non-fast, non-cascading masking views.
                    // If so, we should not remove that volume from the phantom storage group because another view
                    // is relying on
                    // it being there.
                    List<URI> inMoreViewsVolumes = new ArrayList<URI>();
                    for (URI volumeToRemove : volumesToRemove) {
                        if (_helper.isPhantomVolumeInMultipleMaskingViews(storage, volumeToRemove, childGroupName)) {
                            Volume volume = _dbClient.queryObject(Volume.class, volumeToRemove);
                            _log.info("Volume " + volume.getLabel() + " is in other masking views, so we will not remove it from storage group " + storageGroupName);
                            inMoreViewsVolumes.add(volume.getId());
                        }
                    }
                    volumesToRemove.removeAll(inMoreViewsVolumes);
                    // from the phantom storage group.
                    if (!volumesToRemove.isEmpty()) {
                        _log.info(String.format("Going to remove volumes %s from phantom storage group %s", Joiner.on("\t").join(volumesToRemove), storageGroupName));
                        Map<String, List<URI>> phantomGroupVolumeMap = _helper.groupVolumesBasedOnExistingGroups(storage, storageGroupName, volumesToRemove);
                        if (phantomGroupVolumeMap != null && phantomGroupVolumeMap.get(storageGroupName) != null && phantomGroupVolumeMap.get(storageGroupName).size() == volumesToRemove.size() && !_helper.isStorageGroupSizeGreaterThanGivenVolumes(storageGroupName, storage, volumesToRemove.size())) {
                            _log.info("Storage Group has no more than {} volumes", volumesToRemove.size());
                            URI blockURI = volumesToRemove.get(0);
                            BlockObject blockObj = BlockObject.fetch(_dbClient, blockURI);
                            CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, storageGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                            String foundPolicyName = ControllerUtils.getAutoTieringPolicyName(blockObj.getId(), _dbClient);
                            if (_helper.isFastPolicy(foundPolicyName) && storageGroupPolicyLimitsParam.getAutoTierPolicyName().equalsIgnoreCase(foundPolicyName)) {
                                _log.info("Storage Group {} contains only 1 volume, so this group will be disassociated from FAST because group can not be deleted if associated with FAST", storageGroupName);
                                _helper.removeVolumeGroupFromPolicyAndLimitsAssociation(client, storage, maskingGroupPath);
                            }
                        }
                        // Create a relatively empty completer associated with the export mask. We don't have the
                        // export group
                        // at this level, so there's nothing decent to attach the completer to anyway.
                        String task = UUID.randomUUID().toString();
                        ExportMaskVolumeToStorageGroupCompleter completer = new ExportMaskVolumeToStorageGroupCompleter(null, exportMaskURI, task);
                        List<URI> volumesInSG = _helper.findVolumesInStorageGroup(storage, storageGroupName, volumesToRemove);
                        List<CIMObjectPath> volumePaths = new ArrayList<CIMObjectPath>();
                        // Remove the found volumes from the phantom storage group
                        if (volumesInSG != null && !volumesInSG.isEmpty()) {
                            CIMArgument[] inArgs = _helper.getRemoveVolumesFromMaskingGroupInputArguments(storage, storageGroupName, volumesInSG, forceFlag);
                            CIMArgument[] outArgs = new CIMArgument[5];
                            _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "RemoveMembers", inArgs, outArgs, new SmisMaskingViewRemoveVolumeJob(null, storage.getId(), volumePaths, null, storageGroupName, _cimPath, completer));
                        }
                    }
                }
            }
        }
    } finally {
        if (volumePathItr != null) {
            volumePathItr.close();
        }
    }
}
Also used : SmisMaskingViewRemoveVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisMaskingViewRemoveVolumeJob) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportMaskVolumeToStorageGroupCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskVolumeToStorageGroupCompleter) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 99 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxExportOperations method createCascadedVolumeGroup.

private CIMObjectPath createCascadedVolumeGroup(StorageSystem storage, String groupName, List<CIMObjectPath> volumeGroupPaths, TaskCompleter taskCompleter) throws Exception {
    _log.debug("{} createCascadedVolumeGroup START...", storage.getSerialNumber());
    CIMObjectPath cascadedVolumeGroupObjectPath = null;
    CIMObjectPath[] volumePaths = new CIMObjectPath[volumeGroupPaths.size()];
    CIMArgument[] inArgs = _helper.getCascadedStorageGroupInputArguments(storage, groupName, volumeGroupPaths.toArray(volumePaths));
    CIMArgument[] outArgs = new CIMArgument[5];
    _helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), "CreateGroup", inArgs, outArgs);
    cascadedVolumeGroupObjectPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, "MaskingGroup");
    ExportOperationContext.insertContextOperation(taskCompleter, VmaxExportOperationContext.OPERATION_CREATE_CASCADING_STORAGE_GROUP, groupName, volumeGroupPaths);
    _log.debug("{} createCascadedVolumeGroup END...", storage.getSerialNumber());
    return cascadedVolumeGroupObjectPath;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 100 with CIMArgument

use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.

the class VmaxExportOperations method removeStoragePorts.

/**
 * Remove storage ports from the port group.
 *
 * @param storage - Storage system
 * @param exportMaskURI - Export mask URI
 * @param targetURIList - Storage ports to be removed
 * @return - Removed storage ports
 * @throws Exception
 */
private Set<URI> removeStoragePorts(StorageSystem storage, URI exportMaskURI, List<URI> targetURIList) throws Exception {
    _log.info("Removing storage ports...");
    ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
    Set<URI> portsToRemove = new HashSet<URI>();
    CIMInstance portGroupInstance = _helper.getPortGroupInstance(storage, mask.getMaskName());
    if (null == portGroupInstance) {
        String errMsg = String.format("remove storage ports failed - maskName %s : Port group not found ", mask.getMaskName());
        throw DeviceControllerException.exceptions.exportGroupPathAdjustmentError(errMsg);
    }
    String pgGroupName = (String) portGroupInstance.getPropertyValue(SmisConstants.CP_ELEMENT_NAME);
    // Get the current ports off of the storage group; only remove the ones that are there.
    WBEMClient client = _helper.getConnection(storage).getCimClient();
    List<String> storagePorts = _helper.getStoragePortsFromLunMaskingInstance(client, portGroupInstance);
    Set<URI> storagePortURIs = new HashSet<>();
    storagePortURIs.addAll(transform(ExportUtils.storagePortNamesToURIs(_dbClient, storagePorts), CommonTransformerFunctions.FCTN_STRING_TO_URI));
    portsToRemove = intersection(newHashSet(targetURIList), storagePortURIs);
    boolean removingLast = portsToRemove.size() == storagePortURIs.size();
    if (!portsToRemove.isEmpty() && !removingLast) {
        // Going to remove the ports from the port group, checking if the port group is shared with other masking view
        if (_helper.checkPortGroupShared(storage, pgGroupName, mask.getMaskName())) {
            String msg = String.format("The port group %s has other masking view associated, could not remove ports from it", pgGroupName);
            _log.error(msg);
            throw DeviceControllerException.exceptions.exportGroupPathAdjustmentError(msg);
        }
        CIMArgument[] inArgs = _helper.getRemoveTargetPortsFromMaskingGroupInputArguments(storage, pgGroupName, Lists.newArrayList(portsToRemove));
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "RemoveMembers", inArgs, outArgs, null);
    } else if (!removingLast) {
        _log.info(String.format("Target ports already removed fom port group %s, likely by a previous operation.", pgGroupName));
    } else {
        // In this case, some programming, orchestration, or user-fiddling-with-things-outside-of-ViPR situation led
        // us to this scenario. It's best to just print the ports and port group and leave it alone.
        _log.error(String.format("Removing target ports would cause an empty port group %s, which is not allowed on VMAX.  Manual port removal may be required.", pgGroupName));
    // This can lead to an inaccuracy in the ExportMask object, but may be rectified next time it's refreshed.
    }
    return portsToRemove;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMArgument (javax.cim.CIMArgument)234 CIMObjectPath (javax.cim.CIMObjectPath)190 WBEMException (javax.wbem.WBEMException)129 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)127 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)80 ArrayList (java.util.ArrayList)74 CIMInstance (javax.cim.CIMInstance)71 Volume (com.emc.storageos.db.client.model.Volume)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 URI (java.net.URI)39 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)36 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)32 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)26 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)23 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 HashSet (java.util.HashSet)16 List (java.util.List)16 CIMProperty (javax.cim.CIMProperty)16