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);
}
}
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);
}
}
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);
}
}
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();
}
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;
}
Aggregations