use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class FileDeviceController method share.
@Override
public void share(URI storage, URI uri, FileSMBShare smbShare, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileObject fileObject = null;
StorageSystem storageObj = null;
FileShare fsObj = null;
Snapshot snapshotObj = null;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info(String.format("Create SMB share details --- name: %1$s, description: %2$s, permissionType: %3$s, permission: %4$s , maxUsers: %5$s", smbShare.getName(), smbShare.getDescription(), smbShare.getPermissionType(), smbShare.getPermission(), (smbShare.getMaxUsers() > 0) ? smbShare.getMaxUsers() : "unlimited"));
_log.info("Path {}", smbShare.getPath());
// get db object for smb share
SMBFileShare smbFileShare = smbShare.getSMBFileShare();
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setOpId(opId);
if (URIUtil.isType(uri, FileShare.class)) {
fsObj = _dbClient.queryObject(FileShare.class, uri);
fileObject = fsObj;
args.addFSFileObject(fsObj);
args.setFileOperation(true);
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
// Acquire lock for VNXFILE Storage System
WorkflowStepCompleter.stepExecuting(opId);
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fsObj);
List<SMBFileShare> shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
if (result.isCommandSuccess()) {
_log.info("File share created successfully");
createDefaultACEForSMBShare(uri, smbShare, storageObj.getSystemType());
WorkflowStepCompleter.stepSucceded(opId);
}
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), fsObj, smbShare);
} else {
snapshotObj = _dbClient.queryObject(Snapshot.class, uri);
fileObject = snapshotObj;
args.addSnapshotFileObject(snapshotObj);
fsObj = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
args.addFileShare(fsObj);
args.setFileOperation(false);
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
WorkflowStepCompleter.stepExecuting(opId);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
snapshotObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(snapshotObj);
List<SMBFileShare> shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
if (result.isCommandSuccess()) {
_log.info("File snapshot share created successfully");
WorkflowStepCompleter.stepSucceded(opId);
createDefaultACEForSMBShare(uri, smbShare, storageObj.getSystemType());
}
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), snapshotObj, fsObj, smbShare);
}
} catch (Exception e) {
String[] params = { storage.toString(), uri.toString(), smbShare.getName(), e.getMessage() };
_log.error("Unable to create file system or snapshot share: storage {}, FS/snapshot URI {}, SMB share {}: {}", params);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
updateTaskStatus(opId, fileObject, e);
if (URIUtil.isType(uri, FileShare.class)) {
if ((fsObj != null) && (storageObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, false, e.getMessage(), "", fsObj, smbShare, storageObj);
}
} else {
if ((fsObj != null) && (storageObj != null) && (snapshotObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, false, e.getMessage(), "", snapshotObj, fsObj, smbShare, storageObj);
}
}
}
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class FileDeviceController method snapshotFS.
@Override
public void snapshotFS(URI storage, URI snapshot, URI fs, String task) throws ControllerException {
ControllerUtils.setThreadLocalLogData(fs, task);
FileShare fsObj = null;
Snapshot snapshotObj = null;
try {
String[] params = { storage.toString(), snapshot.toString(), fs.toString() };
_log.info("Snapshot FS: storage : {}, snapshot : {}, fs : {}", params);
FileDeviceInputOutput args = new FileDeviceInputOutput();
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
fsObj = _dbClient.queryObject(FileShare.class, fs);
snapshotObj = _dbClient.queryObject(Snapshot.class, snapshot);
args.addFileShare(fsObj);
args.addSnapshot(snapshotObj);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, fsObj.getPool());
args.addStoragePool(storagePool);
args.setOpId(task);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, task);
WorkflowStepCompleter.stepExecuting(task);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doSnapshotFS(storageObj, args);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(task, result.getServiceCoded());
}
snapshotObj.setCreationTime(Calendar.getInstance());
fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
snapshotObj.getOpStatus().updateTaskStatus(task, result.toOperation());
snapshotObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, snapshotObj));
// Incase error, set the snapshot to inactive state.
if (!result.isCommandSuccess()) {
_log.error("Snapshot create command is not successfull, so making object to inactive");
snapshotObj.setInactive(true);
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(task);
}
_dbClient.updateObject(snapshotObj);
_dbClient.updateObject(fsObj);
fsObj = _dbClient.queryObject(FileShare.class, fs);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SNAPSHOT, result.isCommandSuccess(), eventMsg, "", snapshotObj, fsObj);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(task, serviceError);
String[] params = { storage.toString(), fs.toString(), snapshot.toString(), e.getMessage() };
_log.error("Unable to create file system snapshot: storage {}, FS {}, snapshot {}: {}", params);
updateTaskStatus(task, fsObj, e);
updateTaskStatus(task, snapshotObj, e);
if ((fsObj != null) && (snapshotObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SNAPSHOT, false, e.getMessage(), "", snapshotObj, fsObj);
}
}
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileSnapshotPolicyToVirtualPools.
@Override
public void assignFileSnapshotPolicyToVirtualPools(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
StorageSystem storageObj = null;
FilePolicy filePolicy = null;
VirtualNAS vNAS = null;
VirtualPool vpool = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
if (vNASURI != null) {
vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
args.setvNAS(vNAS);
}
args.setFileProtectionPolicy(filePolicy);
args.setVPool(vpool);
_log.info("Assigning file snapshot policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
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.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class FileDeviceController method applyFilePolicy.
@Override
public void applyFilePolicy(URI storage, URI sourceFS, URI policyURI, String taskId) throws ControllerException {
FileShare fsObj = null;
StorageSystem storageObj = null;
try {
fsObj = _dbClient.queryObject(FileShare.class, sourceFS);
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
Project project = _dbClient.queryObject(Project.class, fsObj.getProject());
TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, policyURI);
args.setOpId(taskId);
args.addFSFileObject(fsObj);
args.setVPool(vpool);
args.setTenantOrg(tenantOrg);
args.setProject(project);
args.setFileProtectionPolicy(filePolicy);
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
WorkflowStepCompleter.stepExecuting(taskId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doApplyFilePolicy(storageObj, args);
if (result.getCommandPending()) {
return;
} else if (result.isCommandSuccess()) {
_log.info("File policy: {} applied successfully", filePolicy.getFilePolicyName());
WorkflowStepCompleter.stepSucceded(taskId);
} else {
WorkflowStepCompleter.stepFailed(taskId, result.getServiceCoded());
}
} catch (Exception e) {
_log.error("Unable to apply file policy: {} to file system: {}", policyURI, fsObj.getId());
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
updateTaskStatus(taskId, fsObj, e);
}
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class FileDeviceController method updateStorageSystemFileProtectionPolicy.
@Override
public void updateStorageSystemFileProtectionPolicy(URI storage, URI policy, URI policyRes, FilePolicyUpdateParam policyUpdateParam, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(policy, opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
try {
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, policy);
PolicyStorageResource policyResource = _dbClient.queryObject(PolicyStorageResource.class, policyRes);
if (filePolicy != null && policyResource != null) {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info("Updating File protection ile Policy {}", policy);
args.setFileProtectionPolicy(filePolicy);
args.setPolicyStorageResource(policyResource);
args.setFileProtectionPolicyUpdateParam(policyUpdateParam);
args.setFileOperation(true);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).updateStorageSystemFileProtectionPolicy(storageObj, args);
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
if (result.isCommandSuccess()) {
WorkflowStepCompleter.stepSucceded(opId);
}
} else {
throw DeviceControllerException.exceptions.invalidObjectNull();
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
Aggregations