Search in sources :

Example 21 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class XIVCommunicationInterface method scan.

/**
 * {@inheritDoc}
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    // Call scan method of SMICommunication interface to validate SMIS connectivity
    super.scan(accessProfile);
    URI providerURI = null;
    StorageProvider providerObj = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        providerURI = accessProfile.getSystemId();
        providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
        // Validate Secondary URL for its availability
        validateManagementURL(providerObj.getSecondaryURL(), providerObj.getSecondaryUsername(), providerObj.getSecondaryPassword());
        // scan succeeds
        detailedStatusMessage = String.format("Scan job completed successfully for REST API: %s", providerObj.getSecondaryURL());
    } catch (Exception e) {
        detailedStatusMessage = String.format("Scan job failed for REST API: %s because %s", providerObj.getSecondaryURL(), e.getMessage());
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (providerObj != null) {
            try {
                // set detailed message
                providerObj.setLastScanStatusMessage(detailedStatusMessage);
                _dbClient.updateObject(providerObj);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) XIVRestException(com.emc.storageos.xiv.api.XIVRestException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 22 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class XtremIOCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
    StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    XtremIOClient xtremIOClient = null;
    try {
        xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getXtremIOV1Client(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), true);
        String xmsVersion = xtremIOClient.getXtremIOXMSVersion();
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.xtremio).replace("-", ".");
        String compatibility = (VersionChecker.verifyVersionDetails(minimumSupportedVersion, xmsVersion) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
        provider.setCompatibilityStatus(compatibility);
        provider.setVersionString(xmsVersion);
        String systemType = StorageSystem.Type.xtremio.name();
        List<XtremIOSystem> xioSystems = xtremIOClient.getXtremIOSystemInfo();
        _logger.info("Found {} clusters during scan of XMS {}", xioSystems.size(), accessProfile.getIpAddress());
        Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
        for (XtremIOSystem system : xioSystems) {
            String arrayNativeGUID = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.xtremio.name(), system.getSerialNumber());
            StorageSystemViewObject viewObject = storageSystemsCache.get(arrayNativeGUID);
            if (viewObject == null) {
                viewObject = new StorageSystemViewObject();
            }
            viewObject.setDeviceType(systemType);
            viewObject.addprovider(accessProfile.getSystemId().toString());
            viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, system.getSerialNumber());
            viewObject.setProperty(StorageSystemViewObject.VERSION, system.getVersion());
            viewObject.setProperty(StorageSystemViewObject.STORAGE_NAME, arrayNativeGUID);
            storageSystemsCache.put(arrayNativeGUID, viewObject);
        }
    } catch (Exception ex) {
        _logger.error("Error scanning XMS", ex);
        cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
        // throw exception only if system discovery failed.
        throw XtremIOApiException.exceptions.discoveryFailed(provider.toString());
    } finally {
        provider.setConnectionStatus(cxnStatus.name());
        _dbClient.persistObject(provider);
        if (xtremIOClient != null) {
            xtremIOClient.close();
        }
        _logger.info("Completed scan of XtremIO StorageProvider. IP={}", accessProfile.getIpAddress());
    }
}
Also used : XtremIOSystem(com.emc.storageos.xtremio.restapi.model.response.XtremIOSystem) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 23 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionJobConsumer method triggerScanning.

/**
 * 1. refreshConnections - needs to get called on each Controller, before acquiring lock.
 * 2. Try to acquire lock, if found
 * 3. Acquiring lock is not made as a Blocking Call, hence Controllers will return immediately,
 * if lock not found
 * 3. If lock found, spawn a new thread to do triggerScanning.
 * 4. Release lock immediately.
 */
private void triggerScanning(DataCollectionScanJob job) throws Exception {
    _logger.info("Started scanning Providers : triggerScanning()");
    List<URI> providerList = job.getProviders();
    String providerType = null;
    if (!providerList.isEmpty()) {
        providerType = _dbClient.queryObject(StorageProvider.class, providerList.iterator().next()).getInterfaceType();
    }
    _jobScheduler.refreshProviderConnections(providerType);
    List<URI> allProviderURI = _dbClient.queryByType(StorageProvider.class, true);
    List<StorageProvider> allProvidersAllTypes = _dbClient.queryObject(StorageProvider.class, allProviderURI);
    List<StorageProvider> allProviders = new ArrayList<StorageProvider>();
    // since dbQuery does not return a normal list required by bookkeeping, we need to rebuild it.
    allProviderURI = new ArrayList<URI>();
    for (StorageProvider provider : allProvidersAllTypes) {
        if (providerType == null || providerType.equals(provider.getInterfaceType())) {
            allProviderURI.add(provider.getId());
            allProviders.add(provider);
        }
    }
    Map<String, StorageSystemViewObject> storageSystemsCache = Collections.synchronizedMap(new HashMap<String, StorageSystemViewObject>());
    boolean exceptionIntercepted = false;
    /**
     * Run "Scheduled" Scanner Jobs of all Providers in only one Controller.
     * means our Cache is populated with the latest
     * physicalStorageSystems ID got from this scheduled Scan Job.
     * Compare the list against the ones in DB, and decide the physicalStorageSystem's
     * state REACHABLE
     */
    String lockKey = ControllerServiceImpl.Lock.SCAN_COLLECTION_LOCK.toString();
    if (providerType != null) {
        lockKey += providerType;
    }
    InterProcessLock scanLock = _coordinator.getLock(lockKey);
    if (scanLock.acquire(ControllerServiceImpl.Lock.SCAN_COLLECTION_LOCK.getRecommendedTimeout(), TimeUnit.SECONDS)) {
        _logger.info("Acquired a lock {} to run scanning Job", ControllerServiceImpl.Lock.SCAN_COLLECTION_LOCK.toString() + providerType);
        List<URI> cacheProviders = new ArrayList<URI>();
        Map<URI, Exception> cacheErrorProviders = new HashMap<URI, Exception>();
        try {
            boolean scanIsNeeded = false;
            boolean hasProviders = false;
            // First find out if scan is needed. If it needed for a single system , it is needed for all
            for (StorageProvider provider : allProviders) {
                if (provider.connected() || provider.initializing()) {
                    hasProviders = true;
                    if (_jobScheduler.isProviderScanJobSchedulingNeeded(provider, ControllerServiceImpl.SCANNER, job.isSchedulerJob())) {
                        scanIsNeeded = true;
                        break;
                    }
                }
            }
            if (!scanIsNeeded) {
                for (StorageProvider provider : allProviders) {
                    ScanTaskCompleter scanCompleter = job.findProviderTaskCompleter(provider.getId());
                    if (scanCompleter == null) {
                        continue;
                    }
                    if (provider.connected() || provider.initializing()) {
                        scanCompleter.ready(_dbClient);
                    } else {
                        String errMsg = "Failed to establish connection to the storage provider";
                        scanCompleter.error(_dbClient, DeviceControllerErrors.smis.unableToCallStorageProvider(errMsg));
                        provider.setLastScanStatusMessage(errMsg);
                        _dbClient.updateObject(provider);
                    }
                }
                if (!hasProviders) {
                    _util.performBookKeeping(storageSystemsCache, allProviderURI);
                }
                _logger.info("Scan is not needed");
            } else {
                // If scan is needed for a single system,
                // it must be performed for all available providers in the database at the same time.
                // update each provider that is reachable to scan in progress
                List<StorageProvider> connectedProviders = new ArrayList<StorageProvider>();
                for (StorageProvider provider : allProviders) {
                    if (provider.connected() || provider.initializing()) {
                        ScanTaskCompleter scanCompleter = job.findProviderTaskCompleter(provider.getId());
                        if (scanCompleter == null) {
                            String taskId = UUID.randomUUID().toString();
                            scanCompleter = new ScanTaskCompleter(StorageProvider.class, provider.getId(), taskId);
                            job.addCompleter(scanCompleter);
                        }
                        scanCompleter.createDefaultOperation(_dbClient);
                        scanCompleter.updateObjectState(_dbClient, DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS);
                        scanCompleter.setNextRunTime(_dbClient, System.currentTimeMillis() + DataCollectionJobScheduler.JobIntervals.get(ControllerServiceImpl.SCANNER).getInterval() * 1000);
                        provider.setLastScanStatusMessage("");
                        _dbClient.updateObject(provider);
                        connectedProviders.add(provider);
                    } else {
                        if (null != provider.getStorageSystems() && !provider.getStorageSystems().isEmpty()) {
                            provider.getStorageSystems().clear();
                        }
                        if (providerList.contains(provider.getId())) {
                            String errMsg = "Failed to establish connection to the storage provider";
                            provider.setLastScanStatusMessage(errMsg);
                            job.findProviderTaskCompleter(provider.getId()).error(_dbClient, DeviceControllerErrors.smis.unableToCallStorageProvider(errMsg));
                        }
                        _dbClient.updateObject(provider);
                    }
                }
                // now scan each connected provider
                for (StorageProvider provider : connectedProviders) {
                    try {
                        _logger.info("provider.getInterfaceType():{}", provider.getInterfaceType());
                        ScanTaskCompleter scanCompleter = job.findProviderTaskCompleter(provider.getId());
                        performScan(provider.getId(), scanCompleter, storageSystemsCache);
                        cacheProviders.add(provider.getId());
                    } catch (Exception ex) {
                        _logger.error("Scan failed for {}--->", provider.getId(), ex);
                        cacheErrorProviders.put(provider.getId(), ex);
                    }
                }
                // Perform BooKKeeping
                // TODO: we need to access the status of job completer.
                // for now we assume that this operation can not fail.
                _util.performBookKeeping(storageSystemsCache, allProviderURI);
            }
        } catch (final Exception ex) {
            _logger.error("Scan failed for {} ", ex.getMessage());
            exceptionIntercepted = true;
            for (URI provider : cacheProviders) {
                job.findProviderTaskCompleter(provider).error(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanFailed(ex.getLocalizedMessage(), ex));
                _logger.error("Scan failed for {}--->", provider, ex);
            }
            throw ex;
        } finally {
            if (!exceptionIntercepted) {
                for (URI provider : cacheProviders) {
                    job.findProviderTaskCompleter(provider).ready(_dbClient);
                    _logger.info("Scan complete successfully for " + provider);
                }
            }
            for (Entry<URI, Exception> entry : cacheErrorProviders.entrySet()) {
                URI provider = entry.getKey();
                Exception ex = entry.getValue();
                job.findProviderTaskCompleter(provider).error(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanFailed(ex.getLocalizedMessage(), ex));
            }
            scanLock.release();
            _logger.info("Released a lock {} to run scanning Job", lockKey);
            try {
                if (!exceptionIntercepted) /* && job.isSchedulerJob() */
                {
                    // Manually trigger discoveries, if any new Arrays detected
                    triggerDiscoveryNew(storageSystemsCache, (job.isSchedulerJob() ? DataCollectionJob.JobOrigin.SCHEDULER : DataCollectionJob.JobOrigin.USER_API));
                }
            } catch (Exception ex) {
                _logger.error("Exception occurred while triggering discovery of new systems", ex);
            }
        }
    } else {
        job.setTaskError(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanLockFailed());
        _logger.error("Not able to Acquire Scanning {} lock-->{}", lockKey, Thread.currentThread().getId());
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BeansException(org.springframework.beans.BeansException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Example 24 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionJobScheduler method loadSystemfromDB.

/**
 * Load Physical Systems from DB, and add to Discovery Job Queue
 *
 * @throws Exception
 */
private void loadSystemfromDB(String jobType) throws Exception {
    _logger.info("Started Loading Systems from DB for " + jobType + " jobs");
    ArrayList<DataCollectionJob> jobs = new ArrayList<DataCollectionJob>();
    List<URI> allSystemsURIs = new ArrayList<URI>();
    Map<URI, List<URI>> providerToSystemsMap = new HashMap<URI, List<URI>>();
    if (jobType.equalsIgnoreCase(ControllerServiceImpl.NS_DISCOVERY)) {
        addToList(allSystemsURIs, _dbClient.queryByType(NetworkSystem.class, true).iterator());
    } else if (jobType.equalsIgnoreCase(ControllerServiceImpl.CS_DISCOVERY)) {
        addToList(allSystemsURIs, _dbClient.queryByType(Host.class, true).iterator());
        addToList(allSystemsURIs, _dbClient.queryByType(Vcenter.class, true).iterator());
    } else if (jobType.equalsIgnoreCase(ControllerServiceImpl.COMPUTE_DISCOVERY)) {
        addToList(allSystemsURIs, _dbClient.queryByType(ComputeSystem.class, true).iterator());
    } else if (jobType.equalsIgnoreCase(ControllerServiceImpl.ARRAYAFFINITY_DISCOVERY)) {
        List<URI> systemURIs = _dbClient.queryByType(StorageSystem.class, true);
        List<StorageSystem> systems = new ArrayList<StorageSystem>();
        Iterator<StorageSystem> storageSystems = _dbClient.queryIterativeObjects(StorageSystem.class, systemURIs, true);
        while (storageSystems.hasNext()) {
            StorageSystem system = storageSystems.next();
            if (system.deviceIsType(Type.vmax) || system.deviceIsType(Type.vnxblock) || system.deviceIsType(Type.xtremio) || system.deviceIsType(Type.unity)) {
                systems.add(system);
            }
        }
        // Sort systems by last array affinity time, so that system with the earliest last array affinity time will be used
        // when checking if job should be scheduled
        Collections.sort(systems, new Comparator<StorageSystem>() {

            public int compare(StorageSystem system1, StorageSystem system2) {
                return Long.compare(system1.getLastArrayAffinityRunTime(), system2.getLastArrayAffinityRunTime());
            }
        });
        for (StorageSystem system : systems) {
            if (system.deviceIsType(Type.unity)) {
                List<URI> systemIds = new ArrayList<URI>();
                systemIds.add(system.getId());
                providerToSystemsMap.put(system.getId(), systemIds);
            } else {
                StorageProvider provider = _dbClient.queryObject(StorageProvider.class, system.getActiveProviderURI());
                if (provider != null && !provider.getInactive()) {
                    List<URI> systemIds = providerToSystemsMap.get(provider.getId());
                    if (systemIds == null) {
                        systemIds = new ArrayList<URI>();
                        providerToSystemsMap.put(provider.getId(), systemIds);
                    }
                    systemIds.add(system.getId());
                }
            }
        }
    } else {
        addToList(allSystemsURIs, _dbClient.queryByType(StorageSystem.class, true).iterator());
        addToList(allSystemsURIs, _dbClient.queryByType(ProtectionSystem.class, true).iterator());
    }
    if (!providerToSystemsMap.isEmpty()) {
        for (Map.Entry<URI, List<URI>> entry : providerToSystemsMap.entrySet()) {
            String taskId = UUID.randomUUID().toString();
            List<URI> systemIds = entry.getValue();
            ArrayAffinityDataCollectionTaskCompleter completer = new ArrayAffinityDataCollectionTaskCompleter(StorageSystem.class, systemIds, taskId, jobType);
            DataCollectionArrayAffinityJob job = new DataCollectionArrayAffinityJob(null, systemIds, completer, DataCollectionJob.JobOrigin.SCHEDULER, Discovery_Namespaces.ARRAY_AFFINITY.name());
            jobs.add(job);
        }
        scheduleMultipleJobs(jobs, ControllerServiceImpl.Lock.getLock(jobType));
    } else if (!allSystemsURIs.isEmpty()) {
        Iterator<URI> systemURIsItr = allSystemsURIs.iterator();
        while (systemURIsItr.hasNext()) {
            URI systemURI = systemURIsItr.next();
            String taskId = UUID.randomUUID().toString();
            DataCollectionJob job = null;
            StorageProvider provider = null;
            if (URIUtil.isType(systemURI, StorageSystem.class)) {
                StorageSystem systemObj = _dbClient.queryObject(StorageSystem.class, systemURI);
                if (systemObj == null || systemObj.getInactive()) {
                    _logger.warn(String.format("StorageSystem %s is no longer in the DB or is inactive. It could have been deleted or decommissioned", systemURI));
                    continue;
                }
                // check devices managed by SMIS/hicommand/vplex device mgr has ActiveProviderURI or not.
                if (systemObj.isStorageSystemManagedByProvider()) {
                    if (systemObj.getActiveProviderURI() == null || NullColumnValueGetter.getNullURI().equals(systemObj.getActiveProviderURI())) {
                        _logger.info("Skipping {} Job : StorageSystem {} does not have an active provider", jobType, systemURI);
                        continue;
                    }
                    provider = _dbClient.queryObject(StorageProvider.class, systemObj.getActiveProviderURI());
                    if (provider == null || provider.getInactive()) {
                        _logger.info("Skipping {} Job : StorageSystem {} does not have a valid active provider", jobType, systemURI);
                        continue;
                    }
                }
                // For Metering, check SerialNumber has populated or not.
                if (ControllerServiceImpl.METERING.equalsIgnoreCase(jobType)) {
                    if (null == systemObj.getSerialNumber()) {
                        _logger.info("Skipping {} Job : StorageSystem {} discovery failed or hasn't run.", jobType, systemURI);
                        continue;
                    } else if (CompatibilityStatus.INCOMPATIBLE.name().equalsIgnoreCase(systemObj.getCompatibilityStatus())) {
                        _logger.info("Skipping {} Job : StorageSystem {} has incompatible version", jobType, systemURI);
                        continue;
                    }
                }
                job = getDataCollectionJobByType(StorageSystem.class, jobType, taskId, systemURI);
            } else if (URIUtil.isType(systemURI, NetworkSystem.class)) {
                job = getDataCollectionJobByType(NetworkSystem.class, jobType, taskId, systemURI);
            } else if (URIUtil.isType(systemURI, ComputeSystem.class)) {
                job = getDataCollectionJobByType(ComputeSystem.class, jobType, taskId, systemURI);
            } else if (URIUtil.isType(systemURI, Host.class)) {
                Host host = _dbClient.queryObject(Host.class, systemURI);
                // Add host
                if ((host.getDiscoverable() == null || host.getDiscoverable())) {
                    job = getDataCollectionJobByType(Host.class, jobType, taskId, systemURI);
                }
            } else if (URIUtil.isType(systemURI, Vcenter.class)) {
                job = getDataCollectionJobByType(Vcenter.class, jobType, taskId, systemURI);
            } else if (URIUtil.isType(systemURI, ProtectionSystem.class)) {
                // Protection System metrics are not used for "metering" per vpool/project/tenant
                if (!jobType.equals(ControllerServiceImpl.METERING)) {
                    job = getDataCollectionJobByType(ProtectionSystem.class, jobType, taskId, systemURI);
                }
            }
            if (null != job) {
                jobs.add(job);
            }
        }
        scheduleMultipleJobs(jobs, ControllerServiceImpl.Lock.getLock(jobType));
    } else {
        _logger.info("No systems found in db to schedule jobs.");
    }
}
Also used : Vcenter(com.emc.storageos.db.client.model.Vcenter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) Host(com.emc.storageos.db.client.model.Host) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) Comparator(java.util.Comparator) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 25 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionJobUtil method createStorageSystem.

/**
 * Creates a new StorageSystem if there is a new system managed by provider.
 *
 * @param storageSystemViewObject
 *            : system details to persist.
 * @param scannedStorageSystemNativeGuid
 *            : new Array nativeGuid.
 * @param providersToUpdate: dataStructure to hold provider and its systems managed.
 * @return : StorageSystem db object.
 * @throws IOException
 */
private StorageSystem createStorageSystem(StorageSystemViewObject storageSystemViewObject, String scannedStorageSystemNativeGuid, Map<URI, List<String>> providersToUpdate) throws IOException {
    Set<String> providerSet = storageSystemViewObject.getProviders();
    StorageSystem newStorageSystem = null;
    Iterator<String> iterator = providerSet.iterator();
    if (iterator.hasNext()) {
        // Find StorageProvider that should be associated with this StorageSystem.
        StorageProvider providerFromDB;
        do {
            String provider = iterator.next();
            providerFromDB = _dbClient.queryObject(StorageProvider.class, URI.create(provider));
        } while (iterator.hasNext() && (providerFromDB == null || providerFromDB.getInactive()));
        // If after looking through the provider list there was nothing active found, return null
        if (providerFromDB == null || providerFromDB.getInactive()) {
            _logger.info(String.format("StorageSystem %s was found during scan but could not find its associated active providers. " + "Could have been deleted while scan was occurring.", scannedStorageSystemNativeGuid));
            return null;
        }
        _logger.info("Scanned StorageSystemNativeGuid for a new Storage System:" + scannedStorageSystemNativeGuid);
        newStorageSystem = new StorageSystem();
        newStorageSystem.setId(URIUtil.createId(StorageSystem.class));
        newStorageSystem.setNativeGuid(scannedStorageSystemNativeGuid);
        newStorageSystem.setSystemType(storageSystemViewObject.getDeviceType());
        String model = storageSystemViewObject.getProperty(storageSystemViewObject.MODEL);
        if (StringUtils.isNotBlank(model)) {
            newStorageSystem.setModel(model);
        }
        String serialNo = storageSystemViewObject.getProperty(storageSystemViewObject.SERIAL_NUMBER);
        if (StringUtils.isNotBlank(serialNo)) {
            newStorageSystem.setSerialNumber(serialNo);
        }
        String version = storageSystemViewObject.getProperty(storageSystemViewObject.VERSION);
        if (StringUtils.isNotBlank(version)) {
            newStorageSystem.setFirmwareVersion(version);
        }
        String name = storageSystemViewObject.getProperty(storageSystemViewObject.STORAGE_NAME);
        if (StringUtils.isNotBlank(name)) {
            newStorageSystem.setLabel(name);
        }
        StringSet allProviders = new StringSet(providerSet);
        newStorageSystem.setProviders(allProviders);
        setActiveProviderDetailsInSystem(providerFromDB, newStorageSystem, providersToUpdate);
        newStorageSystem.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
        newStorageSystem.setReachableStatus(true);
    }
    return newStorageSystem;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageProvider (com.emc.storageos.db.client.model.StorageProvider)97 URI (java.net.URI)44 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)26 ArrayList (java.util.ArrayList)24 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)23 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 Produces (javax.ws.rs.Produces)19 IOException (java.io.IOException)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)15 Path (javax.ws.rs.Path)15 Consumes (javax.ws.rs.Consumes)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)8 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7