use of com.emc.storageos.db.client.model.FilePolicy 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.db.client.model.FilePolicy 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);
}
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileDeviceController method checkFilePolicyPathHasResourceLabel.
@Override
public void checkFilePolicyPathHasResourceLabel(URI storage, URI filePolicyURI, URI nasURI, URI vpoolURI, URI projectURI, String opId) {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyURI);
args.setFileProtectionPolicy(filePolicy);
if (vpoolURI != null) {
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
args.setVPool(vpool);
}
if (projectURI != null) {
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
args.setProject(project);
args.setTenantOrg(tenant);
}
if (nasURI != null) {
if (URIUtil.isType(nasURI, VirtualNAS.class)) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, nasURI);
args.setvNAS(vNAS);
}
}
BiosCommandResult result = getDevice(system.getSystemType()).checkFilePolicyPathHasResourceLabel(system, 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 error = DeviceControllerException.errors.jobFailed(e);
_log.error("Error occured while checking policy path has resorce label.", e);
WorkflowStepCompleter.stepFailed(opId, error);
}
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileDeviceController method doDeletePolicyReferenceFromDB.
/**
* Delete the reference of FileShare from SchedulePolicy
*
* @param fs
*/
private void doDeletePolicyReferenceFromDB(FileShare fs) {
_log.info("Removing policy reference for file system " + fs.getName());
for (String policy : fs.getFilePolicies()) {
FilePolicy fp = _dbClient.queryObject(FilePolicy.class, URI.create(policy));
if (fp != null && !fp.getInactive()) {
StringSet fsURIs = fp.getAssignedResources();
fsURIs.remove(fs.getId().toString());
fp.setAssignedResources(fsURIs);
_dbClient.updateObject(fp);
}
}
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileDeviceController method assignFileReplicationPolicyToProjects.
@Override
public void assignFileReplicationPolicyToProjects(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
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);
Project project = _dbClient.queryObject(Project.class, projectURI);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
VirtualNAS sourceVNAS = null;
VirtualNAS targetVNAS = null;
FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
sourceArgs.setFileProtectionPolicy(filePolicy);
sourceArgs.setVPool(vpool);
sourceArgs.setProject(project);
sourceArgs.setTenantOrg(tenant);
targetArgs.setVarray(targetVarray);
if (sourceVNasURI != null) {
sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
sourceArgs.setvNAS(sourceVNAS);
targetArgs.setSourceVNAS(sourceVNAS);
}
targetArgs.setTarget(true);
targetArgs.setSourceSystem(sourceSystem);
targetArgs.setVPool(vpool);
targetArgs.setProject(project);
targetArgs.setTenantOrg(tenant);
if (targetVNasURI != null) {
targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
targetArgs.setvNAS(targetVNAS);
}
_log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
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);
}
}
Aggregations