Search in sources :

Example 26 with CIMObjectPath

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

the class SRDFStorageSyncProcessor method processStorageSynchronizedPaths.

private void processStorageSynchronizedPaths(Operation operation, Iterator<CIMObjectPath> it, Object resultObj, Map<String, Object> keyMap) {
    while (it.hasNext()) {
        try {
            DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
            CIMObjectPath volumePath = it.next();
            CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
            CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
            CIMProperty<?> prop = sourcePath.getKey(Constants._SystemName);
            String[] serialNumber_split = prop.getValue().toString().split(Constants.PATH_DELIMITER_REGEX);
            if (serialNumber_split[1].equalsIgnoreCase((String) keyMap.get(Constants._serialID))) {
                // If mirror
                String sourceVolumeNativeGuid = getVolumeNativeGuid(sourcePath);
                Volume sourceVolume = checkStorageVolumeExistsInDB(sourceVolumeNativeGuid, dbClient);
                if (null == sourceVolume || !isSRDFProtectedVolume(sourceVolume)) {
                    continue;
                }
                String targetVolumeNativeGuid = getVolumeNativeGuid(destPath);
                Volume targetVolume = checkStorageVolumeExistsInDB(targetVolumeNativeGuid, dbClient);
                if (null == targetVolume || !isSRDFProtectedVolume(targetVolume)) {
                    continue;
                }
                if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(sourceVolume.getPersonality())) {
                    if (null == sourceVolume.getSrdfTargets() || !sourceVolume.getSrdfTargets().contains(targetVolume.getId().toString())) {
                        _log.info("target volume {} is not part of ViPR managed targtes for given source {}", targetVolumeNativeGuid, sourceVolumeNativeGuid);
                        continue;
                    }
                } else if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(targetVolume.getPersonality())) {
                    if (null == targetVolume.getSrdfTargets() || !targetVolume.getSrdfTargets().contains(sourceVolume.getId().toString())) {
                        _log.info("target volume {} is not part of ViPR managed targtes for given source {}", sourceVolumeNativeGuid, targetVolumeNativeGuid);
                        continue;
                    }
                }
                addPath(keyMap, operation.getResult(), volumePath);
            }
        } catch (Exception e) {
            _log.error("Prerequiste Step for getting srdf storage synchronized relations failed :", e);
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 27 with CIMObjectPath

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

the class VolumeToSynchronizedRefProcessor 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;
        CIMObjectPath volumePath = getObjectPathfromCIMArgument(args);
        String volumeNativeGuid = getVolumeNativeGuid(volumePath);
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        @SuppressWarnings("unchecked") Map<String, URI> volumeToRAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
        URI remoteRAGroupUri = volumeToRAGroupMap.get(volumeNativeGuid);
        _log.debug("Remote RA Group URI {}", remoteRAGroupUri);
        RemoteDirectorGroup remoteGroup = _dbClient.queryObject(RemoteDirectorGroup.class, remoteRAGroupUri);
        if (null == remoteGroup) {
            _log.info("Remote Group not found {}", remoteRAGroupUri);
            return;
        }
        String copyMode = null;
        int numberOfTargets = 0;
        if (it != null) {
            while (it.hasNext()) {
                CIMInstance storageSynchronized = it.next();
                CIMObjectPath storageSynchronizedPath = storageSynchronized.getObjectPath();
                CIMObjectPath sourcePath = (CIMObjectPath) storageSynchronizedPath.getKey(Constants._SystemElement).getValue();
                CIMObjectPath destPath = (CIMObjectPath) storageSynchronizedPath.getKey(Constants._SyncedElement).getValue();
                String sourceNativeGuid = createKeyfromPath(sourcePath);
                String targetNativeGuid = createKeyfromPath(destPath);
                _log.info("Source : {} , target : {}", sourceNativeGuid, targetNativeGuid);
                if (!findVolumesArefromSameArray(sourceNativeGuid, targetNativeGuid)) {
                    numberOfTargets++;
                    copyMode = storageSynchronized.getPropertyValue(MODE).toString();
                    _log.info("RDF Group {} detected Copy Mode {}", remoteGroup.getNativeGuid(), copyMode);
                }
            }
        }
        if (numberOfTargets > 1) {
            _log.info("RA Group {} is associated with Cascaded SRDF configuration, hence copyMode will not be updated.", remoteGroup.getNativeGuid());
            remoteGroup.setSupported(false);
        } else {
            // set copy Mode on Remote Group.
            // get Volume-->RA Group Mapping
            // if Copy Mode is already set on ViPr remoteGroup in DB, then don't change it.
            remoteGroup.setSupported(true);
            if (updateSupportedCopyMode(remoteGroup.getSupportedCopyMode())) {
                // in general, this property value can't be null, but in customer case we are seeing this, hence added this check
                if (null == copyMode) {
                    remoteGroup.setSupportedCopyMode(SupportedCopyModes.UNKNOWN.toString());
                } else {
                    remoteGroup.setSupportedCopyMode(SupportedCopyModes.getCopyMode(copyMode));
                }
            }
            _log.debug("Remote Group Copy Mode: {}", remoteGroup.getSupportedCopyMode());
        }
        _dbClient.persistObject(remoteGroup);
    } catch (Exception e) {
        _log.error("Copy Mode Discovery failed for remote Groups ", e);
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) URI(java.net.URI) Map(java.util.Map) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 28 with CIMObjectPath

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

the class ScannerProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    AccessProfile profile = null;
    try {
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        while (it.hasNext()) {
            try {
                final CIMInstance instance = it.next();
                final CIMObjectPath path = instance.getObjectPath();
                if (isIBMInstance(instance) || path.toString().toLowerCase().contains(Constants.CLARIION) || !isRemoteSystem(instance)) {
                    addPath(keyMap, operation.getResult(), path);
                } else {
                    _logger.info("Skipping Detection of Remote System {}", instance.getPropertyValue(Constants.NAME));
                }
            } catch (Exception e) {
                _logger.error("Scanner Failed to scan Provider : {}-->{}", profile.getserialID(), getMessage(e));
            }
        }
    } catch (Exception e) {
        _logger.error("Scanner Failed to scan Provider : {}-->{}", profile.getIpAddress(), getMessage(e));
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 29 with CIMObjectPath

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

the class SMICommunicationInterface method discover.

/**
 * {@inheritDoc}
 */
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemURI = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    long startTime = System.currentTimeMillis();
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        storageSystemURI = accessProfile.getSystemId();
        storageSystem = queryStorageSystem(accessProfile);
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
        if (_networkDeviceController != null) {
            _keyMap.put(Constants.networkDeviceController, _networkDeviceController);
        }
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        _keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
        _keyMap.put(Constants._serialID, accessProfile.getserialID());
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.PROTOCOLS, new HashSet<String>());
        _keyMap.put(Constants.STORAGEETHERNETPORTS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.IPENDPOINTS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.STORAGEVOLUMES, new LinkedList<CIMObjectPath>());
        String providerVersion = getProviderVersionString(storageSystem);
        if (null != providerVersion) {
            _keyMap.put(Constants.VERSION, providerVersion);
            _keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
        }
        Map<URI, StoragePool> poolsToMatchWithVpool = new HashMap<URI, StoragePool>();
        _keyMap.put(Constants.MODIFIED_STORAGEPOOLS, poolsToMatchWithVpool);
        // need this nested structure to be able to minimize the changes on existing code.
        List<List<StoragePort>> portsToRunNetworkConnectivity = new ArrayList<List<StoragePort>>();
        _keyMap.put(Constants.STORAGE_PORTS, portsToRunNetworkConnectivity);
        List<StoragePort> discoveredPorts = new ArrayList<StoragePort>();
        _keyMap.put(Constants.DISCOVERED_PORTS, discoveredPorts);
        _keyMap.put(Constants.SLO_NAMES, new HashSet<String>());
        if (Type.ibmxiv.name().equals(accessProfile.getSystemType())) {
            initIBMDiscoveryKeyMap(accessProfile);
        } else {
            initEMCDiscoveryKeyMap(accessProfile);
            if (Type.vmax.name().equals(accessProfile.getSystemType())) {
                // discover port group
                _keyMap.put(Constants.PORTGROUP, CimObjectPathCreator.createInstance(Constants.SE_TARGETMASKINGGROUP, accessProfile.getInteropNamespace()));
            }
        }
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
    } catch (Exception e) {
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemURI.toString(), e.getMessage());
        _logger.error(detailedStatusMessage, e);
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
        releaseResources();
        long totalTime = System.currentTimeMillis() - startTime;
        _logger.info(String.format("Discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) LocalReplicaObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 30 with CIMObjectPath

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

the class SMICommunicationInterface method discoverArrayAffinity.

/**
 * {@inheritDoc}
 */
@Override
public void discoverArrayAffinity(AccessProfile accessProfile) {
    _logger.info("Calling discoverArrayAffinity");
    URI storageSystemURI = accessProfile.getSystemId();
    String detailedStatusMessage = "Array Affinity Discovery completed successfully for Storage System: %s";
    long startTime = System.currentTimeMillis();
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        _keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
        _keyMap.put(Constants._serialID, accessProfile.getserialID());
        _keyMap.put(Constants.MASKING_VIEWS, new LinkedList<CIMObjectPath>());
        StorageSystem storageSystem = queryStorageSystem(accessProfile);
        String providerVersion = getProviderVersionString(storageSystem);
        if (null != providerVersion) {
            _keyMap.put(Constants.VERSION, providerVersion);
            _keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
        }
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
    } catch (Exception e) {
        detailedStatusMessage = "Array Affinity Discovery failed for Storage System: %s because " + e.getMessage();
        _logger.error(String.format(detailedStatusMessage, storageSystemURI.toString()), e);
        throw new SMIPluginException(String.format(detailedStatusMessage, storageSystemURI.toString()));
    } finally {
        try {
            String systemIdsStr = accessProfile.getProps().get(Constants.SYSTEM_IDS);
            String[] systemIds = systemIdsStr.split(Constants.ID_DELIMITER);
            List<StorageSystem> systemsToUpdate = new ArrayList<StorageSystem>();
            for (String systemId : systemIds) {
                StorageSystem system = _dbClient.queryObject(StorageSystem.class, URI.create(systemId));
                // set detailed message
                system.setLastArrayAffinityStatusMessage(String.format(detailedStatusMessage, systemId));
                systemsToUpdate.add(system);
            }
            _dbClient.updateObject(systemsToUpdate);
        } catch (DatabaseException ex) {
            _logger.error("Error while persisting object to DB", ex);
        }
        releaseResources();
        long totalTime = System.currentTimeMillis() - startTime;
        _logger.info(String.format("Array Affinity discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) LocalReplicaObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CIMObjectPath (javax.cim.CIMObjectPath)582 CIMInstance (javax.cim.CIMInstance)254 WBEMException (javax.wbem.WBEMException)236 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)208 CIMArgument (javax.cim.CIMArgument)190 ArrayList (java.util.ArrayList)139 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)118 Volume (com.emc.storageos.db.client.model.Volume)108 URI (java.net.URI)108 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)82 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)76 WBEMClient (javax.wbem.client.WBEMClient)75 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)72 HashSet (java.util.HashSet)68 HashMap (java.util.HashMap)63 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)57 CIMProperty (javax.cim.CIMProperty)57 IOException (java.io.IOException)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)52 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)52