Search in sources :

Example 66 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeExpandFileSystemJob method updateStatus.

/**
 * Called to update the job status when the file system create job completes.
 *
 * @param jobContext The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        URI fsId = getTaskCompleter().getId();
        FileShare fsObj = dbClient.queryObject(FileShare.class, fsId);
        // If terminal state update storage pool capacity
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, fsObj.getPool(), null);
        }
        if (_status == JobStatus.SUCCESS && fsObj != null) {
            updateFS(fsObj, dbClient, logMsgBuilder, vnxeApiClient);
        } else if (_status == JobStatus.FAILED && fsObj != null) {
            logMsgBuilder.append("\n");
            logMsgBuilder.append(String.format("Task %s failed to expand file system: %s", opId, fsId.toString()));
        } else {
            logMsgBuilder.append(String.format("The file system: %s is not found anymore", fsId));
        }
        _logger.info(logMsgBuilder.toString());
        FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, _isSuccess, logMsgBuilder.toString(), "", fsObj, String.valueOf(fsObj.getCapacity()));
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemJob", e);
        setErrorStatus("Encountered an internal error during file system create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 67 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXeExportFileSystemJob method updateStatus.

/**
 * Called to update the job status when the export file system job completes.
 *
 * @param jobContext The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
        FileShare fsObj = null;
        Snapshot snapObj = null;
        URI objId = getTaskCompleter().getId();
        StorageSystem storageObj = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
        if (_status == JobStatus.SUCCESS) {
            _isSuccess = true;
            FileExport newExport = exportInfo.getFileExport();
            newExport.setMountPoint(ExportUtils.getFileMountPoint(exportInfo.getStoragePort(), exportInfo.getMountPath()));
            if (isFile) {
                fsObj = dbClient.queryObject(FileShare.class, objId);
                updateFSExport(fsObj, dbClient, vnxeApiClient, newExport);
            } else {
                snapObj = updateSnapExport(dbClient, vnxeApiClient, newExport);
                fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent().getURI());
            }
        } else if (_status == JobStatus.FAILED) {
            // cleanupFSExport(fsObj, dbClient);
            logMsgBuilder.append("\n");
            logMsgBuilder.append(String.format("Task %s failed to export file system: %s", opId, objId.toString()));
        }
        _logger.info(logMsgBuilder.toString());
        if (isFile) {
            fsObj = dbClient.queryObject(FileShare.class, objId);
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.EXPORT_FILE_SYSTEM, _isSuccess, logMsgBuilder.toString(), "", fsObj, storageObj);
        } else {
            snapObj = dbClient.queryObject(Snapshot.class, objId);
            fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent().getURI());
            FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.EXPORT_FILE_SNAPSHOT, _isSuccess, logMsgBuilder.toString(), "", snapObj, fsObj, storageObj);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeExportFIleSystemJob", e);
        setErrorStatus("Encountered an internal error during file system export job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) FileExport(com.emc.storageos.db.client.model.FileExport) FileShare(com.emc.storageos.db.client.model.FileShare) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 68 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXUnityCommunicationInterface method scan.

/**
 * Implementation for scan for Vnx Unity storage systems.
 *
 * @param accessProfile
 *
 * @throws BaseCollectionException
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("Starting scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
    StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    _locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
    try {
        VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
        if (apiClient != null) {
            Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
            BasicSystemInfo unitySystem = apiClient.getBasicSystemInfo();
            String unityType = StorageSystem.Type.unity.name();
            String version = unitySystem.getApiVersion();
            String compatibility = StorageSystem.CompatibilityStatus.COMPATIBLE.name();
            provider.setCompatibilityStatus(compatibility);
            provider.setVersionString(version);
            VNXeStorageSystem system = apiClient.getStorageSystem();
            _logger.info("Found Unity: {} ", system.getSerialNumber());
            String id = system.getSerialNumber();
            String nativeGuid = generateNativeGuid(unityType, id);
            StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
            if (viewObject == null) {
                viewObject = new StorageSystemViewObject();
            }
            viewObject.setDeviceType(unityType);
            viewObject.addprovider(accessProfile.getSystemId().toString());
            viewObject.setProperty(StorageSystemViewObject.MODEL, unitySystem.getModel());
            viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
            storageSystemsCache.put(nativeGuid, viewObject);
        }
    } catch (Exception e) {
        cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
        _logger.error(String.format("Exception was encountered when attempting to scan Unity Instance %s", accessProfile.getIpAddress()), e);
        throw VNXeException.exceptions.scanFailed(accessProfile.getIpAddress(), e);
    } finally {
        provider.setConnectionStatus(cxnStatus.name());
        _dbClient.updateObject(provider);
        _logger.info("Completed scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
        _locker.releaseLock(accessProfile.getIpAddress());
    }
}
Also used : VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BasicSystemInfo(com.emc.storageos.vnxe.models.BasicSystemInfo) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 69 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient 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)

Example 70 with VNXeApiClient

use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.

the class VNXUnityCommunicationInterface method collectStatisticsInformation.

@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws VNXeException {
    URI storageSystemId = accessProfile.getSystemId();
    StorageSystem storageSystem = null;
    try {
        _logger.info("Start collecting statistics for ip address {}", accessProfile.getIpAddress());
        VNXeApiClient client = getVnxUnityClient(accessProfile);
        long latestSampleTime = accessProfile.getLastSampleTime();
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        String serialNumber = storageSystem.getSerialNumber();
        String deviceType = storageSystem.getSystemType();
        // compute static load processor code
        computeStaticLoadMetrics(accessProfile);
        // TODO: Do we need usage stats?
        _logger.info("End collecting statistics for ip address {}", accessProfile.getIpAddress());
    } catch (Exception e) {
        _logger.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
        throw VNXeException.exceptions.discoveryError("Failed to collect statistics ", e);
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem)

Aggregations

VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)123 VNXeException (com.emc.storageos.vnxe.VNXeException)79 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)66 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)55 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)48 ControllerException (com.emc.storageos.volumecontroller.ControllerException)44 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)40 URI (java.net.URI)37 ArrayList (java.util.ArrayList)34 FileShare (com.emc.storageos.db.client.model.FileShare)33 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 Snapshot (com.emc.storageos.db.client.model.Snapshot)27 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)24 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)23 DbClient (com.emc.storageos.db.client.DbClient)21 Volume (com.emc.storageos.db.client.model.Volume)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileExport (com.emc.storageos.db.client.model.FileExport)14 HashMap (java.util.HashMap)14