use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class ExportMaskRemovePathsCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
if (status == Operation.Status.ready) {
ExportMask exportMask = dbClient.queryObject(ExportMask.class, getMask());
if (removedTargets != null && !removedTargets.isEmpty()) {
for (URI target : removedTargets) {
exportMask.removeTarget(target);
}
}
if (removedInitiators != null && !removedInitiators.isEmpty()) {
exportMask.removeInitiatorURIs(removedInitiators);
exportMask.removeFromUserAddedInitiatorsByURI(removedInitiators);
}
dbClient.updateObject(exportMask);
}
} catch (Exception e) {
_log.error(String.format("Failed updating status for ExportMaskRemovePaths - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class ExportRemoveVolumesOnAdoptedMaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
URI exportMaskUri = getMask();
ExportMask exportMask = (exportMaskUri != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
for (URI volumeURI : _volumes) {
BlockObject volume = BlockObject.fetch(dbClient, volumeURI);
if (exportMask != null && status == Operation.Status.ready) {
exportMask.removeFromUserCreatedVolumes(volume);
exportMask.removeVolume(volume.getId());
}
}
if (exportMask != null) {
URI pgURI = exportMask.getPortGroup();
if (exportMask.getVolumes() == null || exportMask.getVolumes().isEmpty()) {
exportGroup.removeExportMask(exportMask.getId());
dbClient.markForDeletion(exportMask);
dbClient.updateObject(exportGroup);
} else {
dbClient.updateObject(exportMask);
}
updatePortGroupVolumeCount(pgURI, dbClient);
}
_log.info(String.format("Done ExportMaskRemoveVolume - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
} catch (Exception e) {
_log.error(String.format("Failed updating status for ExportMaskRemoveVolume - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
} finally {
super.complete(dbClient, status, coded);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class RPCGExportCompleter 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_export completer: done");
_log.info(String.format("Done RPCGExport - 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(ExportGroup.class, id, getOpId(), coded);
break;
default:
dbClient.ready(ExportGroup.class, id, getOpId());
}
}
} catch (Exception e) {
_log.error(String.format("Failed updating status for CG Export - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class RPCGExportDeleteCompleter 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_export_delete completer: done");
_log.info(String.format("Done RPCGExportDelete - 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(ExportGroup.class, id, getOpId(), coded);
break;
default:
dbClient.ready(ExportGroup.class, id, getOpId());
}
}
} catch (Exception e) {
_log.error(String.format("Failed updating status for CG Export Delete - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
}
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class RollbackExportGroupCreateCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
if ((status == Operation.Status.error) && (coded instanceof ServiceError)) {
ServiceError error = (ServiceError) coded;
String originalMessage = error.getMessage();
StorageSystem storageSystem = exportMask != null ? dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice()) : null;
String additionMessage = String.format("Rollback encountered problems cleaning up export mask %s on storage system %s and may require manual clean up", exportMask.getMaskName(), storageSystem != null ? storageSystem.forDisplay() : "Unknown");
String updatedMessage = String.format("%s\n%s", originalMessage, additionMessage);
error.setMessage(updatedMessage);
}
if (exportMask != null) {
URI pgURI = exportMask.getPortGroup();
// clean up export group
exportGroup.removeExportMask(exportMask.getId());
dbClient.updateObject(exportGroup);
List<URI> boURIs = new ArrayList<>();
// part of export group then we should remove that volumes
for (String emUri : exportGroup.getExportMasks()) {
if (URIUtil.isValid(emUri) && !emUri.equals(exportMask.getId())) {
ExportMask em = dbClient.queryObject(ExportMask.class, URI.create(emUri));
if (em != null) {
for (String boURI : em.getUserAddedVolumes().values()) {
if (URIUtil.isValid(boURI)) {
boURIs.add(URI.create(boURI));
}
}
}
}
}
exportMask.removeFromUserAddedVolumesByURI(boURIs);
dbClient.updateObject(exportMask);
// if its not used anywhere and is system created delete it
if (ExportMaskUtils.getExportGroups(dbClient, exportMask.getId()).isEmpty() && exportMask.getCreatedBySystem() && !exportMask.hasAnyVolumes()) {
dbClient.markForDeletion(exportMask);
}
updatePortGroupVolumeCount(pgURI, dbClient);
}
_log.info(String.format("Done RollbackExportGroupCreate - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
} catch (Exception e) {
_log.error(String.format("Failed updating status for RollbackExportGroupCreate - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
} finally {
super.complete(dbClient, status, coded);
}
}
Aggregations