Search in sources :

Example 1 with StorageDriverManager

use of com.emc.storageos.services.util.StorageDriverManager in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method updateConsistencyGroup.

/**
 * Update the specified consistency group
 *
 * @prereq none
 *
 * @param id the URN of a ViPR Consistency group
 *
 * @brief Update consistency group
 * @return TaskResourceRep
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateConsistencyGroup(@PathParam("id") final URI id, final BlockConsistencyGroupUpdate param) {
    // Get the consistency group.
    BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
    StorageDriverManager storageDriverManager = (StorageDriverManager) StorageDriverManager.getApplicationContext().getBean(StorageDriverManager.STORAGE_DRIVER_MANAGER);
    // Verify a volume was specified to be added or removed.
    if (!param.hasEitherAddOrRemoveVolumes()) {
        throw APIException.badRequests.noVolumesToBeAddedRemovedFromCG();
    }
    // TODO require a check if requested list contains all volumes/replicas?
    // For replicas, check replica count with volume count in CG
    StorageSystem cgStorageSystem = null;
    // Throw exception if the operation is attempted on volumes that are in RP CG.
    if (consistencyGroup.isRPProtectedCG()) {
        throw APIException.badRequests.operationNotAllowedOnRPVolumes();
    }
    // This method also supports adding volumes or replicas to CG (VMAX - SMIS 8.0.x)
    if ((!consistencyGroup.created() || NullColumnValueGetter.isNullURI(consistencyGroup.getStorageController())) && param.hasVolumesToAdd()) {
        // we just need to check the case of add volumes in this case
        BlockObject bo = BlockObject.fetch(_dbClient, param.getAddVolumesList().getVolumes().get(0));
        cgStorageSystem = _permissionsHelper.getObjectById(bo.getStorageController(), StorageSystem.class);
    } else {
        cgStorageSystem = _permissionsHelper.getObjectById(consistencyGroup.getStorageController(), StorageSystem.class);
    }
    // IBMXIV, XtremIO, VPlex, VNX, ScaleIO, and VMax volumes only
    String systemType = cgStorageSystem.getSystemType();
    if (!storageDriverManager.isDriverManaged(cgStorageSystem.getSystemType())) {
        if (!systemType.equals(DiscoveredDataObject.Type.vplex.name()) && !systemType.equals(DiscoveredDataObject.Type.vnxblock.name()) && !systemType.equals(DiscoveredDataObject.Type.vmax.name()) && !systemType.equals(DiscoveredDataObject.Type.vnxe.name()) && !systemType.equals(DiscoveredDataObject.Type.unity.name()) && !systemType.equals(DiscoveredDataObject.Type.ibmxiv.name()) && !systemType.equals(DiscoveredDataObject.Type.scaleio.name()) && !systemType.equals(DiscoveredDataObject.Type.xtremio.name())) {
            throw APIException.methodNotAllowed.notSupported();
        }
    }
    // Get the specific BlockServiceApiImpl based on the storage system type.
    BlockServiceApi blockServiceApiImpl = getBlockServiceImpl(cgStorageSystem);
    List<URI> volIds = null;
    Set<URI> addSet = new HashSet<URI>();
    boolean isReplica = true;
    if (param.hasVolumesToAdd()) {
        volIds = param.getAddVolumesList().getVolumes();
        addSet.addAll(volIds);
        URI volId = volIds.get(0);
        if (URIUtil.isType(volId, Volume.class)) {
            Volume volume = _permissionsHelper.getObjectById(volId, Volume.class);
            ArgValidator.checkEntity(volume, volId, false);
            if (!BlockFullCopyUtils.isVolumeFullCopy(volume, _dbClient)) {
                isReplica = false;
            }
        }
    }
    List<Volume> cgVolumes = blockServiceApiImpl.getActiveCGVolumes(consistencyGroup);
    // check if add volume list is same as existing volumes in CG
    boolean volsAlreadyInCG = false;
    if (!isReplica && cgVolumes != null && !cgVolumes.isEmpty()) {
        Collection<URI> cgVolIds = transform(cgVolumes, fctnDataObjectToID());
        if (addSet.size() == cgVolIds.size()) {
            volsAlreadyInCG = addSet.containsAll(cgVolIds);
        }
    }
    // Verify that the add and remove lists do not contain the same volume.
    if (param.hasBothAddAndRemoveVolumes()) {
        /*
             * Make sure the add and remove lists are unique by getting the intersection and
             * verifying the size is 0.
             */
        Set<URI> removeSet = new HashSet<URI>(param.getRemoveVolumesList().getVolumes());
        addSet.retainAll(removeSet);
        if (!addSet.isEmpty()) {
            throw APIException.badRequests.sameVolumesInAddRemoveList();
        }
    }
    if (cgStorageSystem.getUsingSmis80() && cgStorageSystem.deviceIsType(Type.vmax)) {
        // CG can have replicas
        if (_log.isDebugEnabled()) {
            _log.debug("CG can have replicas for VMAX with SMI-S 8.x");
        }
    } else if (param.hasVolumesToRemove() || (!isReplica && !volsAlreadyInCG)) {
        // CG cannot have replicas when adding/removing volumes to/from CG
        // Check snapshots
        // Adding/removing volumes to/from a consistency group
        // is not supported when the consistency group has active
        // snapshots.
        URIQueryResultList cgSnapshotsResults = new URIQueryResultList();
        _dbClient.queryByConstraint(getBlockSnapshotByConsistencyGroup(id), cgSnapshotsResults);
        Iterator<URI> cgSnapshotsIter = cgSnapshotsResults.iterator();
        while (cgSnapshotsIter.hasNext()) {
            BlockSnapshot cgSnapshot = _dbClient.queryObject(BlockSnapshot.class, cgSnapshotsIter.next());
            if ((cgSnapshot != null) && (!cgSnapshot.getInactive())) {
                throw APIException.badRequests.notAllowedWhenCGHasSnapshots();
            }
        }
        // VNX group clones and mirrors are just list of replicas, no corresponding group on array side
        if (!cgStorageSystem.deviceIsType(Type.vnxblock)) {
            // is not supported when existing volumes in CG have mirrors.
            if (cgVolumes != null && !cgVolumes.isEmpty()) {
                Volume firstVolume = cgVolumes.get(0);
                StringSet mirrors = firstVolume.getMirrors();
                if (mirrors != null && !mirrors.isEmpty()) {
                    throw APIException.badRequests.notAllowedWhenCGHasMirrors();
                }
            }
            // Check clones
            // Adding/removing volumes to/from a consistency group
            // is not supported when the consistency group has
            // volumes with full copies to which they are still
            // attached or has volumes that are full copies that
            // are still attached to their source volumes.
            getFullCopyManager().verifyConsistencyGroupCanBeUpdated(consistencyGroup, cgVolumes);
        }
    }
    // Verify the volumes to be removed.
    List<URI> removeVolumesList = new ArrayList<URI>();
    if (param.hasVolumesToRemove()) {
        for (URI volumeURI : param.getRemoveVolumesList().getVolumes()) {
            // Validate the volume to be removed exists.
            if (URIUtil.isType(volumeURI, Volume.class)) {
                Volume volume = _permissionsHelper.getObjectById(volumeURI, Volume.class);
                ArgValidator.checkEntity(volume, volumeURI, false);
                /**
                 * Remove SRDF volume from CG is not supported.
                 */
                if (volume.checkForSRDF()) {
                    throw APIException.badRequests.notAllowedOnSRDFConsistencyGroups();
                }
                if (!BlockFullCopyUtils.isVolumeFullCopy(volume, _dbClient)) {
                    blockServiceApiImpl.verifyRemoveVolumeFromCG(volume, cgVolumes);
                }
            }
            removeVolumesList.add(volumeURI);
        }
    }
    URI xivPoolURI = null;
    if (systemType.equals(DiscoveredDataObject.Type.ibmxiv.name()) && !cgVolumes.isEmpty()) {
        Volume firstVolume = cgVolumes.get(0);
        xivPoolURI = firstVolume.getPool();
    }
    // Verify the volumes to be added.
    List<URI> addVolumesList = new ArrayList<URI>();
    List<Volume> volumes = new ArrayList<Volume>();
    if (param.hasVolumesToAdd()) {
        for (URI volumeURI : param.getAddVolumesList().getVolumes()) {
            // Validate the volume to be added exists.
            Volume volume = null;
            if (!isReplica) {
                volume = _permissionsHelper.getObjectById(volumeURI, Volume.class);
                ArgValidator.checkEntity(volume, volumeURI, false);
                blockServiceApiImpl.verifyAddVolumeToCG(volume, consistencyGroup, cgVolumes, cgStorageSystem);
                volumes.add(volume);
            } else {
                verifyAddReplicaToCG(volumeURI, consistencyGroup, cgStorageSystem);
            }
            // IBM XIV specific checking
            if (systemType.equals(DiscoveredDataObject.Type.ibmxiv.name())) {
                // all volumes should be on the same storage pool
                if (xivPoolURI == null) {
                    xivPoolURI = volume.getPool();
                } else {
                    if (!xivPoolURI.equals(volume.getPool())) {
                        throw APIException.badRequests.invalidParameterIBMXIVConsistencyGroupVolumeNotInPool(volumeURI, xivPoolURI);
                    }
                }
            }
            // Add the volume to list.
            addVolumesList.add(volumeURI);
        }
        if (!volumes.isEmpty()) {
            blockServiceApiImpl.verifyReplicaCount(volumes, cgVolumes, volsAlreadyInCG);
        }
    }
    // Create the task id;
    String taskId = UUID.randomUUID().toString();
    // Call the block service API to update the consistency group.
    return blockServiceApiImpl.updateConsistencyGroup(cgStorageSystem, cgVolumes, consistencyGroup, addVolumesList, removeVolumesList, taskId);
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) Volume(com.emc.storageos.db.client.model.Volume) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with StorageDriverManager

use of com.emc.storageos.services.util.StorageDriverManager in project coprhd-controller by CoprHD.

the class StorageDriverManagerPostProcessor method postProcessAfterInitialization.

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (!StringUtils.equals(beanName, StorageDriverManager.STORAGE_DRIVER_MANAGER)) {
        return bean;
    }
    StorageDriverManagerProxy proxy = new StorageDriverManagerProxy();
    proxy.setManager((StorageDriverManager) bean);
    DbClient dbClient = (DbClient) ((StorageDriverManager) bean).getApplicationContext().getBean("dbclient");
    proxy.setDbClient(dbClient);
    log.info("StorageDriverManager instance has been substituted in apisvc");
    return proxy;
}
Also used : StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) DbClient(com.emc.storageos.db.client.DbClient)

Example 3 with StorageDriverManager

use of com.emc.storageos.services.util.StorageDriverManager in project coprhd-controller by CoprHD.

the class ExportMaskPlacementDescriptorTest method mockStorageDriverManager.

private static void mockStorageDriverManager() {
    StorageDriverManager storageDriverManager = new StorageDriverManager();
    storageDriverManager.setApplicationContext(new ClassPathXmlApplicationContext("driver-conf.xml"));
}
Also used : StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 4 with StorageDriverManager

use of com.emc.storageos.services.util.StorageDriverManager in project coprhd-controller by CoprHD.

the class ExternalDeviceMaskingOrchestrator method createWorkFlowAndSubmitForExportGroupCreate.

@Override
public void createWorkFlowAndSubmitForExportGroupCreate(List<URI> initiatorURIs, Map<URI, Integer> volumeMap, String token, ExportOrchestrationTask taskCompleter, BlockStorageDevice device, ExportGroup exportGroup, StorageSystem storage) throws Exception {
    // Check that storage system is driver managed.
    StorageDriverManager storageDriverManager = getDriverManager();
    if (!storageDriverManager.isDriverManaged(storage.getSystemType())) {
        throw DeviceControllerException.exceptions.invalidSystemType(storage.getSystemType());
    }
    _log.info("Started export group processing.");
    // Get new work flow to setup steps for export group creation
    Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupCreate", true, token);
    // Create two steps, one for the ExportGroup actions and one for Zoning.
    List<String> maskingSteps = generateExportGroupCreateSteps(workflow, null, device, storage, exportGroup, initiatorURIs, volumeMap, false, token);
    // Have to store export group id to be available at device level for each masking step.
    for (String stepId : maskingSteps) {
        WorkflowService.getInstance().storeStepData(workflow.getWorkflowURI(), null, stepId, exportGroup.getId());
    }
    /*
         * This step is for zoning. It is not specific to a single
         * NetworkSystem, as it will look at all the initiators and targets and
         * compute the zones required (which might be on multiple
         * NetworkSystems.)
         *
         * Dependency task for the zoning execution is
         * EXPORT_GROUP_MASKING_TASK, hence enforcing the masking to be executed
         * before zoning is attempted
         */
    String zoningStep = generateDeviceSpecificZoningCreateWorkflow(workflow, EXPORT_GROUP_MASKING_TASK, exportGroup, null, volumeMap);
    if (!maskingSteps.isEmpty() && null != zoningStep) {
        // Execute the plan and allow the WorkflowExecutor to fire the
        // taskCompleter.
        workflow.executePlan(taskCompleter, String.format("ExportGroup successfully applied for StorageArray %s", storage.getLabel()));
    }
}
Also used : StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) Workflow(com.emc.storageos.workflow.Workflow)

Example 5 with StorageDriverManager

use of com.emc.storageos.services.util.StorageDriverManager in project coprhd-controller by CoprHD.

the class AutoTieringPolicyMatcher method matchStoragePoolsWithAttributeOn.

@Override
protected List<StoragePool> matchStoragePoolsWithAttributeOn(List<StoragePool> pools, Map<String, Object> attributeMap, StringBuffer errorMessage) {
    String autoTieringPolicyName = attributeMap.get(Attributes.auto_tiering_policy_name.toString()).toString();
    _logger.info("Pools Matching Auto Tiering Policy name attribute {} Started:{}", autoTieringPolicyName, Joiner.on("\t").join(getNativeGuidFromPools(pools)));
    // defensive copy
    List<StoragePool> filteredPoolList = new ArrayList<StoragePool>();
    Set<String> fastPolicyPools = null;
    StringSet deviceTypes = (StringSet) attributeMap.get(Attributes.system_type.toString());
    // deviceTypes other than vmax or vnxblock's control will not come to this matcher itself.
    if (deviceTypes.contains(VirtualPool.SystemType.vnxblock.toString())) {
        /**
         * return pools whose Storage System is Auto Tiering enabled
         */
        filteredPoolList = getAutoTieringPoolsOnVnx(pools);
    } else if (deviceTypes.contains(VirtualPool.SystemType.vmax.toString())) {
        fastPolicyPools = getAutoTieringPoolsOnVMAX(autoTieringPolicyName, attributeMap);
        Iterator<StoragePool> poolIterator = pools.iterator();
        while (poolIterator.hasNext()) {
            StoragePool pool = poolIterator.next();
            // if it doesn't match remove it from all pools.
            if (fastPolicyPools.contains(pool.getId().toString())) {
                filteredPoolList.add(pool);
            } else {
                _logger.info("Ignoring pool {} as it doesn't belongs to FAST policy.", pool.getNativeGuid());
            }
        }
    } else if (deviceTypes.contains(VirtualPool.SystemType.hds.name())) {
        filteredPoolList = getAutoTieringPoolsOnHDS(autoTieringPolicyName, attributeMap, pools);
    } else if (deviceTypes.contains(VirtualPool.SystemType.vnxe.toString()) || deviceTypes.contains(VirtualPool.SystemType.unity.toString())) {
        filteredPoolList = getPoolsWithAutoTieringEnabled(pools);
    } else {
        Iterator<String> deviceTypesIter = deviceTypes.iterator();
        if (deviceTypesIter.hasNext()) {
            String deviceType = deviceTypes.iterator().next();
            StorageDriverManager storageDriverManager = (StorageDriverManager) StorageDriverManager.getApplicationContext().getBean(StorageDriverManager.STORAGE_DRIVER_MANAGER);
            if (storageDriverManager.isDriverManaged(deviceType)) {
                filteredPoolList = getAutoTieringPoolsOnExternalSystem(autoTieringPolicyName, attributeMap, pools);
            }
        }
    }
    _logger.info("Pools Matching Auto Tiering name Ended:{}", Joiner.on("\t").join(getNativeGuidFromPools(filteredPoolList)));
    if (CollectionUtils.isEmpty(filteredPoolList)) {
        errorMessage.append(String.format("No matching storage pool found with auto tiering policy %s. ", autoTieringPolicyName));
        _logger.error(errorMessage.toString());
    }
    return filteredPoolList;
}
Also used : StorageDriverManager(com.emc.storageos.services.util.StorageDriverManager) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) Iterator(java.util.Iterator)

Aggregations

StorageDriverManager (com.emc.storageos.services.util.StorageDriverManager)8 ArrayList (java.util.ArrayList)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 MapBlockConsistencyGroup (com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup)1 DbClient (com.emc.storageos.db.client.DbClient)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StorageSystemType (com.emc.storageos.db.client.model.StorageSystemType)1 Volume (com.emc.storageos.db.client.model.Volume)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1