use of com.emc.storageos.model.file.policy.FilePolicyUpdateParam in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateStorageSystemFileProtectionPolicy.
@Override
public BiosCommandResult updateStorageSystemFileProtectionPolicy(StorageSystem storage, FileDeviceInputOutput args) {
FilePolicy existingPolicy = args.getFileProtectionPolicy();
PolicyStorageResource policyRes = args.getPolicyStorageResource();
FilePolicyUpdateParam policyUpdateParam = args.getFileProtectionPolicyUpdateParam();
IsilonApi isi = getIsilonDevice(storage);
BiosCommandResult result = null;
try {
if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
boolean isVersion8above = false;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storage.getFirmwareVersion()) >= 0) {
isVersion8above = true;
}
return updateStorageSystemFileReplicationPolicy(isi, policyRes, existingPolicy, policyUpdateParam, isVersion8above);
} else if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_snapshot.name())) {
return updateStorageSystemFileSnapshotPolicy(isi, policyRes, existingPolicy, policyUpdateParam);
} else {
String errorMsg = "Invalid policy type {} " + existingPolicy.getFilePolicyType();
_log.error(errorMsg);
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_STORAGE_SYSTEM_POLICY_BY_POLICY_RESOURCE.toString(), errorMsg);
result = BiosCommandResult.createErrorResult(serviceCoded);
existingPolicy.getOpStatus().updateTaskStatus(args.getOpId(), result.toOperation());
return result;
}
} catch (IsilonException e) {
_log.error("Update storage system policy for file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.model.file.policy.FilePolicyUpdateParam in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method save.
@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(SchedulePolicyForm schedulePolicy) {
if (schedulePolicy == null) {
Logger.error("No policy parameters passed");
badRequest("No policy parameters passed");
return;
}
schedulePolicy.validate("schedulePolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
schedulePolicy.id = params.get("id");
URI policyId = null;
if (schedulePolicy.isNew()) {
schedulePolicy.tenantId = Models.currentAdminTenant();
FilePolicyCreateParam policyParam = new FilePolicyCreateParam();
updatePolicyParam(schedulePolicy, policyParam, null);
policyParam.setPolicyType(schedulePolicy.policyType);
if (schedulePolicy.description != null && !schedulePolicy.description.isEmpty()) {
policyParam.setPolicyDescription(schedulePolicy.description);
}
FilePolicyCreateResp createdPolicy = getViprClient().fileProtectionPolicies().create(policyParam);
policyId = createdPolicy.getId();
} else {
FilePolicyRestRep schedulePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(schedulePolicy.id));
FilePolicyUpdateParam input = new FilePolicyUpdateParam();
updatePolicyParam(schedulePolicy, input, schedulePolicyRestRep.getType());
getViprClient().fileProtectionPolicies().update(schedulePolicyRestRep.getId(), input);
policyId = schedulePolicyRestRep.getId();
}
// Update the ACLs
com.emc.vipr.client.core.FileProtectionPolicies filePolicies = getViprClient().fileProtectionPolicies();
schedulePolicy.saveTenantACLs(filePolicies, policyId);
flash.success(MessagesUtils.get("schedulepolicies.saved", schedulePolicy.policyName));
if (StringUtils.isNotBlank(schedulePolicy.referrerUrl)) {
redirect(schedulePolicy.referrerUrl);
} else {
list();
}
}
Aggregations