Search in sources :

Example 31 with AccessProfile

use of com.emc.storageos.plugins.AccessProfile in project coprhd-controller by CoprHD.

the class ModelProcessor method processResult.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CIMInstance modelInstance = null;
    try {
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        Map<String, StorageSystemViewObject> storageSystemsCache = (Map<String, StorageSystemViewObject>) keyMap.get(Constants.SYSTEMCACHE);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        String deviceType = null;
        while (it.hasNext()) {
            modelInstance = it.next();
            String model = modelInstance.getPropertyValue(MODEL).toString();
            // TODO should CIM_Chassis.SerialNumber be used instead of Tag?
            String tag = modelInstance.getPropertyValue(TAG).toString();
            String serialID = null;
            if (isIBMInstance(modelInstance)) {
                String typeDesc = modelInstance.getPropertyValue(TYPE_DESC).toString();
                if (Constants.XIV.equalsIgnoreCase(typeDesc)) {
                    deviceType = DiscoveredDataObject.Type.ibmxiv.name();
                    // e.g., IBM.2810-7825363
                    serialID = tag;
                } else {
                    _logger.warn("Array {} is of model {} ---> not XIV, hence will not be added to ViPR", tag, model);
                    continue;
                }
            } else {
                if (model.toLowerCase().contains(VNX)) {
                    deviceType = VNXBLOCK;
                } else if (model.toLowerCase().contains(VMAX) || model.toLowerCase().contains(POWERMAX) || model.toLowerCase().contains(PMAX)) {
                    deviceType = VMAX;
                } else {
                    _logger.warn("Array {} is of model {} ---> neither VMAX nor VNX, hence will not be added to ViPR", tag, model);
                    continue;
                }
                serialID = tag.split(Constants.PATH_DELIMITER_REGEX)[1];
            }
            keyMap.put(Constants.ARRAYTYPE, deviceType);
            StorageSystemViewObject systemVO = null;
            String nativeGuid = NativeGUIDGenerator.generateNativeGuid(deviceType, serialID);
            if (storageSystemsCache.containsKey(nativeGuid)) {
                systemVO = storageSystemsCache.get(nativeGuid);
            } else {
                systemVO = new StorageSystemViewObject();
            }
            systemVO.setDeviceType(deviceType);
            systemVO.addprovider(profile.getSystemId().toString());
            systemVO.setProperty(StorageSystemViewObject.MODEL, model);
            systemVO.setProperty(StorageSystemViewObject.SERIAL_NUMBER, serialID);
            systemVO.setProperty(StorageSystemViewObject.STORAGE_NAME, nativeGuid);
            storageSystemsCache.put(nativeGuid, systemVO);
        }
        _logger.info("Found {} systems during scanning for ip {}", storageSystemsCache.size(), profile.getIpAddress());
        resultObj = null;
    } catch (Exception e) {
        _logger.error(e.getMessage(), e);
        _logger.error("Model Extraction failed for {}-->{}", modelInstance.getObjectPath(), getMessage(e));
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) Iterator(java.util.Iterator) AccessProfile(com.emc.storageos.plugins.AccessProfile) Map(java.util.Map) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 32 with AccessProfile

use of com.emc.storageos.plugins.AccessProfile in project coprhd-controller by CoprHD.

the class StorageProtocolEndPointProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CoordinatorClient coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        List<StoragePort> newPorts = new ArrayList<StoragePort>();
        List<StoragePort> existingPorts = new ArrayList<StoragePort>();
        while (it.hasNext()) {
            CIMInstance endPointInstance = null;
            StoragePort port = null;
            try {
                endPointInstance = it.next();
                String portInstanceID = endPointInstance.getObjectPath().getKey(SYSTEMNAME).getValue().toString();
                if (device.checkIfVmax3()) {
                    CIMObjectPath logicalPortPath = getObjectPathfromCIMArgument(args);
                    // We need the portInstanceID to not constitute the Virtual information.
                    // i.e Instead of SYMMETRIX-+-<<SERIAL>>-+-115-+-0 it should be SYMMETRIX-+-<<SERIAL>>-+-SE-1G-+-0
                    StringBuffer newPortInstanceID = new StringBuffer(logicalPortPath.getKey(SYSTEMNAME).getValue().toString());
                    newPortInstanceID.append(Constants._plusDelimiter).append(logicalPortPath.getKey(DEVICEID).getValue().toString());
                    portInstanceID = (newPortInstanceID.toString()).replaceAll(Constants.SMIS_PLUS_REGEX, Constants.SMIS80_DELIMITER_REGEX);
                }
                String iScsiPortName = getCIMPropertyValue(endPointInstance, NAME);
                // Skip the iSCSI ports without name or without a valid name.
                if (null == iScsiPortName || iScsiPortName.split(COMMA_STR)[0].length() <= 0) {
                    _logger.warn("Invalid port Name found for {} Skipping", portInstanceID);
                    continue;
                }
                port = checkEthernetStoragePortExistsInDB(iScsiPortName.split(COMMA_STR)[0].toLowerCase(), _dbClient, device);
                createEthernetStoragePort(keyMap, port, endPointInstance, portInstanceID, coordinator, newPorts, existingPorts);
                addPath(keyMap, operation.getResult(), endPointInstance.getObjectPath());
            } catch (Exception e) {
                _logger.warn("SCSI End Point Discovery failed for {}-->{}", "", getMessage(e));
            }
        }
        @SuppressWarnings("unchecked") List<List<StoragePort>> portsUsedToRunNetworkConnectivity = (List<List<StoragePort>>) keyMap.get(Constants.STORAGE_PORTS);
        portsUsedToRunNetworkConnectivity.add(newPorts);
        // discovered ports used later to check for not visible ports
        List<StoragePort> discoveredPorts = (List<StoragePort>) keyMap.get(Constants.DISCOVERED_PORTS);
        discoveredPorts.addAll(newPorts);
        discoveredPorts.addAll(existingPorts);
        List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, newPorts, null);
        for (StoragePool pool : modifiedPools) {
            // pool matcher will be invoked on this pool
            if (!poolsToMatchWithVpool.containsKey(pool.getId())) {
                poolsToMatchWithVpool.put(pool.getId(), pool);
            }
        }
        _logger.debug("# Pools used in invoking PoolMatcher during StorageProtoclEndPoint {}", Joiner.on("\t").join(poolsToMatchWithVpool.keySet()));
    } catch (Exception e) {
        _logger.error("SCSI End Point Discovery failed -->{}", getMessage(e));
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 33 with AccessProfile

use of com.emc.storageos.plugins.AccessProfile in project coprhd-controller by CoprHD.

the class SupportedCopyTypesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        boolean isVmax3 = device.checkIfVmax3();
        Iterator<CIMInstance> iterator = (Iterator<CIMInstance>) resultObj;
        while (iterator.hasNext()) {
            CIMInstance instance = iterator.next();
            String instanceID = getCIMPropertyValue(instance, Constants.INSTANCEID);
            String thinProvisionedPreAllocateSupported = Boolean.FALSE.toString();
            if (!isVmax3) {
                thinProvisionedPreAllocateSupported = instance.getPropertyValue(Constants.THIN_PROVISIONED_CLIENT_SETTABLE_RESERVE).toString();
            } else {
                thinProvisionedPreAllocateSupported = Boolean.TRUE.toString();
            }
            UnsignedInteger16[] copyTypes = (UnsignedInteger16[]) instance.getPropertyValue(Constants.SUPPORTED_COPY_TYPES);
            String nativeID = getNativeIDFromInstance(instanceID);
            StoragePool storagePool = checkStoragePoolExistsInDB(nativeID, _dbClient, device);
            if (storagePool == null) {
                _log.warn("No storage pool");
                continue;
            }
            addCopyTypesToStoragePool(copyTypes, storagePool, thinProvisionedPreAllocateSupported, poolsToMatchWithVpool);
        }
    } catch (Exception e) {
        _log.error("Supported copy types processing failed", e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 34 with AccessProfile

use of com.emc.storageos.plugins.AccessProfile in project coprhd-controller by CoprHD.

the class VmaxPortGroupProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    log.info("Process port group");
    try {
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        String serialID = (String) keyMap.get(Constants._serialID);
        dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        StorageSystem device = dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        boolean hasVolume = hasAnyVolume(device.getId());
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        while (it.hasNext()) {
            CIMInstance groupInstance = it.next();
            CIMObjectPath groupPath = groupInstance.getObjectPath();
            if (groupPath.toString().contains(serialID)) {
                String portGroupName = groupInstance.getPropertyValue(Constants.ELEMENTNAME).toString();
                if (StringUtils.isEmpty(portGroupName)) {
                    log.info(String.format("The port group %s name is null, skip", groupPath.toString()));
                    continue;
                }
                log.info(String.format("Got the port group: %s", portGroupName));
                List<String> storagePorts = new ArrayList<String>();
                CloseableIterator<CIMInstance> iterator = client.associatorInstances(groupPath, null, Constants.CIM_PROTOCOL_ENDPOINT, null, null, false, Constants.PS_NAME);
                while (iterator.hasNext()) {
                    CIMInstance cimInstance = iterator.next();
                    String portName = CIMPropertyFactory.getPropertyValue(cimInstance, Constants._Name);
                    String fixedName = Initiator.toPortNetworkId(portName);
                    log.debug("Storage Port: {}", fixedName);
                    storagePorts.add(fixedName);
                }
                if (!storagePorts.isEmpty()) {
                    StoragePortGroup portGroup = getPortGroupInDB(portGroupName, device);
                    if (portGroup == null) {
                        // discovery after the upgrade.
                        if (hasVolume) {
                            List<ExportMask> masks = getExportMasksForPortGroup(client, groupPath, portGroupName, device);
                            boolean viprCreated = (!masks.isEmpty());
                            portGroup = createPortGroup(portGroupName, device, viprCreated);
                            for (ExportMask mask : masks) {
                                mask.setPortGroup(portGroup.getId());
                            }
                            dbClient.updateObject(masks);
                        } else {
                            portGroup = createPortGroup(portGroupName, device, false);
                        }
                    }
                    allPortGroupNativeGuids.add(portGroup.getNativeGuid());
                    List<URI> storagePortURIs = new ArrayList<URI>();
                    storagePortURIs.addAll(transform(ExportUtils.storagePortNamesToURIs(dbClient, storagePorts), CommonTransformerFunctions.FCTN_STRING_TO_URI));
                    portGroup.setStoragePorts(StringSetUtil.uriListToStringSet(storagePortURIs));
                    dbClient.updateObject(portGroup);
                } else {
                    // no storage ports in the port group, remove it
                    log.info(String.format("The port group %s does not have any storage ports, ignore", portGroupName));
                }
            }
        }
        if (!allPortGroupNativeGuids.isEmpty()) {
            doBookKeeping(device.getId());
        } else {
            log.info("Did not get any port group, skip book keeping");
        }
    } catch (Exception e) {
        log.error("port group discovery failed ", e);
    } finally {
        allPortGroupNativeGuids.clear();
    }
}
Also used : StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CloseableIterator(javax.wbem.CloseableIterator) Iterator(java.util.Iterator) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 35 with AccessProfile

use of com.emc.storageos.plugins.AccessProfile in project coprhd-controller by CoprHD.

the class SGsWithFastVolumesProcessor method processVolumes.

private void processVolumes(Iterator<CIMObjectPath> it, String policyName, Map<String, Object> keyMap, Operation operation) {
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
    while (it.hasNext()) {
        CIMObjectPath volumePath = null;
        try {
            volumePath = it.next();
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            _logger.debug("VolumeNativeGuid {}", volumeNativeGuid);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume {} is already being managed by ViPR.", volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            _logger.debug("UnManagedVolumeNativeGuid {}", unManagedVolumeNativeGuid);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                _logger.info("Adding VMAX Policy Rule {}", policyName);
                unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.AUTO_TIERING_POLICIES.toString(), policyName);
                unManagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
                // StorageVolumeInfoProcessor updated supported_vpool_list based on its pool's presence in vPool
                // Now, filter those vPools based on policy associated
                DiscoveryUtils.filterSupportedVpoolsBasedOnTieringPolicy(unManagedVolume, policyName, system, _dbClient);
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume {} failed", volumePath, ex);
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

AccessProfile (com.emc.storageos.plugins.AccessProfile)49 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)33 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)30 Iterator (java.util.Iterator)25 CIMInstance (javax.cim.CIMInstance)24 CIMObjectPath (javax.cim.CIMObjectPath)16 URI (java.net.URI)14 DbClient (com.emc.storageos.db.client.DbClient)12 List (java.util.List)11 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 Stat (com.emc.storageos.db.client.model.Stat)8 StoragePool (com.emc.storageos.db.client.model.StoragePool)7 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 CIMArgument (javax.cim.CIMArgument)4