use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProvider method getFilePolicies.
@Asset("fileFilePolicy")
@AssetDependencies({ "project", "fileFilesystemAssociation" })
public List<AssetOption> getFilePolicies(AssetOptionsContext ctx, URI project, URI fsId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
for (FilePolicyRestRep policyRestRep : getAllFileSystemLevelPolicies(ctx)) {
options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
}
if (options != null && !options.isEmpty()) {
AssetOptionsUtils.sortOptionsByLabel(options);
}
return options;
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProvider method getAllFileSystemLevelPolicies.
private List<FilePolicyRestRep> getAllFileSystemLevelPolicies(AssetOptionsContext ctx) {
ViPRCoreClient client = api(ctx);
List<FilePolicyRestRep> fileSystemPolicies = new ArrayList<FilePolicyRestRep>();
FilePolicyListRestRep policies = client.fileProtectionPolicies().listFilePolicies();
if (policies != null && !policies.getFilePolicies().isEmpty()) {
for (NamedRelatedResourceRep policy : policies.getFilePolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(policy.getId());
if (policyRestRep != null && policyRestRep.getAppliedAt() != null && policyRestRep.getAppliedAt().equalsIgnoreCase("file_system")) {
fileSystemPolicies.add(policyRestRep);
}
}
}
return fileSystemPolicies;
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getFileTargetVirtualArrays.
@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "fileFilesystemAssociation" })
public List<AssetOption> getFileTargetVirtualArrays(AssetOptionsContext context, URI filePolicy, URI fsId) {
ViPRCoreClient client = api(context);
FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
if (policyRest.getType().equals("file_snapshot")) {
VirtualArrayRestRep vArray = null;
List<AssetOption> options = Lists.newArrayList();
FileShareRestRep fsObj = client.fileSystems().get(fsId);
if (fsObj != null) {
vArray = client.varrays().get(fsObj.getVirtualArray().getId());
options.add(createBaseResourceOption(vArray));
}
return options;
} else {
return getFileVirtualArrays(context);
}
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method saveAssignPolicy.
@FlashException(keep = true, referrer = { "assign" })
public static void saveAssignPolicy(AssignPolicyForm assignPolicy) {
if (assignPolicy == null) {
Logger.error("No assign policy parameters passed");
badRequest("No assign policy parameters passed");
return;
}
assignPolicy.validate("assignPolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
assignPolicy.id = params.get("id");
FilePolicyRestRep policy = getViprClient().fileProtectionPolicies().getFilePolicy(uri(assignPolicy.id));
if (policy.getAppliedAt().equalsIgnoreCase(FilePolicyApplyLevel.file_system.name())) {
list();
}
FilePolicyAssignParam assignPolicyParam = new FilePolicyAssignParam();
if (assignPolicy.topologiesString == null || assignPolicy.topologiesString.equalsIgnoreCase("[]")) {
if (policy.getReplicationSettings() != null && policy.getReplicationSettings().getType().equalsIgnoreCase(FileReplicationType.REMOTE.name())) {
flash.error("No source and target varry parameters passed", policy.getName());
if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
redirect(assignPolicy.referrerUrl);
} else {
list();
}
}
}
try {
updateAssignPolicyParam(assignPolicy, assignPolicyParam);
TaskResourceRep taskRes = getViprClient().fileProtectionPolicies().assignPolicy(uri(assignPolicy.id), assignPolicyParam);
if (isTaskSuccessful(assignPolicy.id, taskRes)) {
flash.success(MessagesUtils.get("assignPolicy.request.saved", assignPolicy.policyName));
}
} catch (Exception ex) {
flash.error(ex.getMessage(), assignPolicy.policyName);
}
if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
redirect(assignPolicy.referrerUrl);
} else {
list();
}
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method details.
public static void details(String id) {
FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(id));
if (filePolicyRestRep == null) {
renderJSON("");
}
renderJSON(filePolicyRestRep);
}
Aggregations