Search in sources :

Example 16 with BaseCollectionException

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

the class SoftwareIdentityProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    AccessProfile profile = null;
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        if (it.hasNext()) {
            CIMInstance softwareInstance = it.next();
            String providerId = profile.getIpAddress() + "-" + profile.getProviderPort();
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerId);
            if (!providers.isEmpty()) {
                checkProviderVersion(softwareInstance, providers.get(0));
            }
        } else {
            String errMsg = String.format("No information obtained from Provider %s for Provider version", profile.getIpAddress());
            throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
        }
    } catch (SMIPluginException e) {
        throw e;
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while verifying Provider version: %s", e.getMessage());
        throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
    }
}
Also used : Iterator(java.util.Iterator) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 17 with BaseCollectionException

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

the class StorageConfigurationCapabilitiesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
    _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    try {
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
        Boolean usingSMIS80 = (Boolean) keyMap.get(Constants.USING_SMIS80_DELIMITERS);
        boolean isSMIS80 = (usingSMIS80 != null && usingSMIS80);
        while (it.hasNext()) {
            CIMInstance storageConfigurationInstance = it.next();
            if (Type.vnxblock.toString().equalsIgnoreCase(system.getSystemType())) {
                updateStorageSystemCapabilityOnVolumeForVNX(storageConfigurationInstance, system);
            } else {
                updateStorageSystemCapabilityOnVolume(storageConfigurationInstance, system);
            }
            system.setUsingSmis80(isSMIS80);
        }
        _dbClient.persistObject(system);
    } catch (Exception e) {
        _logger.error("Finding out Storage System Capability on Volume Creation failed :", e);
    }
}
Also used : Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException 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 19 with BaseCollectionException

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

the class ScaleIOCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    log.info("Starting scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
    StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    if (provider.getInterfaceType().equalsIgnoreCase(DiscoveredDataObject.Type.scaleio.name())) {
        provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.name());
        ScaleIOException ex = ScaleIOException.exceptions.scaleioCliNotSupported();
        provider.setLastScanStatusMessage(ex.getLocalizedMessage());
        _dbClient.persistObject(provider);
        throw ScaleIOException.exceptions.scaleioCliNotSupported();
    }
    _locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(_dbClient).getClientHandle(provider);
        if (scaleIOHandle != null) {
            Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
            ScaleIOSystem sioSystem = scaleIOHandle.getSystem();
            String[] ipList = null;
            if (sioSystem.getVersion().substring(0, 1).compareTo("2") >= 0) {
                Slaves[] slaves = sioSystem.getMdmCluster().getSlaves();
                if ((slaves.length > 0))
                    ipList = new String[slaves.length];
                for (int iterInd = 0; iterInd < slaves.length; iterInd++) {
                    ipList[iterInd] = slaves[iterInd].getIps()[0];
                }
            } else {
                ipList = sioSystem.getSecondaryMdmActorIpList();
            }
            if (ipList != null && ipList.length > 0) {
                StringSet secondaryIps = new StringSet();
                secondaryIps.add(ipList[0]);
                provider.setSecondaryIps(secondaryIps);
            }
            String scaleIOType = StorageSystem.Type.scaleio.name();
            String installationId = sioSystem.getInstallId();
            String version = sioSystem.getVersion().replaceAll("_", ".");
            String minimumSupported = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.scaleio);
            String compatibility = (VersionChecker.verifyVersionDetails(minimumSupported, version) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
            provider.setCompatibilityStatus(compatibility);
            provider.setVersionString(version);
            List<ScaleIOProtectionDomain> protectionDomains = scaleIOHandle.getProtectionDomains();
            for (ScaleIOProtectionDomain protectionDomain : protectionDomains) {
                log.info("For ScaleIO instance {}, found ProtectionDomain {}", installationId, protectionDomain.getName());
                String id = String.format("%s+%s", installationId, protectionDomain.getName());
                String nativeGuid = generateNativeGuid(scaleIOType, id);
                StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
                if (viewObject == null) {
                    viewObject = new StorageSystemViewObject();
                }
                viewObject.setDeviceType(scaleIOType);
                viewObject.addprovider(accessProfile.getSystemId().toString());
                viewObject.setProperty(StorageSystemViewObject.MODEL, "ScaleIO ECS");
                viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
                storageSystemsCache.put(nativeGuid, viewObject);
            }
        }
    } catch (Exception e) {
        cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
        log.error(String.format("Exception was encountered when attempting to scan ScaleIO Instance %s", accessProfile.getIpAddress()), e);
        throw ScaleIOException.exceptions.scanFailed(e);
    } finally {
        provider.setConnectionStatus(cxnStatus.name());
        _dbClient.persistObject(provider);
        log.info("Completed scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
        _locker.releaseLock(accessProfile.getIpAddress());
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) ScaleIOSystem(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem) ScaleIOProtectionDomain(com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) Slaves(com.emc.storageos.scaleio.api.restapi.response.Slaves)

Example 20 with BaseCollectionException

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

the class VNXFileCommunicationInterface method discoverUmanagedFileSystems.

private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
    _logger.info("Access Profile Details :  IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    int newFileSystemsCount = 0;
    int existingFileSystemsCount = 0;
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
    String detailedStatusMessage = "Discovery of VNXFile Unmanaged FileSystem started";
    try {
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        HashMap<String, StoragePool> pools = new HashMap();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
            if (storagePool != null && !storagePool.getInactive()) {
                pools.put(storagePool.getNativeId(), storagePool);
            }
        }
        StoragePort storagePort = this.getStoragePortPool(storageSystem);
        List<VNXFileSystem> discoveredFS = discoverAllFileSystems(storageSystem);
        StringSet umfsIds = new StringSet();
        if (discoveredFS != null) {
            for (VNXFileSystem fs : discoveredFS) {
                String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getFsId() + "");
                StoragePool pool = pools.get(fs.getStoragePool());
                if (!checkStorageFileSystemExistsInDB(fsNativeGuid)) {
                    // Create UnManaged FS
                    String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getFsId() + "");
                    UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
                    boolean alreadyExist = unManagedFs == null ? false : true;
                    unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs);
                    if (alreadyExist) {
                        existingUnManagedFileSystems.add(unManagedFs);
                        existingFileSystemsCount++;
                    } else {
                        unManagedFileSystems.add(unManagedFs);
                        newFileSystemsCount++;
                    }
                    allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
                    umfsIds.add(fs.getFsId() + "");
                    /**
                     * Persist 200 objects and clear them to avoid memory issue
                     */
                    validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
                }
            }
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
        markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
        _logger.info("New unmanaged VNXFile file systems count: {}", newFileSystemsCount);
        _logger.info("Update unmanaged VNXFile file systems count: {}", existingFileSystemsCount);
        if (!unManagedFileSystems.isEmpty()) {
            // Add UnManagedFileSystem
            _dbClient.createObject(unManagedFileSystems);
        }
        if (!existingUnManagedFileSystems.isEmpty()) {
            // Update UnManagedFilesystem
            _dbClient.updateAndReindexObject(existingUnManagedFileSystems);
        }
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for VNXFile: %s", storageSystemId.toString());
        if (null != umfsIds && !umfsIds.isEmpty()) {
            // Discovering unmanaged quota directories
            discoverUmanagedFileQuotaDirectory(profile, umfsIds);
        }
    } catch (Exception e) {
        if (storageSystem != null) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for VNXFile %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new VNXFileCollectionException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : VNXStoragePool(com.emc.storageos.vnx.xmlapi.VNXStoragePool) StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Aggregations

BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)185 Iterator (java.util.Iterator)66 CIMInstance (javax.cim.CIMInstance)66 CIMObjectPath (javax.cim.CIMObjectPath)59 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)55 IOException (java.io.IOException)47 URI (java.net.URI)47 ArrayList (java.util.ArrayList)47 PostMethod (org.apache.commons.httpclient.methods.PostMethod)36 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)35 Status (com.emc.nas.vnxfile.xmlapi.Status)33 AccessProfile (com.emc.storageos.plugins.AccessProfile)30 List (java.util.List)30 Map (java.util.Map)30 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 StoragePool (com.emc.storageos.db.client.model.StoragePool)27 Header (org.apache.commons.httpclient.Header)27 StoragePort (com.emc.storageos.db.client.model.StoragePort)22 HashSet (java.util.HashSet)18 URISyntaxException (java.net.URISyntaxException)17