Integrated Maintenance Window fields in Management API and UI (#677)
* Added Maintenance Window properties to API and UI * extended Management API with Maintenance Window schedule, duration, timezone and nextAt properties * extended integration tests for the above properties * extended Management UI with Maintenance Window column in Action History grid, added tooltip for next execution * general refactoring Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * fixed Sonar issues Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * changed the documentation help link for maintenance window Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * added licence header, first refactoring after partial PR review Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * changes related to PR review findings Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * last PR review findings Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
1deb47a4db
commit
b5114081be
@@ -8,88 +8,32 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* JSON model for Management API to define the maintenance window based on a
|
||||
* schedule defined as cron expression, duration in HH:mm:ss format and time
|
||||
* zone as offset from UTC.
|
||||
* JSON model for Management API to define the maintenance window.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtMaintenanceWindow {
|
||||
|
||||
private String maintenanceSchedule;
|
||||
private String maintenanceWindowDuration;
|
||||
private String maintenanceWindowTimeZone;
|
||||
public class MgmtMaintenanceWindow extends MgmtMaintenanceWindowRequestBody {
|
||||
|
||||
/**
|
||||
* Sets the maintenance schedule.
|
||||
*
|
||||
* @param maintenanceSchedule
|
||||
* is the cron expression to be used for scheduling maintenance
|
||||
* window(s). Expression has 6 mandatory fields and a last
|
||||
* optional field: "second minute hour dayofmonth month weekday
|
||||
* year".
|
||||
* Time in {@link TimeUnit#MILLISECONDS} of the next maintenance window
|
||||
* start
|
||||
*/
|
||||
@JsonSetter("schedule")
|
||||
public void setMaintenanceSchedule(final String maintenanceSchedule) {
|
||||
this.maintenanceSchedule = maintenanceSchedule;
|
||||
@JsonProperty
|
||||
private long nextStartAt;
|
||||
|
||||
public long getNextStartAt() {
|
||||
return nextStartAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maintenance window duration.
|
||||
*
|
||||
* @param maintenanceWindowDuration
|
||||
* in HH:mm:ss format specifying the duration of a maintenance
|
||||
* window, for example 00:30:00 for 30 minutes.
|
||||
*/
|
||||
@JsonSetter("duration")
|
||||
public void setMaintenanceWindowDuration(final String maintenanceWindowDuration) {
|
||||
this.maintenanceWindowDuration = maintenanceWindowDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maintenance window timezone.
|
||||
*
|
||||
* @param maintenanceWindowTimeZone
|
||||
* is the time zone specified as +/-hh:mm offset from UTC. For
|
||||
* example +02:00 for CET summer time and +00:00 for UTC. The
|
||||
* start time of a maintenance window calculated based on the
|
||||
* cron expression is relative to this time zone.
|
||||
*/
|
||||
@JsonSetter("timezone")
|
||||
public void setMaintenanceWindowTimeZone(final String maintenanceWindowTimeZone) {
|
||||
this.maintenanceWindowTimeZone = maintenanceWindowTimeZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maintenance schedule for the {@link Action}.
|
||||
*
|
||||
* @return cron expression as {@link String}.
|
||||
*/
|
||||
public String getMaintenanceSchedule() {
|
||||
return maintenanceSchedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of maintenance window for the {@link Action}.
|
||||
*
|
||||
* @return duration in HH:mm:ss format as {@link String}.
|
||||
*/
|
||||
public String getMaintenanceWindowDuration() {
|
||||
return maintenanceWindowDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timezone of maintenance window for the {@link Action}.
|
||||
*
|
||||
* @return the timezone offset from UTC in +/-hh:mm as {@link String}.
|
||||
*/
|
||||
public String getMaintenanceWindowTimeZone() {
|
||||
return maintenanceWindowTimeZone;
|
||||
public void setNextStartAt(final long nextStartAt) {
|
||||
this.nextStartAt = nextStartAt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Copyright (c) 2018 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Request body for maintenance window PUT/POST commands, based on a schedule
|
||||
* defined as cron expression, duration in HH:mm:ss format and time zone as
|
||||
* offset from UTC.
|
||||
*
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtMaintenanceWindowRequestBody {
|
||||
@JsonProperty
|
||||
private String schedule;
|
||||
|
||||
@JsonProperty
|
||||
private String duration;
|
||||
|
||||
@JsonProperty
|
||||
private String timezone;
|
||||
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schedule
|
||||
* is the cron expression to be used for scheduling maintenance
|
||||
* window(s). Expression has 6 mandatory fields and a last
|
||||
* optional field: "second minute hour dayofmonth month weekday
|
||||
* year".
|
||||
*/
|
||||
public void setSchedule(final String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duration
|
||||
* in HH:mm:ss format specifying the duration of a maintenance
|
||||
* window, for example 00:30:00 for 30 minutes.
|
||||
*/
|
||||
public void setDuration(final String duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timezone
|
||||
* is the time zone specified as +/-hh:mm offset from UTC. For
|
||||
* example +02:00 for CET summer time and +00:00 for UTC. The
|
||||
* start time of a maintenance window calculated based on the
|
||||
* cron expression is relative to this time zone.
|
||||
*/
|
||||
public void setTimezone(final String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.mgmt.json.model.action;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindow;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
@@ -59,6 +60,17 @@ public class MgmtAction extends MgmtBaseEntity {
|
||||
@JsonProperty
|
||||
private MgmtActionType forceType;
|
||||
|
||||
@JsonProperty
|
||||
private MgmtMaintenanceWindow maintenanceWindow;
|
||||
|
||||
public MgmtMaintenanceWindow getMaintenanceWindow() {
|
||||
return maintenanceWindow;
|
||||
}
|
||||
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindow maintenanceWindow) {
|
||||
this.maintenanceWindow = maintenanceWindow;
|
||||
}
|
||||
|
||||
public Long getForceTime() {
|
||||
return forceTime;
|
||||
}
|
||||
@@ -75,47 +87,26 @@ public class MgmtAction extends MgmtBaseEntity {
|
||||
this.forceType = forceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* the status to set
|
||||
*/
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionId
|
||||
*/
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actionId
|
||||
* the actionId to set
|
||||
*/
|
||||
public void setActionId(final Long actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.distributionset;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindow;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindowRequestBody;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -28,10 +28,10 @@ public class MgmtTargetAssignmentRequestBody {
|
||||
private MgmtActionType type;
|
||||
|
||||
/**
|
||||
* {@link MgmtMaintenanceWindow} object containing schedule, duration and
|
||||
* timezone.
|
||||
* {@link MgmtMaintenanceWindowRequestBody} object containing schedule,
|
||||
* duration and timezone.
|
||||
*/
|
||||
private MgmtMaintenanceWindow maintenanceWindow;
|
||||
private MgmtMaintenanceWindowRequestBody maintenanceWindow;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -57,11 +57,11 @@ public class MgmtTargetAssignmentRequestBody {
|
||||
this.forcetime = forcetime;
|
||||
}
|
||||
|
||||
public MgmtMaintenanceWindow getMaintenanceWindow() {
|
||||
public MgmtMaintenanceWindowRequestBody getMaintenanceWindow() {
|
||||
return maintenanceWindow;
|
||||
}
|
||||
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindow maintenanceWindow) {
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindowRequestBody maintenanceWindow) {
|
||||
this.maintenanceWindow = maintenanceWindow;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package org.eclipse.hawkbit.mgmt.json.model.target;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindow;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindowRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
||||
|
||||
/**
|
||||
@@ -16,10 +16,10 @@ public class MgmtDistributionSetAssignment extends MgmtId {
|
||||
private MgmtActionType type;
|
||||
|
||||
/**
|
||||
* {@link MgmtMaintenanceWindow} object defining a schedule, duration and
|
||||
* timezone.
|
||||
* {@link MgmtMaintenanceWindowRequestBody} object defining a schedule,
|
||||
* duration and timezone.
|
||||
*/
|
||||
private MgmtMaintenanceWindow maintenanceWindow;
|
||||
private MgmtMaintenanceWindowRequestBody maintenanceWindow;
|
||||
|
||||
public MgmtActionType getType() {
|
||||
return type;
|
||||
@@ -38,21 +38,23 @@ public class MgmtDistributionSetAssignment extends MgmtId {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link MgmtMaintenanceWindow} for distribution set assignment.
|
||||
* Returns {@link MgmtMaintenanceWindowRequestBody} for distribution set
|
||||
* assignment.
|
||||
*
|
||||
* @return {@link MgmtMaintenanceWindow}.
|
||||
* @return {@link MgmtMaintenanceWindowRequestBody}.
|
||||
*/
|
||||
public MgmtMaintenanceWindow getMaintenanceWindow() {
|
||||
public MgmtMaintenanceWindowRequestBody getMaintenanceWindow() {
|
||||
return maintenanceWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link MgmtMaintenanceWindow} for distribution set assignment.
|
||||
* Sets {@link MgmtMaintenanceWindowRequestBody} for distribution set
|
||||
* assignment.
|
||||
*
|
||||
* @param maintenanceWindow
|
||||
* as {@link MgmtMaintenanceWindow}.
|
||||
* as {@link MgmtMaintenanceWindowRequestBody}.
|
||||
*/
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindow maintenanceWindow) {
|
||||
public void setMaintenanceWindow(final MgmtMaintenanceWindowRequestBody maintenanceWindow) {
|
||||
this.maintenanceWindow = maintenanceWindow;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user