Search in sources :

Example 1 with ScanTaskCompleter

use of com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method scanProvider.

private boolean scanProvider(StorageProvider provider, StorageSystem storageSystem, boolean activeProvider, String opId) throws DatabaseException, BaseCollectionException, ControllerException {
    Map<String, StorageSystemViewObject> storageCache = new HashMap<String, StorageSystemViewObject>();
    _dbClient.createTaskOpStatus(StorageProvider.class, provider.getId(), opId, ResourceOperationTypeEnum.SCAN_SMISPROVIDER);
    ScanTaskCompleter scanCompleter = new ScanTaskCompleter(StorageProvider.class, provider.getId(), opId);
    try {
        scanCompleter.statusPending(_dbClient, "Scan for storage system is Initiated");
        provider.setLastScanStatusMessage("");
        _dbClient.updateObject(provider);
        ControllerServiceImpl.performScan(provider.getId(), scanCompleter, storageCache);
        scanCompleter.statusReady(_dbClient, "Scan for storage system has completed");
    } catch (Exception ex) {
        _log.error("Scan failed for {}--->", provider, ex);
        scanCompleter.statusError(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanFailed(ex.getLocalizedMessage(), ex));
        throw DeviceControllerException.exceptions.scanProviderFailed(storageSystem.getNativeGuid(), provider.getId().toString());
    }
    if (!storageCache.containsKey(storageSystem.getNativeGuid())) {
        return false;
    } else {
        StorageSystemViewObject vo = storageCache.get(storageSystem.getNativeGuid());
        String model = vo.getProperty(StorageSystemViewObject.MODEL);
        if (StringUtils.isNotBlank(model)) {
            storageSystem.setModel(model);
        }
        String serialNo = vo.getProperty(StorageSystemViewObject.SERIAL_NUMBER);
        if (StringUtils.isNotBlank(serialNo)) {
            storageSystem.setSerialNumber(serialNo);
        }
        String version = vo.getProperty(StorageSystemViewObject.VERSION);
        if (StringUtils.isNotBlank(version)) {
            storageSystem.setMajorVersion(version);
        }
        String name = vo.getProperty(StorageSystemViewObject.STORAGE_NAME);
        if (StringUtils.isNotBlank(name)) {
            storageSystem.setLabel(name);
        }
        provider.addStorageSystem(_dbClient, storageSystem, activeProvider);
        return true;
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) HashMap(java.util.HashMap) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException)

Example 2 with ScanTaskCompleter

use of com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter in project coprhd-controller by CoprHD.

the class BlockControllerImpl method scanStorageProviders.

/**
 * {@inheritDoc}
 */
@Override
public void scanStorageProviders(AsyncTask[] tasks) throws ControllerException {
    try {
        Map<String, DataCollectionScanJob> scanJobByInterfaceType = new HashMap<String, DataCollectionScanJob>();
        for (AsyncTask task : tasks) {
            ScanTaskCompleter completer = new ScanTaskCompleter(task);
            StorageProvider provider = _dbClient.queryObject(StorageProvider.class, completer.getId());
            if (provider != null && !provider.getInactive()) {
                if (scanJobByInterfaceType.get(provider.getInterfaceType()) == null) {
                    scanJobByInterfaceType.put(provider.getInterfaceType(), new DataCollectionScanJob());
                }
                scanJobByInterfaceType.get(provider.getInterfaceType()).addCompleter(completer);
            }
        }
        for (DataCollectionScanJob job : scanJobByInterfaceType.values()) {
            _util.scheduleScanningJobs(job);
        }
    } catch (Exception e) {
        throw ClientControllerException.fatals.unableToScanSMISProviders(tasks, "BlockController", e);
    }
}
Also used : HashMap(java.util.HashMap) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DataCollectionScanJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionScanJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException) RetryableDatabaseException(com.emc.storageos.db.exceptions.RetryableDatabaseException)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 ScanTaskCompleter (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter)2 HashMap (java.util.HashMap)2 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)1 RetryableDatabaseException (com.emc.storageos.db.exceptions.RetryableDatabaseException)1 ClientControllerException (com.emc.storageos.exceptions.ClientControllerException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)1 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)1 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)1 DataCollectionScanJob (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionScanJob)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 DataBindingException (javax.xml.bind.DataBindingException)1