use of org.ovirt.engine.core.common.action.gluster.ScheduleGlusterVolumeSnapshotParameters in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotListModel method scheduleSnapshot.
private void scheduleSnapshot(final GlusterVolumeSnapshotModel snapshotModel, boolean reschedule) {
GlusterVolumeEntity volumeEntity = getEntity();
final GlusterVolumeSnapshotSchedule schedule = new GlusterVolumeSnapshotSchedule();
schedule.setSnapshotNamePrefix(snapshotModel.getSnapshotName().getEntity());
schedule.setSnapshotDescription(snapshotModel.getDescription().getEntity());
schedule.setClusterId(volumeEntity.getClusterId());
schedule.setVolumeId(volumeEntity.getId());
switch(snapshotModel.getRecurrence().getSelectedItem()) {
case INTERVAL:
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.INTERVAL);
schedule.setInterval(Integer.valueOf(snapshotModel.getInterval().getSelectedItem()));
break;
case HOURLY:
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.HOURLY);
break;
case DAILY:
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.DAILY);
schedule.setExecutionTime(getExecutionTime(snapshotModel));
break;
case WEEKLY:
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.WEEKLY);
schedule.setExecutionTime(getExecutionTime(snapshotModel));
StringBuilder sb = new StringBuilder();
for (DayOfWeek day : snapshotModel.getDaysOfTheWeek().getSelectedItem()) {
sb.append(day.name().substring(0, 3));
// $NON-NLS-1$
sb.append(',');
}
schedule.setDays(sb.toString());
break;
case MONTHLY:
schedule.setRecurrence(GlusterVolumeSnapshotScheduleRecurrence.MONTHLY);
schedule.setExecutionTime(getExecutionTime(snapshotModel));
schedule.setDays(snapshotModel.getDaysOfMonth().getSelectedItem());
break;
}
Date startAt = snapshotModel.getStartAt().getEntity();
schedule.setStartDate(startAt);
schedule.setTimeZone(snapshotModel.getTimeZones().getSelectedItem().getKey());
if (snapshotModel.getEndByOptions().getSelectedItem() == EndDateOptions.NoEndDate) {
schedule.setEndByDate(null);
} else {
schedule.setEndByDate(snapshotModel.getEndDate().getEntity());
}
ScheduleGlusterVolumeSnapshotParameters params = new ScheduleGlusterVolumeSnapshotParameters(schedule, snapshotModel.getDisableCliSchedule().getEntity());
snapshotModel.startProgress();
ActionType actionType = null;
if (reschedule) {
actionType = ActionType.RescheduleGlusterVolumeSnapshot;
} else {
actionType = ActionType.ScheduleGlusterVolumeSnapshot;
}
Frontend.getInstance().runAction(actionType, params, result -> {
GlusterVolumeSnapshotListModel localModel = (GlusterVolumeSnapshotListModel) result.getState();
snapshotModel.stopProgress();
localModel.postSnapshotAction(result.getReturnValue());
}, this, snapshotModel.getDisableCliSchedule().getEntity());
}
Aggregations