use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSnapshotPolicyToProjects.
@Override
public void assignFileSnapshotPolicyToProjects(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
try {
WorkflowStepCompleter.stepExecuting(opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
if (vNASURI != null) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
args.setvNAS(vNAS);
}
args.setFileProtectionPolicy(filePolicy);
args.setVPool(vpool);
args.setProject(project);
args.setTenantOrg(tenant);
_log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
BiosCommandResult result = getDevice(storageObj.getSystemType()).checkFilePolicyExistsOrCreate(storageObj, args);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class FileDeviceController method failoverFileSystem.
/**
* Fail over Work flow Method
*
* @param storage target storage system
* @param fileshareURI target file system URI
* @param completer
* @param opId
*/
public void failoverFileSystem(URI storage, URI fileshareURI, TaskCompleter completer, String opId) {
try {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
FileShare fileShare = _dbClient.queryObject(FileShare.class, fileshareURI);
WorkflowStepCompleter.stepExecuting(opId);
_log.info("Execution of Failover Job Started");
BiosCommandResult cmdResult = getDevice(system.getSystemType()).doFailoverLink(system, fileShare, completer);
if (cmdResult.getCommandSuccess()) {
completer.ready(_dbClient);
} else if (cmdResult.getCommandPending()) {
completer.statusPending(_dbClient, cmdResult.getMessage());
} else {
completer.error(_dbClient, cmdResult.getServiceCoded());
}
} catch (Exception e) {
ServiceError error = DeviceControllerException.errors.jobFailed(e);
if (null != completer) {
completer.error(this._dbClient, error);
}
WorkflowStepCompleter.stepFailed(opId, error);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileReplicationPolicyToVirtualPools.
@Override
public void assignFileReplicationPolicyToVirtualPools(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
StorageSystem targetSystem = _dbClient.queryObject(StorageSystem.class, targetSystemURI);
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
VirtualNAS sourceVNAS = null;
VirtualNAS targetVNAS = null;
FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
targetArgs.setVarray(targetVarray);
sourceArgs.setFileProtectionPolicy(filePolicy);
sourceArgs.setVPool(vpool);
if (sourceVNasURI != null) {
sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
sourceArgs.setvNAS(sourceVNAS);
targetArgs.setSourceVNAS(sourceVNAS);
}
targetArgs.setSourceSystem(sourceSystem);
targetArgs.setVPool(vpool);
targetArgs.setTarget(true);
if (targetVNasURI != null) {
targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
targetArgs.setvNAS(targetVNAS);
}
_log.info("Assigning file replication policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
BiosCommandResult result = getDevice(sourceSystem.getSystemType()).checkFileReplicationPolicyExistsOrCreate(sourceSystem, targetSystem, sourceArgs, targetArgs);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteExportRules.
@Override
public void deleteExportRules(URI storage, URI fileUri, boolean allDirs, String subDir, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(fileUri, opId);
FileObject fsObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
Snapshot snapshotObj = null;
StorageSystem storageObj = null;
boolean isFile = false;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
// File
if (URIUtil.isType(fileUri, FileShare.class)) {
isFile = true;
fs = _dbClient.queryObject(FileShare.class, fileUri);
setVirtualNASinArgs(fs.getVirtualNAS(), args);
fsObj = fs;
args.addFSFileObject(fs);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.setAllDir(allDirs);
args.setSubDirectory(subDir);
} else {
// Snapshot
snapshotObj = _dbClient.queryObject(Snapshot.class, fileUri);
fsObj = snapshotObj;
fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
setVirtualNASinArgs(fs.getVirtualNAS(), args);
args.addFileShare(fs);
args.addSnapshotFileObject(snapshotObj);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.setAllDir(true);
args.setSubDirectory(null);
}
args.setFileOperation(isFile);
args.setOpId(opId);
List<ExportRule> existingExportRules = queryExports(args);
args.setExistingDBExportRules(existingExportRules);
// Do the Operation on device.
_log.info("Delete Export Rules : request received for {}, with allDirs : {}, subDir : {}", new Object[] { fs.getId(), allDirs, subDir });
acquireStepLock(storageObj, opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).deleteExportRules(storageObj, args);
if (result.isCommandSuccess()) {
// Update Database
doDeleteExportRulesFromDB(allDirs, subDir, args);
doDeleteExportsFromFSObjMap(allDirs, subDir, args);
WorkflowStepCompleter.stepSucceded(opId);
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Audit & Update the task status
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
if (isFile) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, storageObj);
} else {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, result.isCommandSuccess(), eventMsg, "", snapshotObj, fs, storageObj);
}
_dbClient.updateObject(fsObj);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
String[] params = { storage.toString(), fileUri.toString() };
_log.error("Unable to export file system or snapshot: storage {}, FS/snapshot URI {}", params);
if ((fsObj != null) && (storageObj != null)) {
if (URIUtil.isType(fileUri, FileShare.class)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SYSTEM, false, e.getMessage(), "", fs, storageObj);
} else {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, false, e.getMessage(), "", snapshotObj, fs, storageObj);
}
}
updateTaskStatus(opId, fsObj, e);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class FileDeviceController method modifyFS.
@Override
public void modifyFS(URI storage, URI pooluri, URI fsuri, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(fsuri, opId);
FileShare fs = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
fs = _dbClient.queryObject(FileShare.class, fsuri);
args.addFSFileObject(fs);
StoragePool pool = _dbClient.queryObject(StoragePool.class, pooluri);
args.addStoragePool(pool);
args.setFileOperation(true);
args.setOpId(opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doModifyFS(storageObj, args);
if (result.getCommandPending()) {
// async operation
return;
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
_log.info("FileSystem updated " + " with Soft Limit: " + args.getFsSoftLimit() + ", Notification Limit: " + args.getFsNotificationLimit() + ", Soft Grace: " + args.getFsSoftGracePeriod());
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Set status
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fs);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UPDATE_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs);
} catch (Exception e) {
_log.error("Unable to update file system: FS URI {}", fs.getId());
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
updateTaskStatus(opId, fs, e);
if (fs != null) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UPDATE_FILE_SYSTEM, false, e.getMessage(), "", fs);
}
}
}
Aggregations