Search in sources :

Example 51 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class NetworkDeviceController method deleteNetworkSystem.

@Override
public void deleteNetworkSystem(URI network, String taskId) throws ControllerException {
    try {
        NetworkSystem networkDevice = getNetworkSystemObject(network);
        URIQueryResultList epUriList = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(network), epUriList);
        while (epUriList.iterator().hasNext()) {
            FCEndpoint connection = _dbClient.queryObject(FCEndpoint.class, epUriList.iterator().next());
            if (connection != null) {
                _dbClient.removeObject(connection);
            }
        }
        List<URI> tzUriList = _dbClient.queryByType(Network.class, true);
        NetworkDiscoveryWorker worker = new NetworkDiscoveryWorker(getDevice(networkDevice.getSystemType()), _dbClient);
        worker.setCoordinator(_coordinator);
        for (URI tzUri : tzUriList) {
            Network tz = _dbClient.queryObject(Network.class, tzUri);
            if (tz != null && (tz.getNetworkSystems() != null && tz.getNetworkSystems().contains(network.toString()))) {
                worker.removeNetworkSystemTransportZone(tz, network.toString());
            }
        }
        if (taskId != null) {
            _dbClient.ready(NetworkSystem.class, network, taskId);
            _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.DELETE_NETWORK_SYSTEM, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, networkDevice.getId().toString(), networkDevice.getLabel(), networkDevice.getPortNumber(), networkDevice.getUsername(), networkDevice.getSmisProviderIP(), networkDevice.getSmisPortNumber(), networkDevice.getSmisUserName(), networkDevice.getSmisUseSSL());
        }
    } catch (Exception ex) {
        String msg = MessageFormat.format("Exception encountered while removing FC Port Connection for {0} because: {1}", network, ex.getLocalizedMessage());
        _log.error(msg);
        if (taskId != null) {
            try {
                ServiceError serviceError = NetworkDeviceControllerException.errors.deleteNetworkSystemFailed(network.toString(), ex);
                _dbClient.error(NetworkSystem.class, network, taskId, serviceError);
            } catch (DatabaseException e) {
                _log.error(e.getMessage());
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Network(com.emc.storageos.db.client.model.Network) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 52 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class NetworkDiscoveryWorker method verifyVersion.

/**
 * Verify the firmware version for the NetworkSystem
 *
 * @param uri - Device URI
 * @throws ControllerException thrown if firmware version is not supported
 */
public void verifyVersion(URI uri) throws ControllerException {
    // Retrieve the storage device info from the database.
    NetworkSystem networkDev = getDeviceObject(uri);
    NetworkSystemDevice networkDevice = getDevice();
    if (networkDevice == null) {
        throw NetworkDeviceControllerException.exceptions.verifyVersionFailedNull(uri.toString());
    }
    String version = null;
    try {
        version = networkDevice.getVersion(networkDev);
        networkDev.setVersion(version);
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(networkDev.getSystemType()));
        _log.info("Verifying version details : Minimum Supported Version {} - Discovered Firmware Version {}", minimumSupportedVersion, version);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, version) < 0) {
            networkDev.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            throw NetworkDeviceControllerException.exceptions.versionNotSupported(version, minimumSupportedVersion);
        } else {
            networkDev.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (Exception ex) {
        Date date = new Date();
        networkDev.setLastDiscoveryStatusMessage(ex.getMessage());
        throw NetworkDeviceControllerException.exceptions.verifyVersionFailed(uri.toString(), date.toString(), ex);
    } finally {
        if (networkDev != null) {
            try {
                dbClient.updateObject(networkDev);
            } catch (DatabaseException ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) Date(java.util.Date)

Example 53 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class VNXFileMonitoringImpl method stopMonitoringStaleSystem.

/**
 * 1. Find stale vnxFile devices.
 * 2. UNsubscribe existing subscription to avoid indications for the stale vnx devices.
 * 3. Clear stale devices from zoo keeper queue and local CACHE.
 */
@Override
public void stopMonitoringStaleSystem() {
    _logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    Iterator<Map.Entry<String, DistributedQueueItemProcessedCallback>> iter = VNXFILE_CACHE.entrySet().iterator();
    StorageSystem storageDevice = null;
    while (iter.hasNext()) {
        Map.Entry<String, DistributedQueueItemProcessedCallback> entry = iter.next();
        String storageDeviceURI = entry.getKey();
        _logger.debug("storageDeviceURI :{}", storageDeviceURI);
        try {
            storageDevice = _dbClient.queryObject(StorageSystem.class, URI.create(storageDeviceURI));
        } catch (DatabaseException e) {
            _logger.error(e.getMessage(), e);
        }
        if (null == storageDevice || storageDevice.getInactive() || !isSMISProviderConnected(storageDeviceURI)) {
            _logger.info("Stale vnxfiler {} has been removed from monitoring", storageDeviceURI);
            _connectionFactory.unsubscribeSMIProviderConnection(storageDeviceURI);
            try {
                // Removes monitorinJob token from queue
                entry.getValue().itemProcessed();
            } catch (Exception e) {
                _logger.error("Exception occurred while removing monitoringJob token from ZooKeeper queue", e);
            } finally {
                // Removes from local CACHE
                iter.remove();
                FAILED_VNXFILE_SUBSCRIPTION.remove(storageDeviceURI);
            }
        }
    }
    _logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
}
Also used : DistributedQueueItemProcessedCallback(com.emc.storageos.coordinator.client.service.DistributedQueueItemProcessedCallback) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 54 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverAll.

public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        storageSystemId = accessProfile.getSystemId();
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        // Retrieve control station information.
        discoverControlStation(storageSystem);
        // Model number
        VNXFileSshApi sshDmApi = new VNXFileSshApi();
        sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
        String model = sshDmApi.getModelInfo();
        storageSystem.setModel(model);
        boolean connectionStatus = getVnxFileSMISConnection(accessProfile, storageSystem);
        if (connectionStatus) {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.CONNECTED.toString());
        } else {
            storageSystem.setSmisConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
        }
        _dbClient.persistObject(storageSystem);
        if (!storageSystem.getReachableStatus()) {
            throw new VNXFileCollectionException("Failed to connect to " + storageSystem.getIpAddress());
        }
        // Get All Existing DataMovers
        Map<String, StorageHADomain> allExistingDataMovers = getAllDataMovers(storageSystem);
        for (StorageHADomain activeDM : allExistingDataMovers.values()) {
            _logger.info("Existing DataMovers in database {}", activeDM.getName());
        }
        // Discover port groups (data movers)
        StringSet fileSharingProtocols = new StringSet();
        Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, fileSharingProtocols);
        _logger.info("No of newly discovered groups {}", groups.get(NEW).size());
        _logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
        if (!groups.get(NEW).isEmpty()) {
            _dbClient.createObject(groups.get(NEW));
            for (StorageHADomain newDm : groups.get(NEW)) {
                _logger.info("New DM {} ", newDm.getAdapterName());
            }
        }
        if (!groups.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(groups.get(EXISTING));
            for (StorageHADomain existingDm : groups.get(EXISTING)) {
                _logger.info("Existing DM {} ", existingDm.getAdapterName());
            }
        }
        // Discover storage pools.
        List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool, fileSharingProtocols);
        _logger.info("No of newly discovered pools {}", pools.get(NEW).size());
        _logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
        if (!pools.get(NEW).isEmpty()) {
            allPools.addAll(pools.get(NEW));
            _dbClient.createObject(pools.get(NEW));
        }
        if (!pools.get(EXISTING).isEmpty()) {
            allPools.addAll(pools.get(EXISTING));
            _dbClient.persistObject(pools.get(EXISTING));
        }
        List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
        if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
            poolsToMatchWithVpool.addAll(notVisiblePools);
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeDataMovers = new HashSet<StorageHADomain>();
        activeDataMovers.addAll(groups.get(NEW));
        activeDataMovers.addAll(groups.get(EXISTING));
        int i = 0;
        for (StorageHADomain activeDM : activeDataMovers) {
            _logger.info("DataMover {} : {}", i++, activeDM.getName());
        }
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, activeDataMovers);
        _logger.info("No of newly discovered port {}", ports.get(NEW).size());
        _logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
        if (!ports.get(NEW).isEmpty()) {
            _dbClient.createObject(ports.get(NEW));
        }
        if (!ports.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(ports.get(EXISTING));
        }
        // Discover VDM and Ports
        Map<String, StorageHADomain> allVdmsInDb = this.getAllVDMs(storageSystem);
        for (StorageHADomain activeVDM : allVdmsInDb.values()) {
            _logger.info("Existing DataMovers in the Database {}", activeVDM.getName());
        }
        Map<String, List<StorageHADomain>> vdms = discoverVdmPortGroups(storageSystem, activeDataMovers);
        _logger.info("No of newly Vdm discovered groups {}", vdms.get(NEW).size());
        _logger.info("No of existing vdm discovered groups {}", vdms.get(EXISTING).size());
        if (!vdms.get(NEW).isEmpty()) {
            _dbClient.createObject(vdms.get(NEW));
        }
        if (!vdms.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdms.get(EXISTING));
            for (StorageHADomain existingVdm : vdms.get(EXISTING)) {
                _logger.info("Existing VDM {}", existingVdm.getAdapterName());
            }
        }
        // Keep a set of active data movers. Data movers in 'standby' state are not added to the
        // database since they cannot be used in this state.
        Set<StorageHADomain> activeVDMs = new HashSet<StorageHADomain>();
        List<StorageHADomain> newVdms = vdms.get(NEW);
        for (StorageHADomain vdm : newVdms) {
            _logger.debug("New VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        List<StorageHADomain> existingVdms = vdms.get(EXISTING);
        for (StorageHADomain vdm : existingVdms) {
            _logger.debug("Existing VDM : {}", vdm.getName());
            activeVDMs.add(vdm);
        }
        // Discover VDM Interfaces
        // Discover ports (data mover interfaces) with the data movers in the active set.
        Map<String, List<StoragePort>> vdmPorts = discoverVdmPorts(storageSystem, activeVDMs);
        _logger.info("No of newly discovered port {}", vdmPorts.get(NEW).size());
        _logger.info("No of existing discovered port {}", vdmPorts.get(EXISTING).size());
        if (!vdmPorts.get(NEW).isEmpty()) {
            _dbClient.createObject(vdmPorts.get(NEW));
            for (StoragePort port : vdmPorts.get(NEW)) {
                _logger.debug("New VDM Port : {}", port.getPortName());
            }
        }
        if (!vdmPorts.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(vdmPorts.get(EXISTING));
            for (StoragePort port : vdmPorts.get(EXISTING)) {
                _logger.info("EXISTING VDM Port : {}", port.getPortName());
            }
        }
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
        allExistingPorts.addAll(vdmPorts.get(EXISTING));
        List<StoragePort> allNewPorts = new ArrayList<StoragePort>(ports.get(NEW));
        allNewPorts.addAll(vdmPorts.get(NEW));
        List<StoragePort> allPorts = new ArrayList<StoragePort>(allExistingPorts);
        allPorts.addAll(allNewPorts);
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
        allExistingPorts.addAll(notVisiblePorts);
        StoragePortAssociationHelper.updatePortAssociations(allNewPorts, _dbClient);
        StoragePortAssociationHelper.updatePortAssociations(allExistingPorts, _dbClient);
        StringBuffer errorMessage = new StringBuffer();
        ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVpool(poolsToMatchWithVpool, _dbClient, _coordinator, storageSystemId, errorMessage);
        // Update the virtual nas association with virtual arrays!!!
        // For existing virtual nas ports!!
        StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistingPorts, null, _dbClient);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
    } catch (Exception e) {
        if (storageSystem != null) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for Storage System: %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 (DatabaseException 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) ArrayList(java.util.ArrayList) URI(java.net.URI) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) 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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 55 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class VNXeCommunicationInterface method discover.

/**
 * Implementation for discovery for Vnxe storage systems, file related only
 * for now
 *
 * @param accessProfile
 *
 * @throws VNXeException
 */
@Override
public void discover(AccessProfile accessProfile) throws VNXeException {
    URI storageSystemURI = accessProfile.getSystemId();
    StorageSystem viprStorageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        if (null != accessProfile.getnamespace() && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()) || accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_FILESYSTEMS.toString()))) {
            discoverUnmanagedObjects(accessProfile);
        } else {
            // Get the Vnxe storage system from the database.
            viprStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
            _logger.info(String.format("Discover Vnxe storage system %s at IP:%s, PORT:%s", storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber()));
            // Get the vnxe service client for getting information about the
            // Vnxe
            // storage system.
            VNXeApiClient client = getVnxeClient(accessProfile);
            _logger.debug("Got handle to Vnxe service client");
            // Get the serial number and the native guid and set
            // into the storage system.
            _logger.info("Discovering storage system properties.");
            VNXeStorageSystem system = client.getStorageSystem();
            boolean isFASTVPEnabled = false;
            if (system != null) {
                viprStorageSystem.setSerialNumber(system.getSerialNumber());
                String guid = NativeGUIDGenerator.generateNativeGuid(viprStorageSystem);
                viprStorageSystem.setNativeGuid(guid);
                viprStorageSystem.setLabel(guid);
                viprStorageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                viprStorageSystem.setReachableStatus(true);
                isFASTVPEnabled = client.isFASTVPEnabled();
                viprStorageSystem.setAutoTieringEnabled(isFASTVPEnabled);
                StringSet supportedActions = new StringSet();
                supportedActions.add(StorageSystem.AsyncActions.CreateElementReplica.name());
                supportedActions.add(StorageSystem.AsyncActions.CreateGroupReplica.name());
                viprStorageSystem.setSupportedAsynchronousActions(supportedActions);
                StringSet supportedReplica = new StringSet();
                supportedReplica.add(StorageSystem.SupportedReplicationTypes.LOCAL.name());
                viprStorageSystem.setSupportedReplicationTypes(supportedReplica);
                _dbClient.persistObject(viprStorageSystem);
                _completer.statusPending(_dbClient, "Completed discovery of system properties");
            } else {
                _logger.error("Failed to retrieve VNXe system info!");
                viprStorageSystem.setReachableStatus(false);
            }
            // get version for the storage system
            BasicSystemInfo info = client.getBasicSystemInfo();
            if (info != null) {
                viprStorageSystem.setFirmwareVersion(info.getSoftwareVersion());
            }
            StringSet arraySupportedProtocols = new StringSet();
            // Discover the NasServers
            Map<String, URI> nasServerIdMap = new HashMap<String, URI>();
            Map<String, List<StorageHADomain>> nasServers = discoverNasServers(viprStorageSystem, client, nasServerIdMap, arraySupportedProtocols);
            _logger.info("No of newly discovered NasServers {}", nasServers.get(NEW).size());
            _logger.info("No of existing discovered NasServers {}", nasServers.get(EXISTING).size());
            if (!nasServers.get(NEW).isEmpty()) {
                _dbClient.createObject(nasServers.get(NEW));
            }
            if (!nasServers.get(EXISTING).isEmpty()) {
                _dbClient.persistObject(nasServers.get(EXISTING));
            }
            _completer.statusPending(_dbClient, "Completed NAS Server discovery");
            // Discover FileInterfaces
            List<StoragePort> allExistingPorts = new ArrayList<StoragePort>();
            List<StoragePort> allNewPorts = new ArrayList<StoragePort>();
            Map<String, List<StoragePort>> ports = discoverFileStoragePorts(viprStorageSystem, client, nasServerIdMap);
            if (ports.get(NEW) != null && !ports.get(NEW).isEmpty()) {
                allNewPorts.addAll(ports.get(NEW));
                _dbClient.createObject(ports.get(NEW));
            }
            if (ports.get(EXISTING) != null && !ports.get(EXISTING).isEmpty()) {
                allExistingPorts.addAll(ports.get(EXISTING));
                _dbClient.persistObject(ports.get(EXISTING));
            }
            _completer.statusPending(_dbClient, "Completed file ports discovery");
            // discover storage processors
            Map<String, URI> spIdMap = new HashMap<String, URI>();
            Map<String, List<StorageHADomain>> sps = discoverStorageProcessors(viprStorageSystem, client, spIdMap);
            if (!sps.get(NEW).isEmpty()) {
                _dbClient.createObject(sps.get(NEW));
            }
            if (!sps.get(EXISTING).isEmpty()) {
                _dbClient.persistObject(sps.get(EXISTING));
            }
            _completer.statusPending(_dbClient, "Completed storage processor discovery");
            // discover iscsi ports
            Map<String, List<StoragePort>> iscsiPorts = discoverIscsiPorts(viprStorageSystem, client, spIdMap);
            boolean hasIscsiPorts = false;
            if (iscsiPorts.get(NEW) != null && !iscsiPorts.get(NEW).isEmpty()) {
                allNewPorts.addAll(iscsiPorts.get(NEW));
                hasIscsiPorts = true;
                _dbClient.createObject(iscsiPorts.get(NEW));
            }
            if (iscsiPorts.get(EXISTING) != null && !iscsiPorts.get(EXISTING).isEmpty()) {
                allExistingPorts.addAll(iscsiPorts.get(EXISTING));
                hasIscsiPorts = true;
                _dbClient.persistObject(ports.get(EXISTING));
            }
            if (hasIscsiPorts) {
                arraySupportedProtocols.add(StorageProtocol.Block.iSCSI.name());
            }
            _completer.statusPending(_dbClient, "Completed iscsi ports discovery");
            // discover fc ports
            Map<String, List<StoragePort>> fcPorts = discoverFcPorts(viprStorageSystem, client, spIdMap);
            boolean hasFcPorts = false;
            if (fcPorts.get(NEW) != null && !fcPorts.get(NEW).isEmpty()) {
                allNewPorts.addAll(fcPorts.get(NEW));
                hasFcPorts = true;
                _dbClient.createObject(fcPorts.get(NEW));
            }
            if (fcPorts.get(EXISTING) != null && !fcPorts.get(EXISTING).isEmpty()) {
                allExistingPorts.addAll(fcPorts.get(EXISTING));
                hasFcPorts = true;
                _dbClient.persistObject(ports.get(EXISTING));
            }
            if (hasFcPorts) {
                arraySupportedProtocols.add(StorageProtocol.Block.FC.name());
            }
            _completer.statusPending(_dbClient, "Completed FC ports discovery");
            List<StoragePort> allPorts = new ArrayList<StoragePort>(allNewPorts);
            allPorts.addAll(allExistingPorts);
            // check if any port not visible in this discovery
            List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, viprStorageSystem.getId());
            if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
                allExistingPorts.addAll(notVisiblePorts);
            }
            /**
             * Discover the VNXe pool information.
             */
            _logger.info("Discovering storage pools.");
            List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
            List<StoragePool> allPools = new ArrayList<StoragePool>();
            Map<String, List<StoragePool>> pools = discoverStoragePools(viprStorageSystem, client, arraySupportedProtocols, poolsToMatchWithVpool);
            _logger.info("No of newly discovered pools {}", pools.get(NEW).size());
            _logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
            if (!pools.get(NEW).isEmpty()) {
                allPools.addAll(pools.get(NEW));
                _dbClient.createObject(pools.get(NEW));
                StoragePoolAssociationHelper.setStoragePoolVarrays(viprStorageSystem.getId(), pools.get(NEW), _dbClient);
            }
            if (!pools.get(EXISTING).isEmpty()) {
                allPools.addAll(pools.get(EXISTING));
                _dbClient.persistObject(pools.get(EXISTING));
            }
            List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, viprStorageSystem.getId());
            if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
                poolsToMatchWithVpool.addAll(notVisiblePools);
            }
            StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allNewPorts, allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
            _completer.statusPending(_dbClient, "Completed pool discovery");
            if (isFASTVPEnabled) {
                _logger.info("FASTVP is enabled");
                HashMap<String, List<AutoTieringPolicy>> policies = discoverAutoTierPolicies(viprStorageSystem, client);
                if (!policies.get(NEW).isEmpty()) {
                    _dbClient.createObject(policies.get(NEW));
                }
                if (!policies.get(EXISTING).isEmpty()) {
                    _dbClient.persistObject(policies.get(EXISTING));
                }
                HashMap<String, List<StorageTier>> tiers = discoverStorageTier(viprStorageSystem, client);
                if (!tiers.get(NEW).isEmpty()) {
                    _dbClient.createObject(tiers.get(NEW));
                }
                if (!tiers.get(EXISTING).isEmpty()) {
                    _dbClient.persistObject(tiers.get(EXISTING));
                }
            }
            detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
        }
    } catch (Exception e) {
        detailedStatusMessage = String.format("Discovery failed for VNXe %s: %s", storageSystemURI.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw VNXeException.exceptions.discoveryError("Discovery error", e);
    } finally {
        if (viprStorageSystem != null) {
            try {
                // set detailed message
                viprStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(viprStorageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem) StoragePool(com.emc.storageos.db.client.model.StoragePool) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) BasicSystemInfo(com.emc.storageos.vnxe.models.BasicSystemInfo) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)109 URI (java.net.URI)71 ArrayList (java.util.ArrayList)29 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 IOException (java.io.IOException)21 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)20 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)19 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)18 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)12 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 List (java.util.List)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)11 Volume (com.emc.storageos.db.client.model.Volume)11 WBEMException (javax.wbem.WBEMException)11