use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getTargetVirtualArrays.
@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "unprotectedFilesystem" })
public List<AssetOption> getTargetVirtualArrays(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 FileProvider method getFileTargetVirtualPools.
@Asset("fileTargetVirtualPool")
@AssetDependencies({ "fileFilePolicy" })
public List<AssetOption> getFileTargetVirtualPools(AssetOptionsContext ctx, URI filePolicy) {
List<AssetOption> options = Lists.newArrayList();
ViPRCoreClient client = api(ctx);
FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
List<FileVirtualPoolRestRep> vpoolChanges = client.fileVpools().getByTenant(ctx.getTenant());
for (FileVirtualPoolRestRep vpool : vpoolChanges) {
if (vpool.getProtection() != null) {
if ((policyRest.getType().equals("file_snapshot") && vpool.getProtection().getScheduleSnapshots()) || (policyRest.getType().equals("file_replication") && vpool.getProtection().getReplicationSupported())) {
options.add(new AssetOption(vpool.getId(), vpool.getName()));
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method unassign.
@FlashException(value = "list", keep = true)
public static void unassign(String ids) {
FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(ids));
if (filePolicyRestRep != null) {
AssignPolicyForm assignPolicy = new AssignPolicyForm().form(filePolicyRestRep);
addRenderApplyPolicysAt();
addAssignedProjectArgs(filePolicyRestRep);
addAssignedVPoolArgs(filePolicyRestRep);
render(assignPolicy);
} else {
flash.error(MessagesUtils.get(UNKNOWN, ids));
list();
}
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method updateUnAssignPolicyParam.
private static Boolean updateUnAssignPolicyParam(AssignPolicyForm assignPolicy, FilePolicyUnAssignParam param) {
Boolean policyUnAssignment = false;
FilePolicyRestRep existingPolicy = getViprClient().fileProtectionPolicies().get(URI.create(assignPolicy.id));
if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(existingPolicy.getAppliedAt())) {
List<String> projects = Lists.newArrayList();
if (assignPolicy.unassignedProjects != null) {
projects = assignPolicy.unassignedProjects;
}
List<String> remove = projects;
// removed projects
Set<URI> unAssingRes = new HashSet<URI>();
if (!remove.isEmpty()) {
for (String project : remove) {
unAssingRes.add(uri(project));
}
policyUnAssignment = true;
}
param.setUnassignfrom(unAssingRes);
} else if (FilePolicyApplyLevel.vpool.name().equalsIgnoreCase(existingPolicy.getAppliedAt())) {
List<String> vPools = Lists.newArrayList();
if (assignPolicy.unassignedVirtualPools != null) {
vPools = assignPolicy.unassignedVirtualPools;
}
List<String> remove = vPools;
// removed vpools
Set<URI> unAssingRes = new HashSet<URI>();
if (!remove.isEmpty()) {
for (String vpool : remove) {
unAssingRes.add(uri(vpool));
}
policyUnAssignment = true;
}
param.setUnassignfrom(unAssingRes);
}
return policyUnAssignment;
}
use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.
the class FileSystems method getScheculePolicies.
public static void getScheculePolicies() {
ViPRCoreClient client = BourneUtil.getViprClient();
List<NamedRelatedResourceRep> filePolicies = client.fileProtectionPolicies().listFilePolicies().getFilePolicies();
List<StringOption> policyOptions = Lists.newArrayList();
for (NamedRelatedResourceRep filePolicy : filePolicies) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(filePolicy.getId());
if (policyRestRep != null && "file_system".equalsIgnoreCase(policyRestRep.getAppliedAt())) {
policyOptions.add(new StringOption(policyRestRep.getId().toString(), filePolicy.getName()));
}
}
renderJSON(policyOptions);
}
Aggregations