Search in sources :

Example 26 with AccessProfile

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

the class CommunicationInterfaceTest method testArrayWeight.

@Test
public void testArrayWeight() {
    // long s = UnsignedLongs.parseUnsignedLong("18446744073709551104");
    String s = "18446744073709551104";
    String s1 = s.substring(0, s.length() - 6);
    long l = Long.parseLong(s1);
    BigInteger t = new BigInteger("-1");
    UnsignedInteger64 ui = new UnsignedInteger64("18446744073709551104");
    String providerIPAddress = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.ipaddress");
    String providerNamespace = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.namespace");
    String providerPortNumber = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.port");
    String providerUser = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.username");
    String providerPwd = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.password");
    String providerUseSSL = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.usessl");
    String providerSystemSerialId = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.array.serial");
    BigInteger l1 = ui.bigIntegerValue();
    _logger.info("Test Started");
    WBEMClientCIMXML _wbemClient = null;
    try {
        final NamespaceList _nsList = (NamespaceList) _context.getBean("namespaces");
        _wbemClient = (WBEMClientCIMXML) _context.getBean("cimClient");
        AccessProfile _profile = new AccessProfile();
        _profile.setInteropNamespace(providerNamespace);
        _profile.setIpAddress(providerIPAddress);
        _profile.setPassword(providerPwd);
        _profile.setProviderPort(providerPortNumber);
        _profile.setnamespace("Performance");
        _profile.setelementType("Array");
        _profile.setUserName(providerUser);
        // need to set Array serial ID;
        _profile.setSslEnable(providerUseSSL);
        _profile.setserialID(providerSystemSerialId);
        getCIMClient(_profile, _wbemClient);
        Map<String, Object> _keyMap = new ConcurrentHashMap<String, Object>();
        _keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
        _keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
        _keyMap.put(Constants._cimClient, new WBEMClientCIMXML());
        _keyMap.put(Constants.ACCESSPROFILE, _profile);
        _profile.setSystemId(new URI("tag"));
        _profile.setSystemClazz(StorageSystem.class);
        _keyMap.put(Constants._serialID, _profile.getserialID());
        _keyMap.put(Constants._storagePool, CimObjectPathCreator.createInstance(Constants._cimPool, _profile.getInteropNamespace()));
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        _keyMap.put("storageProcessors", new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants._computerSystem, CimObjectPathCreator.createInstance(Constants._cimSystem, _profile.getInteropNamespace()));
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants._serialID, _profile.getserialID());
        // _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants._Volumes, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants._nativeGUIDs, Sets.newHashSet());
        _keyMap.put(Constants._Stats, new LinkedList<Stat>());
        _keyMap.put(Constants._InteropNamespace, _profile.getInteropNamespace());
        _keyMap.put(Constants._debug, true);
        // _keyMap.put(Constants._cache, _Cache);
        // _keyMap.put(Constants._globalCacheKey, cacheVolumes);
        // _keyMap.put(Constants._cachePools, cachePools);
        // _keyMap.put(Constants._cassandraInsertion, _dbUtil);
        // _keyMap.put(Constants.PROPS, accessProfile.getProps());
        // Add storagePool Object path & LinkedList<CIMObjectPath> to Map
        _keyMap.put(Constants._storagePool, CimObjectPathCreator.createInstance(Constants._cimPool, _profile.getInteropNamespace()));
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        Executor _executor = new Executor() {

            @Override
            protected void customizeException(Exception e, Operation operation) throws BaseCollectionException {
            // TODO Auto-generated method stub
            }
        };
        Util _util = new Util();
        CommandGenerator _gen = new CommandGenerator();
        _gen.setutil(_util);
        _executor.set_keyMap(_keyMap);
        _executor.set_generator(_gen);
        _executor.set_util(_util);
        _executor.execute((Namespace) _nsList.getNsList().get("metering"));
    } catch (Exception e) {
        _logger.error(e.getMessage(), e);
    } finally {
        _wbemClient.close();
    }
}
Also used : UnsignedInteger64(javax.cim.UnsignedInteger64) CIMObjectPath(javax.cim.CIMObjectPath) Util(com.emc.storageos.plugins.common.Util) AccessProfile(com.emc.storageos.plugins.AccessProfile) Operation(com.emc.storageos.plugins.common.domainmodel.Operation) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) WBEMClientCIMXML(org.sblim.cimclient.internal.wbem.WBEMClientCIMXML) CommandGenerator(com.emc.storageos.plugins.common.commandgenerator.CommandGenerator) Stat(com.emc.storageos.db.client.model.Stat) Executor(com.emc.storageos.plugins.common.Executor) BigInteger(java.math.BigInteger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.junit.Test)

Example 27 with AccessProfile

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

the class StorageSystemStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    Iterator<CIMInstance> systemStatsResponseItr = (Iterator<CIMInstance>) resultObj;
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
    logger.info("Processing storagesystem {} stats response", profile.getSystemId());
    try {
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        if (systemStatsResponseItr != null) {
            while (systemStatsResponseItr.hasNext()) {
                CIMInstance systemStatInstance = (CIMInstance) systemStatsResponseItr.next();
                Stat systemStat = new Stat();
                // HUS VM.211643
                systemStat.setNativeGuid(getSystemNativeGuid(systemStatInstance, dbClient));
                systemStat.setResourceId(profile.getSystemId());
                systemStat.setServiceType(Constants._Block);
                systemStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
                Long providerCollectionTime = convertCIMStatisticTime(getCIMPropertyValue(systemStatInstance, STATISTICTIME));
                if (0 != providerCollectionTime) {
                    systemStat.setTimeInMillis(providerCollectionTime);
                } else {
                    systemStat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
                }
                systemStat.setTotalIOs(ControllerUtils.getLongValue(getCIMPropertyValue(systemStatInstance, TOTALIOS)));
                systemStat.setKbytesTransferred(ControllerUtils.getLongValue(getCIMPropertyValue(systemStatInstance, KBYTESTRANSFERRED)));
                metricsObjList.add(systemStat);
            }
        }
    } catch (Exception ex) {
        logger.error("Failed while extracting Stats for storage System: ", ex);
    } finally {
        resultObj = null;
    }
    logger.info("Processing storagesystem {} stats response completed", profile.getSystemId());
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 28 with AccessProfile

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

the class ConnectionManagerUtils method allowReaping.

public void allowReaping(Object profile, Object client) throws BaseCollectionException {
    AccessProfile accessProfile = (AccessProfile) profile;
    DbClient dbClient = (DbClient) client;
    try {
        final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
        connectionFactory.unsetKeepAliveForConnection(storageSystem);
    } catch (final IllegalStateException ex) {
        log.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
        throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 29 with AccessProfile

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

the class DataCollectionJobUtil method getAccessProfile.

/**
 * Create AccessProfile from DiscoveryJob
 *
 * TODO create subClasses for Accessprofile based on deviceType and Profile.
 * i.e. Metering-isilon accessProfile - a subclass under AccessProfile
 *
 * @param clazz
 * @param objectID
 * @param jobProfile
 * @return AccessProfile
 * @throws IOException
 */
public AccessProfile getAccessProfile(Class<? extends DataObject> clazz, URI objectID, String jobProfile, String nameSpace) throws DatabaseException, DeviceControllerException {
    DataObject taskObject = _dbClient.queryObject(clazz, objectID);
    AccessProfile profile = new AccessProfile();
    profile.setProfileName(jobProfile);
    profile.setRecordableEventManager(_eventManager);
    if (clazz == StorageProvider.class && StorageProvider.InterfaceType.smis.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateSMISAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.hicommand.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateHDSAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.cinder.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateCinderAccessProfile(profile, (StorageProvider) taskObject);
    } else if ((clazz == StorageProvider.class && StorageProvider.InterfaceType.vplex.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) || (clazz == StorageSystem.class && DiscoveredDataObject.Type.vplex.name().equalsIgnoreCase(((StorageSystem) taskObject).getSystemType()))) {
        populateVPLEXAccessProfile(profile, taskObject, nameSpace);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.scaleioapi.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateScaleIOAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ddmc.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateDataDomainAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ibmxiv.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateSMISAccessProfile(profile, (StorageProvider) taskObject);
        profile.setnamespace(Constants.IBM_NAMESPACE);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.xtremio.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateXtremIOAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.ceph.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateCephAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageProvider.InterfaceType.unity.name().equalsIgnoreCase(((StorageProvider) taskObject).getInterfaceType())) {
        populateUnityAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageProvider.class && StorageSystem.Type.isDriverManagedStorageProvider(((StorageProvider) taskObject).getInterfaceType())) {
        populateExternalProviderAccessProfile(profile, (StorageProvider) taskObject);
    } else if (clazz == StorageSystem.class) {
        populateAccessProfile(profile, (StorageSystem) taskObject, nameSpace);
    } else if (clazz == ProtectionSystem.class) {
        populateAccessProfile(profile, (ProtectionSystem) taskObject, nameSpace);
    } else if (clazz == ComputeSystem.class) {
        populateAccessProfile(profile, (ComputeSystem) taskObject);
    } else if (clazz == NetworkSystem.class) {
        populateAccessProfile(profile, (NetworkSystem) taskObject);
    } else if (clazz == Host.class) {
        populateAccessProfile(profile, (Host) taskObject);
    } else if (clazz == Vcenter.class) {
        populateAccessProfile(profile, (Vcenter) taskObject);
    } else {
        throw new RuntimeException("getAccessProfile: profile is unknown for objects of type : " + taskObject.getClass());
    }
    return profile;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) Host(com.emc.storageos.db.client.model.Host) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 30 with AccessProfile

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

the class LunMaskingProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
    Map<String, VolHostIOObject> volToIolimits = new HashMap<String, VolHostIOObject>();
    List<CIMObjectPath> processedSGCoPs = new ArrayList<CIMObjectPath>();
    Map<String, String> volToFastPolicy = new HashMap<String, String>();
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    CIMObjectPath maskingViewPath = getObjectPathfromCIMArgument(_args);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    URI systemId = profile.getSystemId();
    try {
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, systemId);
        while (it.hasNext()) {
            CIMObjectPath path = it.next();
            // use io limit on child always
            if (path.toString().contains(SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name())) {
                List<CIMObjectPath> paths = getChildGroupsifCascaded(path, client);
                if (!paths.isEmpty()) {
                    _logger.info("Cascaded SG Detected");
                    CIMInstance csgInstance = client.getInstance(path, false, true, SmisConstants.PS_HOST_IO);
                    String parentHostIoBw = String.valueOf(csgInstance.getPropertyValue(SmisConstants.EMC_MAX_BANDWIDTH));
                    String parentHostIoPs = String.valueOf(csgInstance.getPropertyValue(SmisConstants.EMC_MAX_IO));
                    for (CIMObjectPath childPath : paths) {
                        addIoLimitsOnVolume(client, childPath, volToIolimits, volToFastPolicy, parentHostIoBw, parentHostIoPs);
                    }
                    processedSGCoPs.addAll(paths);
                } else {
                    _logger.info("Non cascaded SG Detected");
                    addIoLimitsOnVolume(client, path, volToIolimits, volToFastPolicy, "0", "0");
                    processedSGCoPs.add(path);
                }
            }
            // Clar_LunMaskingSCSIProtocolController-->StorageVolume, if volume entry is there,
            // then consider those as exported Volumes.
            String systemName = (String) maskingViewPath.getKey(Constants.SYSTEMNAME).getValue();
            if (systemName.toLowerCase().contains(Constants.CLARIION) && path.toString().toLowerCase().contains(STORAGE_VOLUME_PREFIX)) {
                String volumeNativeGuid = getVolumeNativeGuid(path);
                VolHostIOObject obj = new VolHostIOObject();
                obj.setVolNativeGuid(volumeNativeGuid);
                obj.setHostIoBw("0");
                obj.setHostIops("0");
                volToIolimits.put(volumeNativeGuid, obj);
            }
        }
        // will be used to filter out already exported Volumes
        if (!keyMap.containsKey(Constants.EXPORTED_VOLUMES)) {
            keyMap.put(Constants.EXPORTED_VOLUMES, volToIolimits);
        } else {
            @SuppressWarnings("unchecked") Map<String, VolHostIOObject> alreadyExportedVolumes = (Map<String, VolHostIOObject>) keyMap.get(Constants.EXPORTED_VOLUMES);
            alreadyExportedVolumes.putAll(volToIolimits);
        }
        if (device.checkIfVmax3()) {
            // SLO Names.
            if (!keyMap.containsKey(Constants.STORAGE_GROUPS_PROCESSED)) {
                keyMap.put(Constants.STORAGE_GROUPS_PROCESSED, processedSGCoPs);
            } else {
                List<CIMObjectPath> volumesWithFastPolicy = (List<CIMObjectPath>) keyMap.get(Constants.STORAGE_GROUPS_PROCESSED);
                volumesWithFastPolicy.addAll(processedSGCoPs);
            }
            // Set the volumesWithSLO in the keyMap for further processing.
            if (!keyMap.containsKey(Constants.VOLUMES_WITH_SLOS)) {
                keyMap.put(Constants.VOLUMES_WITH_SLOS, volToFastPolicy);
            } else {
                Map<String, String> volumesWithFastPolicy = (Map<String, String>) keyMap.get(Constants.VOLUMES_WITH_SLOS);
                volumesWithFastPolicy.putAll(volToFastPolicy);
            }
        }
    } catch (Exception e) {
        _logger.error("Extracting already exported Volumes failed", e);
    }
}
Also used : HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) VolHostIOObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.VolHostIOObject) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CloseableIterator(javax.wbem.CloseableIterator) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient) HashMap(java.util.HashMap) Map(java.util.Map) 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