Search in sources :

Example 1 with FilePolicyUpdateParam

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);
    }
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) FilePolicyUpdateParam(com.emc.storageos.model.file.policy.FilePolicyUpdateParam) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 2 with FilePolicyUpdateParam

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();
    }
}
Also used : FilePolicyUpdateParam(com.emc.storageos.model.file.policy.FilePolicyUpdateParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FilePolicyCreateResp(com.emc.storageos.model.file.policy.FilePolicyCreateResp) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) URI(java.net.URI) FlashException(controllers.util.FlashException)

Aggregations

FilePolicyUpdateParam (com.emc.storageos.model.file.policy.FilePolicyUpdateParam)2 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)1 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)1 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)1 FilePolicyCreateParam (com.emc.storageos.model.file.policy.FilePolicyCreateParam)1 FilePolicyCreateResp (com.emc.storageos.model.file.policy.FilePolicyCreateResp)1 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)1 FlashException (controllers.util.FlashException)1 URI (java.net.URI)1