Search in sources :

Example 36 with CIMInstance

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

the class SupportedAsynchronousActionsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _log.info("***Inside SupportedAsynchronousActionsProcessor****");
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Iterator<CIMInstance> iterator = (Iterator<CIMInstance>) resultObj;
        while (iterator.hasNext()) {
            CIMInstance instance = iterator.next();
            UnsignedInteger16[] supportedAsyncActions = (UnsignedInteger16[]) instance.getPropertyValue(Constants.SUPPORTED_ASYNCHRONOUS_ACTIONS);
            StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
            addSupportedAsynchronousActionsToStorageSystem(supportedAsyncActions, device);
            StringSet replicationTypes = new StringSet();
            replicationTypes.add(SupportedReplicationTypes.LOCAL.toString());
            device.setSupportedReplicationTypes(replicationTypes);
        }
    } catch (Exception e) {
        _log.error("Supported asynchronous action processing failed", e);
    }
}
Also used : Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 37 with CIMInstance

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

the class TCPProtocolEndPointProcessor 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);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        while (it.hasNext()) {
            CIMInstance tcpPointInstance = null;
            StoragePort port = null;
            try {
                tcpPointInstance = it.next();
                String portInstanceID = tcpPointInstance.getObjectPath().getKey(SYSTEMNAME).getValue().toString();
                port = checkEthernetStoragePortExistsInDB(getCIMPropertyValue(tcpPointInstance, NAME), _dbClient, device);
                updateTCPEndPointDetails(keyMap, port, tcpPointInstance, portInstanceID);
            } catch (Exception e) {
                _logger.warn("Port TCP End Point Discovery failed for {}-->{}", "", getMessage(e));
            }
        }
    } catch (Exception e) {
        _logger.error("Port TCP End Point Discovery failed -->{}", getMessage(e));
    }
}
Also used : Iterator(java.util.Iterator) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 38 with CIMInstance

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

the class VmaxPortGroupProcessor method getExportMasksForPortGroup.

/**
 * Get export masks using the specified port group
 *
 * @param client
 *            - WBEMClient
 * @param groupPath
 *            - port group CIMObjectPath
 * @param portGroupName
 *            - port group name
 * @param device
 *            - Storage system
 * @return List of export mask using this port group
 */
private List<ExportMask> getExportMasksForPortGroup(WBEMClient client, CIMObjectPath groupPath, String portGroupName, StorageSystem device) {
    List<ExportMask> result = new ArrayList<ExportMask>();
    CloseableIterator<CIMInstance> iterator = null;
    try {
        iterator = client.associatorInstances(groupPath, null, Constants.SYMM_LUNMASKINGVIEW, null, null, false, Constants.PS_NAME);
        if (!iterator.hasNext()) {
            // No lun masking view associated.
            return result;
        }
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String maskName = CIMPropertyFactory.getPropertyValue(cimInstance, Constants._Name);
            if (maskName != null) {
                // Try to see if we could find export mask in ViPR has the same name
                URIQueryResultList exportMaskURIs = new URIQueryResultList();
                dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportMaskByNameConstraint(maskName), exportMaskURIs);
                Iterator<URI> maskIt = exportMaskURIs.iterator();
                while (maskIt.hasNext()) {
                    URI maskURI = maskIt.next();
                    ExportMask mask = dbClient.queryObject(ExportMask.class, maskURI);
                    if (device.getId().equals(mask.getStorageDevice()) && mask.getUserAddedVolumes() != null && !mask.getUserAddedVolumes().isEmpty()) {
                        result.add(mask);
                        log.info(String.format("The port group %s is used by the export mask %s %s", portGroupName, maskName, maskURI.toString()));
                    }
                }
            }
        }
    } catch (Exception e) {
        log.warn("Exception while getting port gorup association:", e);
    } finally {
        if (null != iterator) {
            iterator.close();
        }
    }
    return result;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 39 with CIMInstance

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

the class MetaVolumeMembersProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
        if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
            _logger.info(String.format("There are no meta members to process"));
        } else {
            _logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
            // Get volume from db
            _logger.debug(String.format("Args size: %s", _args.size()));
            Object[] arguments = (Object[]) _args.get(0);
            CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
            _logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
            CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(theElementPath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
                _logger.debug("Volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            Integer membersCount = metaMembersPaths.length;
            // get meta member size. use second member --- the first member will show size of meta volume itself.
            CIMObjectPath metaMemberPath = metaMembersPaths[1];
            CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
            CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate size = consumableBlocks * block size
            Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
            // set meta member count and meta members size for meta volume (required for volume expansion)
            if (null != preExistingVolume) {
                StringSet metaMembersCount = new StringSet();
                metaMembersCount.add(membersCount.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
                StringSet metaMemberSize = new StringSet();
                metaMemberSize.add(size.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
                // persist unmanaged volume in db
                dbClient.persistObject(preExistingVolume);
            } else {
                storageVolume.setMetaMemberCount(membersCount);
                storageVolume.setMetaMemberSize(size);
                storageVolume.setTotalMetaMemberCapacity(membersCount * size);
                // persist volume in db
                dbClient.persistObject(storageVolume);
            }
            _logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume  information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) CIMArgument(javax.cim.CIMArgument)

Example 40 with CIMInstance

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

the class MetaVolumeTypeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath metaVolumePath = getObjectPathfromCIMArgument(_args);
        if (metaVolumePath == null) {
            _logger.info(String.format("MetaVolumePath is null."));
        } else {
            _logger.info(String.format("Processing EMC_Meta for meta volume: %s", metaVolumePath));
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(metaVolumePath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(metaVolumePath);
                _logger.debug("Meta volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeTypeProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            final Iterator<?> it = (Iterator<?>) resultObj;
            if (it.hasNext()) {
                final CIMObjectPath symmMetaPath = (CIMObjectPath) it.next();
                _logger.debug(String.format("Processing EMC_Meta: %s", symmMetaPath));
                CIMInstance cimMeta = client.getInstance(symmMetaPath, false, false, STRIPE_EXTENTS_NUMBER);
                CIMProperty stripeLengthProperty = cimMeta.getProperty(SmisConstants.CP_EXTENT_STRIPE_LENGTH);
                Long stripeLength = Long.valueOf(stripeLengthProperty.getValue().toString());
                String metaVolumeType;
                if (stripeLength < 1) {
                    _logger.error(String.format("Stripe length for EMC_Meta is less than 1: %s", stripeLength));
                    return;
                } else if (stripeLength == 1) {
                    // this is concatenated meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is concatenated.", stripeLength));
                    metaVolumeType = Volume.CompositionType.CONCATENATED.toString();
                } else {
                    // this is striped meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is striped.", stripeLength));
                    metaVolumeType = Volume.CompositionType.STRIPED.toString();
                }
                _logger.info(String.format("Meta volume: %s, type: %s", metaVolumePath, metaVolumeType));
                if (null == preExistingVolume) {
                    // storage volume update
                    storageVolume.setCompositionType(metaVolumeType);
                    // persist volume in db
                    dbClient.persistObject(storageVolume);
                } else {
                    // unmanaged volume update
                    StringSet metaVolumeTypeSet = new StringSet();
                    metaVolumeTypeSet.add(metaVolumeType);
                    preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_VOLUME_TYPE.toString(), metaVolumeTypeSet);
                    // for this volume.
                    if (Volume.CompositionType.STRIPED.toString().equalsIgnoreCase(metaVolumeType)) {
                        URI storageSystemUri = preExistingVolume.getStorageSystemUri();
                        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemUri);
                        if (DiscoveredDataObject.Type.vmax.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
                            _logger.info("Check matched vpool list for vmax striped meta volume and remove fastExpansion vpools.");
                            StringSet matchedVirtualPools = preExistingVolume.getSupportedVpoolUris();
                            if (matchedVirtualPools != null && !matchedVirtualPools.isEmpty()) {
                                _logger.debug("Matched Pools :" + Joiner.on("\t").join(matchedVirtualPools));
                                StringSet newMatchedPools = new StringSet();
                                boolean needToReplace = false;
                                for (String vPoolUriStr : matchedVirtualPools) {
                                    URI vPoolUri = new URI(vPoolUriStr);
                                    VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, vPoolUri);
                                    // null check since supported vPool list in UnManagedVolume may contain inactive vPool
                                    if (virtualPool != null && !virtualPool.getFastExpansion()) {
                                        newMatchedPools.add(vPoolUriStr);
                                    } else {
                                        needToReplace = true;
                                    }
                                }
                                if (needToReplace) {
                                    matchedVirtualPools.replace(newMatchedPools);
                                    _logger.info("Replaced VPools : {}", Joiner.on("\t").join(preExistingVolume.getSupportedVpoolUris()));
                                }
                            }
                        }
                    }
                    // persist volume in db
                    dbClient.updateAndReindexObject(preExistingVolume);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume type information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CIMInstance (javax.cim.CIMInstance)370 CIMObjectPath (javax.cim.CIMObjectPath)254 WBEMException (javax.wbem.WBEMException)139 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)104 ArrayList (java.util.ArrayList)98 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)79 URI (java.net.URI)79 CIMArgument (javax.cim.CIMArgument)71 WBEMClient (javax.wbem.client.WBEMClient)69 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)62 Volume (com.emc.storageos.db.client.model.Volume)62 HashSet (java.util.HashSet)60 IOException (java.io.IOException)53 HashMap (java.util.HashMap)52 Iterator (java.util.Iterator)50 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)48 CIMProperty (javax.cim.CIMProperty)37 StringSet (com.emc.storageos.db.client.model.StringSet)31 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)29