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