Search in sources :

Example 6 with FilePolicyScheduleParams

use of com.emc.storageos.model.file.policy.FilePolicyScheduleParams in project coprhd-controller by CoprHD.

the class FilePolicyApiTest method testCreatePolicyWithInValidPolicyScheduleRepeat.

@Test
public void testCreatePolicyWithInValidPolicyScheduleRepeat() {
    FilePolicyCreateParam param = new FilePolicyCreateParam();
    setFilePolicyMandatoryParams(param);
    FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
    // Value less than 1
    policySchedule.setScheduleRepeat(0L);
    policySchedule.setScheduleTime("12:00");
    policySchedule.setScheduleFrequency("DAYS");
    FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
    snapshotPolicyParam.setPolicySchedule(policySchedule);
    param.setSnapshotPolicyPrams(snapshotPolicyParam);
    FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
    snapshotExpireParams.setExpireType(SnapshotExpireType.NEVER.toString());
    snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
    ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
    Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSnapshotPolicyExpireParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) FilePolicyScheduleParams(com.emc.storageos.model.file.policy.FilePolicyScheduleParams) Test(org.junit.Test)

Example 7 with FilePolicyScheduleParams

use of com.emc.storageos.model.file.policy.FilePolicyScheduleParams in project coprhd-controller by CoprHD.

the class FilePolicyApiTest method testCreatePolicyWithInValidPolicyScheduleDayOfMonth.

@Test
public void testCreatePolicyWithInValidPolicyScheduleDayOfMonth() {
    FilePolicyCreateParam param = new FilePolicyCreateParam();
    setFilePolicyMandatoryParams(param);
    FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
    FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
    snapshotExpireParams.setExpireType(SnapshotExpireType.NEVER.toString());
    snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
    FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
    policySchedule.setScheduleRepeat(6L);
    policySchedule.setScheduleTime("13:00");
    policySchedule.setScheduleFrequency("MONTHS");
    // Invalid day of month(not in range of 1-31)
    policySchedule.setScheduleDayOfWeek("34");
    snapshotPolicyParam.setPolicySchedule(policySchedule);
    param.setSnapshotPolicyPrams(snapshotPolicyParam);
    ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
    Assert.assertEquals(createFilePolicyResp.toString(), HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSnapshotPolicyExpireParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) FilePolicyScheduleParams(com.emc.storageos.model.file.policy.FilePolicyScheduleParams) Test(org.junit.Test)

Example 8 with FilePolicyScheduleParams

use of com.emc.storageos.model.file.policy.FilePolicyScheduleParams in project coprhd-controller by CoprHD.

the class FilePolicyApiTest method testCreateSnapshotPolicyInvalidExpireValue.

@Test
public void testCreateSnapshotPolicyInvalidExpireValue() {
    FilePolicyCreateParam param = new FilePolicyCreateParam();
    setFilePolicyMandatoryParams(param);
    FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
    FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
    setFilePolicyScheduleParams(policySchedule);
    snapshotPolicyParam.setPolicySchedule(policySchedule);
    param.setSnapshotPolicyPrams(snapshotPolicyParam);
    FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
    snapshotExpireParams.setExpireType("HOURS");
    // Some invalid value less than 2 hours or greater than 2 years
    snapshotExpireParams.setExpireValue(1);
    snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
    ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
    Assert.assertEquals(createFilePolicyResp.toString(), HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSnapshotPolicyExpireParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) FilePolicyScheduleParams(com.emc.storageos.model.file.policy.FilePolicyScheduleParams) Test(org.junit.Test)

Example 9 with FilePolicyScheduleParams

use of com.emc.storageos.model.file.policy.FilePolicyScheduleParams in project coprhd-controller by CoprHD.

the class FilePolicyApiTest method testCreateSnapshotPolicyInvalidExpireType.

@Test
public void testCreateSnapshotPolicyInvalidExpireType() {
    FilePolicyCreateParam param = new FilePolicyCreateParam();
    setFilePolicyMandatoryParams(param);
    FileSnapshotPolicyParam snapshotPolicyParam = new FileSnapshotPolicyParam();
    FilePolicyScheduleParams policySchedule = new FilePolicyScheduleParams();
    setFilePolicyScheduleParams(policySchedule);
    snapshotPolicyParam.setPolicySchedule(policySchedule);
    param.setSnapshotPolicyPrams(snapshotPolicyParam);
    FileSnapshotPolicyExpireParam snapshotExpireParams = new FileSnapshotPolicyExpireParam();
    // Invalid Expire Type
    snapshotExpireParams.setExpireType("some_junk_value");
    snapshotPolicyParam.setSnapshotExpireParams(snapshotExpireParams);
    ClientResponse createFilePolicyResp = rSys.path(FILE_POLICIES).post(ClientResponse.class, param);
    Assert.assertEquals(createFilePolicyResp.toString(), HttpStatus.SC_BAD_REQUEST, createFilePolicyResp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSnapshotPolicyExpireParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) FilePolicyScheduleParams(com.emc.storageos.model.file.policy.FilePolicyScheduleParams) Test(org.junit.Test)

Example 10 with FilePolicyScheduleParams

use of com.emc.storageos.model.file.policy.FilePolicyScheduleParams in project coprhd-controller by CoprHD.

the class FileProtectionPolicies method updatePolicyParam.

private static FilePolicyParam updatePolicyParam(SchedulePolicyForm schedulePolicy, FilePolicyParam param, String policyType) {
    param.setPolicyName(schedulePolicy.policyName);
    if (schedulePolicy.appliedAt != null) {
        param.setApplyAt(schedulePolicy.appliedAt);
    }
    if (schedulePolicy.description != null && !schedulePolicy.description.isEmpty()) {
        param.setPolicyDescription(schedulePolicy.description);
    }
    if (policyType == null) {
        policyType = schedulePolicy.policyType;
    }
    FilePolicyScheduleParams scheduleParam = new FilePolicyScheduleParams();
    if (policyType.equalsIgnoreCase("file_snapshot") || policyType.equalsIgnoreCase("file_replication")) {
        scheduleParam.setScheduleTime(schedulePolicy.scheduleHour + ":" + schedulePolicy.scheduleMin);
        scheduleParam.setScheduleFrequency(schedulePolicy.frequency);
        scheduleParam.setScheduleRepeat(schedulePolicy.repeat);
        if (schedulePolicy.frequency != null && "weeks".equals(schedulePolicy.frequency)) {
            if (schedulePolicy.scheduleDayOfWeek != null) {
                scheduleParam.setScheduleDayOfWeek(schedulePolicy.scheduleDayOfWeek);
            }
        } else if (schedulePolicy.frequency != null && "months".equals(schedulePolicy.frequency)) {
            scheduleParam.setScheduleDayOfMonth(schedulePolicy.scheduleDayOfMonth);
        }
    }
    if (policyType.equalsIgnoreCase("file_snapshot")) {
        FileSnapshotPolicyParam snapshotParam = new FileSnapshotPolicyParam();
        snapshotParam.setSnapshotNamePattern(schedulePolicy.snapshotNamePattern);
        snapshotParam.setPolicySchedule(scheduleParam);
        FileSnapshotPolicyExpireParam snapExpireParam = new FileSnapshotPolicyExpireParam();
        if (schedulePolicy.expiration != null && !"NEVER".equals(schedulePolicy.expiration)) {
            snapExpireParam.setExpireType(schedulePolicy.expireType);
            snapExpireParam.setExpireValue(schedulePolicy.expireValue);
            snapshotParam.setSnapshotExpireParams(snapExpireParam);
            param.setSnapshotPolicyPrams(snapshotParam);
        }
        if ("NEVER".equals(schedulePolicy.expiration)) {
            snapExpireParam.setExpireType("never");
            snapshotParam.setSnapshotExpireParams(snapExpireParam);
            param.setSnapshotPolicyPrams(snapshotParam);
        }
    } else if (policyType.equalsIgnoreCase("file_replication")) {
        FileReplicationPolicyParam replicationPolicyParams = new FileReplicationPolicyParam();
        replicationPolicyParams.setReplicationCopyMode(schedulePolicy.replicationCopyType);
        replicationPolicyParams.setReplicationType(schedulePolicy.replicationType);
        replicationPolicyParams.setPolicySchedule(scheduleParam);
        param.setPriority(schedulePolicy.priority);
        param.setNumWorkerThreads(schedulePolicy.numWorkerThreads);
        param.setReplicationPolicyParams(replicationPolicyParams);
    }
    return param;
}
Also used : FileReplicationPolicyParam(com.emc.storageos.model.file.policy.FileReplicationPolicyParam) FileSnapshotPolicyExpireParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) FilePolicyScheduleParams(com.emc.storageos.model.file.policy.FilePolicyScheduleParams)

Aggregations

FilePolicyScheduleParams (com.emc.storageos.model.file.policy.FilePolicyScheduleParams)10 FileSnapshotPolicyExpireParam (com.emc.storageos.model.file.policy.FileSnapshotPolicyExpireParam)9 FileSnapshotPolicyParam (com.emc.storageos.model.file.policy.FileSnapshotPolicyParam)9 FilePolicyCreateParam (com.emc.storageos.model.file.policy.FilePolicyCreateParam)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)8 Test (org.junit.Test)8 FilePolicyCreateResp (com.emc.storageos.model.file.policy.FilePolicyCreateResp)1 FileReplicationPolicyParam (com.emc.storageos.model.file.policy.FileReplicationPolicyParam)1