Search in sources :

Example 11 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException 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 12 with DatabaseException

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

the class HDSSnapshotOperations method setInactive.

/**
 * Wrapper for setting the BlockSnapshot.inactive value
 *
 * @param snapshotURIs [in] - List of BlockSnapshot objects to update
 * @param value [in] - Value to assign to inactive
 */
protected void setInactive(List<URI> snapshotURIs, boolean value) {
    try {
        if (snapshotURIs != null) {
            for (URI uri : snapshotURIs) {
                BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, uri);
                snapshot.setInactive(value);
                dbClient.persistObject(snapshot);
            }
        }
    } catch (DatabaseException e) {
        log.error("IOException when trying to update snapshot.inactive value", e);
    }
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 13 with DatabaseException

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

the class HDSCreateVolumeJob method specificProcessing.

/**
 * This simply updates the deviceLabel name for the single volume that was created.
 *
 * @param dbClient [in] - Client for reading/writing from/to database.
 * @param client [in] - HDSAPI Client for accessing HiCommand DM data
 * @param volume [in] - Reference to Bourne's Volume object
 */
@Override
void specificProcessing(DbClient dbClient, HDSApiClient client, Volume volume) {
    try {
        // Get the tenant name from the volume
        TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        // that was successfully created
        if (_nameGeneratorRef.get() == null) {
            _nameGeneratorRef.compareAndSet(null, (NameGenerator) ControllerServiceImpl.getBean("defaultNameGenerator"));
        }
        String generatedName = _nameGeneratorRef.get().generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
        changeVolumeName(dbClient, client, volume, generatedName);
    } catch (DatabaseException e) {
        log.error("Encountered an error while trying to set the volume name", e);
    } catch (Exception e) {
        log.error("Encountered an error while trying to set the volume name", e);
    }
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 14 with DatabaseException

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

the class ExternalBlockStorageDevice method doDeleteSnapshot.

@Override
public void doDeleteSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
        List<BlockSnapshot> groupSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(blockSnapshot, dbClient);
        if (!groupSnapshots.isEmpty() && ControllerUtils.checkSnapshotsInConsistencyGroup(Arrays.asList(blockSnapshot), dbClient, taskCompleter)) {
            // make sure we delete only snapshots from the same consistency group
            List<BlockSnapshot> snapshotsToDelete = new ArrayList<>();
            for (BlockSnapshot snap : groupSnapshots) {
                if (snap.getConsistencyGroup().equals(blockSnapshot.getConsistencyGroup())) {
                    snapshotsToDelete.add(snap);
                }
            }
            deleteGroupSnapshots(storage, snapshotsToDelete, taskCompleter);
        } else {
            deleteVolumeSnapshot(storage, snapshot, taskCompleter);
        }
    } catch (DatabaseException e) {
        String message = String.format("IO exception when trying to delete snapshot(s) on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = ExternalDeviceException.errors.deleteSnapshotFailed("doDeleteSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    } catch (Exception e) {
        String message = String.format("Exception when trying to delete snapshot(s) on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = ExternalDeviceException.errors.deleteSnapshotFailed("doDeleteSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException)

Example 15 with DatabaseException

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

the class RPCGCreateCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        // Tell the workflow we're done.
        super.complete(dbClient, status, coded);
        _log.info("cg_create completer: done");
        _log.info(String.format("Done RPCGCreate - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        // Tell the individual objects we're done.
        for (URI id : getIds()) {
            switch(status) {
                case error:
                    dbClient.error(Volume.class, id, getOpId(), coded);
                    break;
                default:
                    dbClient.ready(Volume.class, id, getOpId());
            }
        }
    } catch (DatabaseException e) {
        _log.error(String.format("Failed updating status for CG Create - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    }
}
Also used : URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)109 URI (java.net.URI)70 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 HashSet (java.util.HashSet)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 HashMap (java.util.HashMap)11 List (java.util.List)11 WBEMException (javax.wbem.WBEMException)11