use of com.emc.storageos.db.client.model.SchedulePolicy.SnapshotExpireType in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getIsilonSnapshotExpireValue.
private Integer getIsilonSnapshotExpireValue(FilePolicy policy) {
Long seconds = 0L;
String snapshotExpire = policy.getSnapshotExpireType();
if (snapshotExpire != null && !snapshotExpire.isEmpty()) {
Long expireValue = policy.getSnapshotExpireTime();
SnapshotExpireType expireType = SnapshotExpireType.valueOf(snapshotExpire.toUpperCase());
switch(expireType) {
case HOURS:
seconds = TimeUnit.HOURS.toSeconds(expireValue);
break;
case DAYS:
seconds = TimeUnit.DAYS.toSeconds(expireValue);
break;
case WEEKS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 7);
break;
case MONTHS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 30);
break;
case NEVER:
return null;
default:
_log.error("Not a valid expire type: " + expireType);
return null;
}
}
return seconds.intValue();
}
use of com.emc.storageos.db.client.model.SchedulePolicy.SnapshotExpireType in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getSnapshotExpireValue.
private Integer getSnapshotExpireValue(FileSnapshotPolicyExpireParam snapExpireParam) {
Long seconds = 0L;
String snapshotExpire = snapExpireParam.getExpireType();
if (snapshotExpire != null && !snapshotExpire.isEmpty()) {
int expireValue = snapExpireParam.getExpireValue();
SnapshotExpireType expireType = SnapshotExpireType.valueOf(snapshotExpire.toUpperCase());
switch(expireType) {
case HOURS:
seconds = TimeUnit.HOURS.toSeconds(expireValue);
break;
case DAYS:
seconds = TimeUnit.DAYS.toSeconds(expireValue);
break;
case WEEKS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 7);
break;
case MONTHS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 30);
break;
case NEVER:
return null;
default:
_log.error("Not a valid expire type: " + expireType);
return null;
}
}
return seconds.intValue();
}
use of com.emc.storageos.db.client.model.SchedulePolicy.SnapshotExpireType in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getSnapshotExpireValue.
@Deprecated
private Integer getSnapshotExpireValue(SchedulePolicy schedulePolicy) {
Long seconds = 0L;
String snapshotExpire = schedulePolicy.getSnapshotExpireType();
if (snapshotExpire != null && !snapshotExpire.isEmpty()) {
Long expireValue = schedulePolicy.getSnapshotExpireTime();
SnapshotExpireType expireType = SnapshotExpireType.valueOf(snapshotExpire.toUpperCase());
switch(expireType) {
case HOURS:
seconds = TimeUnit.HOURS.toSeconds(expireValue);
break;
case DAYS:
seconds = TimeUnit.DAYS.toSeconds(expireValue);
break;
case WEEKS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 7);
break;
case MONTHS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 30);
break;
case NEVER:
return null;
default:
_log.error("Not a valid expire type: " + expireType);
return null;
}
}
return seconds.intValue();
}
use of com.emc.storageos.db.client.model.SchedulePolicy.SnapshotExpireType in project coprhd-controller by CoprHD.
the class SchedulePolicyService method validateSnapshotExpireParam.
/**
* validates whether the snapshot expire parameters are valid or not
*
* @param expireParam - snapshot expire parameters
* @return true/false
*/
public static boolean validateSnapshotExpireParam(ScheduleSnapshotExpireParam expireParam) {
long seconds = 0;
long minPeriod = 7200;
long maxPeriod = 10 * 365 * 24 * 3600;
int expireValue = expireParam.getExpireValue();
SnapshotExpireType expireType = SnapshotExpireType.valueOf(expireParam.getExpireType().toUpperCase());
switch(expireType) {
case HOURS:
seconds = TimeUnit.HOURS.toSeconds(expireValue);
break;
case DAYS:
seconds = TimeUnit.DAYS.toSeconds(expireValue);
break;
case WEEKS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 7);
break;
case MONTHS:
seconds = TimeUnit.DAYS.toSeconds(expireValue * 30);
break;
case NEVER:
return true;
default:
return false;
}
if (seconds >= minPeriod && seconds <= maxPeriod) {
return true;
}
return false;
}
Aggregations