Search in sources :

Example 96 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 snapshotURI [in] - BlockSnapshot object to update
 * @param value [in] - Value to assign to inactive
 */
protected void setInactive(URI snapshotURI, boolean value) {
    try {
        if (snapshotURI != null) {
            BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
            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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 97 with DatabaseException

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

the class HDSAbstractCreateVolumeJob method changeVolumeName.

/**
 * Method will modify the name of a given volume to a generate name.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - HDSApiClient used for reading/writing from/to HiCommand DM.
 * @param volume [in] - Volume object
 */
protected void changeVolumeName(DbClient dbClient, HDSApiClient client, Volume volume, String name) {
    try {
        _log.info(String.format("Attempting to add volume label %s to %s", name, volume.getWWN()));
        StorageSystem system = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
        String systemObjectId = HDSUtils.getSystemObjectID(system);
        LogicalUnit logicalUnit = client.getLogicalUnitInfo(systemObjectId, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), system));
        if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
            Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
            if (ldevItr.hasNext()) {
                LDEV ldev = ldevItr.next();
                ObjectLabel objectLabel = client.addVolumeLabel(ldev.getObjectID(), name);
                volume.setDeviceLabel(objectLabel.getLabel());
                dbClient.persistObject(volume);
            }
        } else {
            _log.info("No LDEV's found on volume: {}", volume.getWWN());
        }
        _log.info(String.format("Volume label has been added to volume %s", volume.getWWN()));
    } 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 : ObjectLabel(com.emc.storageos.hds.model.ObjectLabel) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 98 with DatabaseException

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

the class ScaleIOStorageDevice 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);
        // We check the snapset size here because SIO consistency groups require more than 1 device
        if (ControllerUtils.checkSnapshotsInConsistencyGroup(Arrays.asList(blockSnapshot), dbClient, taskCompleter) && groupSnapshots.size() > 1) {
            snapshotOperations.deleteGroupSnapshots(storage, snapshot, taskCompleter);
        } else {
            snapshotOperations.deleteSingleVolumeSnapshot(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 = DeviceControllerErrors.smis.methodFailed("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 = DeviceControllerErrors.smis.methodFailed("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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException)

Example 99 with DatabaseException

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

the class BiosCommandResultTest method setUp.

@Before
public void setUp() throws Exception {
    _isi = new IsilonFileStorageDevice();
    IsilonApiFactory factory = new IsilonApiFactory();
    factory.init();
    _isi.setIsilonApiFactory(factory);
    _isi.setDbClient(new DummyDbClient() {

        @Override
        public List<URI> queryByConstraint(Constraint constraint) throws DatabaseException {
            return new ArrayList<>();
        }
    });
    // storage device object for tests to use
    _device = new StorageSystem();
    _device.setIpAddress(ip);
    _device.setPortNumber(Integer.parseInt(portNumber));
    _device.setUsername(userName);
    _device.setPassword(password);
    _pool = new StoragePool();
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) IsilonApiFactory(com.emc.storageos.isilon.restapi.IsilonApiFactory) Constraint(com.emc.storageos.db.client.constraint.Constraint) DummyDbClient(com.emc.storageos.util.DummyDbClient) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Before(org.junit.Before)

Example 100 with DatabaseException

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

the class BourneDbClient method queryNamedElementsByConstraint.

protected List<NamedElement> queryNamedElementsByConstraint(Constraint constraint, int maxCount) {
    NamedElementQueryResultList queryResults = new NamedElementQueryResultList();
    try {
        if (maxCount > 0) {
            getDbClient().queryByConstraint(constraint, queryResults, null, maxCount);
        } else {
            getDbClient().queryByConstraint(constraint, queryResults);
        }
    } catch (DatabaseException e) {
        throw new DataAccessException(e);
    }
    List<NamedElement> results = Lists.newArrayList();
    for (NamedElement namedElement : queryResults) {
        results.add(namedElement);
    }
    return results;
}
Also used : NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

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