use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method expandFS.
@Override
public void expandFS(URI storage, URI uri, long newFSsize, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileShare fs = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
fs = _dbClient.queryObject(FileShare.class, uri);
args.addFSFileObject(fs);
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.setFileOperation(true);
args.setNewFSCapacity(newFSsize);
args.setOpId(opId);
// work flow and we need to add TaskCompleter(TBD for vnxfile)
WorkflowStepCompleter.stepExecuting(opId);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doExpandFS(storageObj, args);
if (result.getCommandPending()) {
// async operation
return;
}
if (result.isCommandSuccess()) {
_log.info("FileSystem old capacity :" + args.getFsCapacity() + ":Expanded Size:" + args.getNewFSCapacity());
args.setFsCapacity(args.getNewFSCapacity());
_log.info("FileSystem new capacity :" + args.getFsCapacity());
WorkflowStepCompleter.stepSucceded(opId);
} else if (!result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
// Set status
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fs);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, String.valueOf(newFSsize));
} catch (Exception e) {
String[] params = { storage.toString(), uri.toString(), String.valueOf(newFSsize), e.getMessage() };
_log.error("Unable to expand file system: storage {}, FS URI {}, size {}: {}", params);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
updateTaskStatus(opId, fs, e);
if (fs != null) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, false, e.getMessage(), "", fs, String.valueOf(newFSsize));
}
}
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method reduceFS.
@Override
public void reduceFS(URI storage, URI uri, long newFSsize, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileShare fs = null;
StoragePool pool = null;
StorageSystem storageObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
try {
fs = _dbClient.queryObject(FileShare.class, uri);
pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
args.addFSFileObject(fs);
args.addStoragePool(pool);
args.setFileOperation(true);
args.setNewFSCapacity(newFSsize);
args.setOpId(opId);
// work flow and we need to add TaskCompleter
WorkflowStepCompleter.stepExecuting(opId);
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doReduceFS(storageObj, args);
if (result.getCommandPending()) {
// async operation
return;
}
if (result.isCommandSuccess()) {
_log.info("FileSystem old capacity :" + args.getFsCapacity() + ":Reduced Size:" + args.getNewFSCapacity());
args.setFsCapacity(args.getNewFSCapacity());
WorkflowStepCompleter.stepSucceded(opId);
} else if (!result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
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.REDUCE_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, String.valueOf(newFSsize));
} catch (Exception e) {
String[] params = { storage.toString(), uri.toString(), String.valueOf(newFSsize), e.getMessage() };
_log.error("Unable to reduce file system: storage {}, FS URI {}, size {}: {}", params);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
updateTaskStatus(opId, fs, e);
if (fs != null) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.REDUCE_FILE_SYSTEM, false, e.getMessage(), "", fs, String.valueOf(newFSsize));
}
}
}
use of com.emc.storageos.db.client.model.StorageSystem 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.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteQuotaDirectory.
@Override
public void deleteQuotaDirectory(URI storage, URI quotaDir, URI fs, String task) throws ControllerException {
FileShare fsObj = null;
QuotaDirectory quotaDirObj = null;
try {
String[] params = { storage.toString(), quotaDir.toString(), fs.toString() };
_log.info("FileDeviceController::deleteQuotaDirectory: storage : {}, quotadir : {}, fs : {}", params);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
fsObj = _dbClient.queryObject(FileShare.class, fs);
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, quotaDir);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addFSFileObject(fsObj);
args.addQuotaDirectory(quotaDirObj);
args.setOpId(task);
FileStorageDevice nasDevice = getDevice(storageObj.getSystemType());
BiosCommandResult result = nasDevice.doDeleteQuotaDirectory(storageObj, args);
if (result.getCommandPending()) {
return;
}
fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
quotaDirObj.getOpStatus().updateTaskStatus(task, result.toOperation());
String fsName = fsObj.getName();
quotaDirObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirObj, fsName));
if (!result.isCommandSuccess()) {
_log.error("FileDeviceController::deleteQuotaDirectory: command is not successfull");
} else {
// If delete operation is successful, then remove obj from ViPR db by setting inactive=true
quotaDirObj.setInactive(true);
}
// save the task status in db
_dbClient.updateObject(quotaDirObj);
_dbClient.updateObject(fsObj);
fsObj = _dbClient.queryObject(FileShare.class, fs);
_log.debug("FileDeviceController::deleteQuotaDirectory: After deleteQuotaDirectory created and fs persisted, Task Stauts {} -- Operation Details : {}", fsObj.getOpStatus().get(task).getStatus(), result.toOperation());
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, result.isCommandSuccess(), eventMsg, "", quotaDirObj, fsObj);
} catch (Exception e) {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString(), e.getMessage() };
_log.error("FileDeviceController::deleteQuotaDirectory: Unable to create file system quota dir: storage {}, FS {}, quotadir {}: {}", params);
updateTaskStatus(task, fsObj, e);
updateTaskStatus(task, quotaDirObj, e);
if ((fsObj != null) && (quotaDirObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, false, e.getMessage(), "", quotaDirObj, fsObj);
}
}
}
use of com.emc.storageos.db.client.model.StorageSystem 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);
}
}
Aggregations