use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSystemSnapshotPolicy.
@Override
public void assignFileSystemSnapshotPolicy(URI storage, URI fsURI, URI policy, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
try {
fs = _dbClient.queryObject(FileShare.class, fsURI);
SchedulePolicy fp = _dbClient.queryObject(SchedulePolicy.class, policy);
if (fs != null && fp != null) {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info("Controller Recieved File Policy {}", policy);
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.addFilePolicy(fp);
args.setFileOperation(true);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).assignFilePolicy(storageObj, args);
if (result.isCommandSuccess()) {
// Update FS database
StringSet fpolicies = fs.getFilePolicies();
fpolicies.add(fp.getId().toString());
fs.setFilePolicies(fpolicies);
// Update SchedulePolicy database
StringSet resources = fp.getAssignedResources();
resources.add(fs.getId().toString());
fp.setAssignedResources(resources);
}
if (result.getCommandPending()) {
return;
}
// Audit & Update the task status
OperationTypeEnum auditType = null;
auditType = OperationTypeEnum.ASSIGN_FILE_SYSTEM_SNAPSHOT_SCHEDULE;
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
// Monitoring - Event Processing
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, fp);
_dbClient.updateObject(fs);
_dbClient.updateObject(fp);
} else {
throw DeviceControllerException.exceptions.invalidObjectNull();
}
} catch (Exception e) {
String[] params = { storage.toString(), fsURI.toString(), e.getMessage() };
_log.error("Unable to assign policy : storage {}, FS URI {},: Error {}", params);
updateTaskStatus(opId, fs, e);
}
}
use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteNFSAcls.
@Override
public void deleteNFSAcls(URI storage, URI fsURI, String subDir, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileObject fsObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
Snapshot snapshotObj = null;
boolean isFile = false;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
args.setSubDirectory(subDir);
_log.info("FileDeviceController::deleteNFSAcls Recieved Nfs ACL DELETE Operation ");
// File
if (URIUtil.isType(fsURI, FileShare.class)) {
isFile = true;
fs = _dbClient.queryObject(FileShare.class, fsURI);
fsObj = fs;
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
} else {
// Snapshot
snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
fsObj = snapshotObj;
fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
args.addFileShare(fs);
args.setFileSystemPath(fs.getPath());
args.addSnapshotFileObject(snapshotObj);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
}
args.setFileOperation(isFile);
args.setOpId(opId);
List<NfsACE> aceDeleteList = new ArrayList<NfsACE>();
List<NFSShareACL> dbNfsAclTemp = queryAllNfsACLInDB(fs, subDir, args);
makeNfsAceFromDB(aceDeleteList, dbNfsAclTemp);
args.setNfsAclsToDelete(aceDeleteList);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).deleteNfsACLs(storageObj, args);
if (result.isCommandSuccess()) {
// Update Database
if (!dbNfsAclTemp.isEmpty()) {
for (NFSShareACL nfsShareACL : dbNfsAclTemp) {
nfsShareACL.setInactive(true);
}
_dbClient.updateObject(dbNfsAclTemp);
}
}
if (result.getCommandPending()) {
return;
}
// Audit & Update the task status
OperationTypeEnum auditType = null;
auditType = (isFile) ? OperationTypeEnum.DELETE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.DELETE_FILE_SNAPSHOT_NFS_ACL;
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
// Monitoring - Event Processing
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
if (isFile) {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
} else {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
}
_dbClient.updateObject(fsObj);
} catch (Exception e) {
String[] params = { storage.toString(), fsURI.toString() };
_log.error("Unable to Delete ACL on file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
_log.error("{}, {} ", e.getMessage(), e);
updateTaskStatus(opId, fsObj, e);
}
}
use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.
the class FileDeviceController method updateNFSAcl.
@Override
public void updateNFSAcl(URI storage, URI fsURI, NfsACLUpdateParams param, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileObject fsObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
Snapshot snapshotObj = null;
boolean isFile = false;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
args.setSubDirectory(param.getSubDir());
args.setAllNfsAcls(param);
_log.info("Controller Recieved NfsACLUpdateParams {}", param);
// File
if (URIUtil.isType(fsURI, FileShare.class)) {
isFile = true;
fs = _dbClient.queryObject(FileShare.class, fsURI);
fsObj = fs;
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
} else {
// Snapshot
snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
fsObj = snapshotObj;
fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
args.addFileShare(fs);
args.setFileSystemPath(fs.getPath());
args.addSnapshotFileObject(snapshotObj);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
}
if (fs.getVirtualNAS() != null) {
VirtualNAS vNas = _dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
if (vNas != null && !vNas.getInactive()) {
args.setvNAS(vNas);
}
}
args.setFileOperation(isFile);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).updateNfsACLs(storageObj, args);
if (result.isCommandSuccess()) {
// Update Database
updateNFSACLsInDB(param, fs, args);
WorkflowStepCompleter.stepSucceded(opId);
}
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Audit & Update the task status
OperationTypeEnum auditType = null;
auditType = (isFile) ? OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.UPDATE_FILE_SNAPSHOT_NFS_ACL;
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
// Monitoring - Event Processing
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
if (isFile) {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
} else {
recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
}
_dbClient.updateObject(fsObj);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
String[] params = { storage.toString(), fsURI.toString() };
_log.error("Unable to set ACL on file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
_log.error("{}, {} ", e.getMessage(), e);
updateTaskStatus(opId, fsObj, e);
}
}
use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.
the class VolumeVpoolChangeTaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded serviceCoded) {
boolean useOldVpoolMap = (oldVpool == null);
List<Volume> volumesToUpdate = new ArrayList<Volume>();
try {
switch(status) {
case error:
_log.error("An error occurred during virtual pool change " + "- restore the old virtual pool to the volume(s): {}", serviceCoded.getMessage());
// We either are using a single old Vpool URI or a map of Volume URI to old Vpool URI
for (URI id : getIds()) {
Volume volume = dbClient.queryObject(Volume.class, id);
// the volume. If not set, the volume has not yet been created.
if ((volume != null) && (!volume.isVPlexVolume(dbClient)) && (volume.checkInternalFlags(DataObject.Flag.INTERNAL_OBJECT)) && (NullColumnValueGetter.isNullValue(volume.getNativeGuid())) && (!volume.getInactive())) {
volume.setInactive(true);
volumesToUpdate.add(volume);
}
URI oldVpoolURI = oldVpool;
if ((useOldVpoolMap) && (!oldVpools.containsKey(id))) {
continue;
} else if (useOldVpoolMap) {
oldVpoolURI = oldVpools.get(id);
}
_log.info("Rolling back virtual pool on volume {}({})", id, volume.getLabel());
URI newVpoolURI = volume.getVirtualPool();
if (newVpools != null && !newVpools.isEmpty()) {
newVpoolURI = newVpools.get(id);
if (newVpoolURI != null) {
newVpoolURI = volume.getVirtualPool();
}
}
VirtualPool oldVpool = dbClient.queryObject(VirtualPool.class, oldVpoolURI);
VirtualPool newVpool = dbClient.queryObject(VirtualPool.class, newVpoolURI);
if (isMigrationCommitted(dbClient)) {
_log.info("Migration already commited, leaving virtual pool for volume: " + volume.forDisplay());
} else {
volume.setVirtualPool(oldVpoolURI);
_log.info("Set volume's virtual pool back to {}", oldVpoolURI);
}
// Only rollback protection on the volume if the volume specifies RP and the
// old vpool did not have protection and the new one does (so we were trying to add
// RP protection but it failed for some reason so we need to rollback).
boolean rollbackProtection = volume.checkForRp() && !VirtualPool.vPoolSpecifiesProtection(oldVpool) && VirtualPool.vPoolSpecifiesProtection(newVpool);
if (rollbackProtection) {
// Special rollback for RP, RP+VPLEX, and MetroPoint in the case
// where the operation tried to apply RP Protection to the volume
// and now it needs to be reverted.
RPHelper.rollbackProtectionOnVolume(volume, oldVpool, dbClient);
}
if (RPHelper.isVPlexVolume(volume, dbClient)) {
if (!isMigrationCommitted(dbClient)) {
// Special rollback for VPLEX to update the backend vpools to the old vpools
rollBackVpoolOnVplexBackendVolume(volume, volumesToUpdate, dbClient, oldVpoolURI);
}
}
// Add the volume to the list of volumes to be updated in the DB so that the
// old vpool reference can be restored.
volumesToUpdate.add(volume);
}
dbClient.updateObject(volumesToUpdate);
handleVplexVolumeErrors(dbClient);
rollbackMaskZoningMap(dbClient);
// If there's a task associated with the CG, update that as well
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.error(BlockConsistencyGroup.class, cgId, this.getOpId(), serviceCoded);
}
}
break;
case ready:
// record event.
OperationTypeEnum opType = OperationTypeEnum.CHANGE_VOLUME_VPOOL;
try {
boolean opStatus = (Operation.Status.ready == status) ? true : false;
String evType = opType.getEvType(opStatus);
String evDesc = opType.getDescription();
for (URI id : getIds()) {
if ((useOldVpoolMap) && (!oldVpools.containsKey(id))) {
continue;
}
// vpool reference to the new vpool.
if (newVpools != null && !newVpools.isEmpty()) {
URI newVpoolId = newVpools.get(id);
if (newVpoolId != null) {
Volume volume = dbClient.queryObject(Volume.class, id);
_log.info("Change vpool task complete, updating vpool references for " + volume.getLabel());
volume.setVirtualPool(newVpoolId);
// No effect if this not a VPLEX volume
VPlexUtil.updateVPlexBackingVolumeVpools(volume, newVpoolId, dbClient);
volumesToUpdate.add(volume);
}
}
recordBourneVolumeEvent(dbClient, id, evType, status, evDesc);
}
dbClient.updateObject(volumesToUpdate);
} catch (Exception ex) {
_logger.error("Failed to record block volume operation {}, err: {}", opType.toString(), ex);
}
// If there's a task associated with the CG, update that as well
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.ready(BlockConsistencyGroup.class, cgId, this.getOpId());
}
}
break;
case suspended_error:
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.suspended_error(BlockConsistencyGroup.class, cgId, this.getOpId(), serviceCoded);
}
}
break;
case suspended_no_error:
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.suspended_no_error(BlockConsistencyGroup.class, cgId, this.getOpId());
}
}
break;
default:
break;
}
} finally {
switch(status) {
case error:
for (URI migrationURI : migrationURIs) {
dbClient.error(Migration.class, migrationURI, getOpId(), serviceCoded);
}
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.error(BlockConsistencyGroup.class, cgId, this.getOpId(), serviceCoded);
}
}
break;
case suspended_error:
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.suspended_error(BlockConsistencyGroup.class, cgId, this.getOpId(), serviceCoded);
}
}
break;
case suspended_no_error:
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.suspended_no_error(BlockConsistencyGroup.class, cgId, this.getOpId());
}
}
break;
case ready:
default:
for (URI migrationURI : migrationURIs) {
dbClient.ready(Migration.class, migrationURI, getOpId());
}
if (this.getConsistencyGroupIds() != null) {
for (URI cgId : this.getConsistencyGroupIds()) {
dbClient.ready(BlockConsistencyGroup.class, cgId, this.getOpId());
}
}
}
super.complete(dbClient, status, serviceCoded);
}
}
use of com.emc.storageos.services.OperationTypeEnum in project coprhd-controller by CoprHD.
the class VolumeVpoolAutoTieringPolicyChangeTaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded serviceCoded) {
switch(status) {
case error:
_log.error("An error occurred during virtual pool change " + "- restore the old auto tiering policy to the volume(s): {}", serviceCoded.getMessage());
List<Volume> volumesToUpdate = new ArrayList<Volume>();
for (URI id : getIds()) {
Volume volume = dbClient.queryObject(Volume.class, id);
_log.info("rolling back auto tiering policy on volume {}({})", id, volume.getLabel());
URI policyURI = oldVolToPolicyMap.get(id);
if (policyURI == null) {
policyURI = NullColumnValueGetter.getNullURI();
}
volume.setAutoTieringPolicyUri(policyURI);
_log.info("set volume's auto tiering policy back to {}", policyURI);
volumesToUpdate.add(volume);
rollBackPolicyOnVplexBackendVolume(volume, volumesToUpdate, dbClient);
}
dbClient.updateObject(volumesToUpdate);
break;
case ready:
// The new auto tiering policy has already been stored in the volume
// in BlockDeviceExportController.
// record event.
OperationTypeEnum opType = OperationTypeEnum.CHANGE_VOLUME_AUTO_TIERING_POLICY;
try {
boolean opStatus = (Operation.Status.ready == status) ? true : false;
String evType = opType.getEvType(opStatus);
String evDesc = opType.getDescription();
for (URI id : getIds()) {
recordBourneVolumeEvent(dbClient, id, evType, status, evDesc);
}
} catch (Exception ex) {
_logger.error("Failed to record block volume operation {}, err: {}", opType.toString(), ex);
}
break;
default:
break;
}
super.complete(dbClient, status, serviceCoded);
}
Aggregations