public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui
@ 2021-11-11 11:07 Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

* adds the pvescheduler manpage to pve-docs (not sure about the transition
  here regarding dependcies, hope it's ok this way)
* mentions the schedules in vzdump too
* hide the id on create/edit completely (autogenerate it)
* add a 'simulate' api and gui for simulating schedules

pve-docs:

Dominik Csapak (3):
  refactor calendar events into appendix
  vzdump: change vzdump.cron to pvescheduler
  add pvescheduler docs and manpage

 calendar-events.adoc | 73 ++++++++++++++++++++++++++++++++++++++++++++
 pve-admin-guide.adoc | 18 +++++++++++
 pvescheduler.adoc    | 33 ++++++++++++++++++++
 pvesr.adoc           | 72 ++-----------------------------------------
 vzdump.adoc          |  5 ++-
 5 files changed, 130 insertions(+), 71 deletions(-)
 create mode 100644 calendar-events.adoc
 create mode 100644 pvescheduler.adoc

pve-manager:

Dominik Csapak (5):
  ui: dc/Backup: never show id input field, autogenerate id
  ui: dc/Backup: fix comment sort
  api: cluster: add jobs/schedule-analyze api call
  ui: dc/Backup: add schedule simulator button
  remove pvescheduler manpage generation

 PVE/API2/Cluster.pm                      |   5 +
 PVE/API2/Cluster/Jobs.pm                 | 107 ++++++++++++++++++++
 PVE/API2/Cluster/Makefile                |   1 +
 bin/Makefile                             |   4 -
 www/manager6/Makefile                    |   1 +
 www/manager6/dc/Backup.js                |  38 ++++----
 www/manager6/window/ScheduleSimulator.js | 118 +++++++++++++++++++++++
 7 files changed, 252 insertions(+), 22 deletions(-)
 create mode 100644 PVE/API2/Cluster/Jobs.pm
 create mode 100644 www/manager6/window/ScheduleSimulator.js

-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 17:03   ` [pve-devel] applied-series: " Thomas Lamprecht
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 2/3] vzdump: change vzdump.cron to pvescheduler Dominik Csapak
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 calendar-events.adoc | 73 ++++++++++++++++++++++++++++++++++++++++++++
 pvesr.adoc           | 72 ++-----------------------------------------
 2 files changed, 75 insertions(+), 70 deletions(-)
 create mode 100644 calendar-events.adoc

diff --git a/calendar-events.adoc b/calendar-events.adoc
new file mode 100644
index 0000000..24a1dc6
--- /dev/null
+++ b/calendar-events.adoc
@@ -0,0 +1,73 @@
+[[chapter_calendar_events]]
+Schedule Format
+---------------
+
+{pve} has a very flexible scheduling configuration. It is based on the systemd
+time calendar event format.footnote:[see `man 7 systemd.time` for more information]
+Calendar events may be used to refer to one or more points in time in a
+single expression.
+
+Such a calendar event uses the following format:
+
+----
+[day(s)] [[start-time(s)][/repetition-time(s)]]
+----
+
+This format allows you to configure a set of days on which the job should run.
+You can also set one or more start times. It tells the replication scheduler
+the moments in time when a job should start.
+With this information we, can create a job which runs every workday at 10
+PM: `'mon,tue,wed,thu,fri 22'` which could be abbreviated to: `'mon..fri
+22'`, most reasonable schedules can be written quite intuitive this way.
+
+NOTE: Hours are formatted in 24-hour format.
+
+To allow a convenient and shorter configuration, one or more repeat times per
+guest can be set. They indicate that replications are done on the start-time(s)
+itself and the start-time(s) plus all multiples of the repetition value. If
+you want to start replication at 8 AM and repeat it every 15 minutes until
+9 AM you would use: `'8:00/15'`
+
+Here you see that if no hour separation (`:`), is used the value gets
+interpreted as minute. If such a separation is used, the value on the left
+denotes the hour(s), and the value on the right denotes the minute(s).
+Further, you can use `*` to match all possible values.
+
+To get additional ideas look at
+xref:pvesr_schedule_format_examples[more Examples below].
+
+Detailed Specification
+----------------------
+
+days:: Days are specified with an abbreviated English version: `sun, mon,
+tue, wed, thu, fri and sat`. You may use multiple days as a comma-separated
+list. A range of days can also be set by specifying the start and end day
+separated by ``..'', for example `mon..fri`. These formats can be mixed.
+If omitted `'*'` is assumed.
+
+time-format:: A time format consists of hours and minutes interval lists.
+Hours and minutes are separated by `':'`. Both hour and minute can be list
+and ranges of values, using the same format as days.
+First are hours, then minutes. Hours can be omitted if not needed. In this
+case `'*'` is assumed for the value of hours.
+The valid range for values is `0-23` for hours and `0-59` for minutes.
+
+[[pvesr_schedule_format_examples]]
+Examples:
+~~~~~~~~~
+
+.Schedule Examples
+[width="100%",options="header"]
+|==============================================================================
+|Schedule String	|Alternative		|Meaning
+|mon,tue,wed,thu,fri	|mon..fri		|Every working day at 0:00
+|sat,sun		|sat..sun		|Only on weekends at 0:00
+|mon,wed,fri		|--			|Only on Monday, Wednesday and Friday at 0:00
+|12:05			|12:05			|Every day at 12:05 PM
+|*/5			|0/5			|Every five minutes
+|mon..wed 30/10		|mon,tue,wed 30/10	|Monday, Tuesday, Wednesday 30, 40 and 50 minutes after every full hour
+|mon..fri 8..17,22:0/15	|--			|Every working day every 15 minutes between 8 AM and 6 PM and between 10 PM and 11 PM
+|fri 12..13:5/20	|fri 12,13:5/20		|Friday at 12:05, 12:25, 12:45, 13:05, 13:25 and 13:45
+|12,14,16,18,20,22:5	|12/2:5			|Every day starting at 12:05 until 22:05, every 2 hours
+|*			|*/1			|Every minute (minimum interval)
+|==============================================================================
diff --git a/pvesr.adoc b/pvesr.adoc
index 4506c9f..e508eee 100644
--- a/pvesr.adoc
+++ b/pvesr.adoc
@@ -80,76 +80,8 @@ Supported Storage Types
 [[pvesr_schedule_time_format]]
 Schedule Format
 ---------------
-
-{pve} has a very flexible replication scheduler. It is based on the systemd
-time calendar event format.footnote:[see `man 7 systemd.time` for more information]
-Calendar events may be used to refer to one or more points in time in a
-single expression.
-
-Such a calendar event uses the following format:
-
-----
-[day(s)] [[start-time(s)][/repetition-time(s)]]
-----
-
-This format allows you to configure a set of days on which the job should run.
-You can also set one or more start times. It tells the replication scheduler
-the moments in time when a job should start.
-With this information we, can create a job which runs every workday at 10
-PM: `'mon,tue,wed,thu,fri 22'` which could be abbreviated to: `'mon..fri
-22'`, most reasonable schedules can be written quite intuitive this way.
-
-NOTE: Hours are formatted in 24-hour format.
-
-To allow a convenient and shorter configuration, one or more repeat times per
-guest can be set. They indicate that replications are done on the start-time(s)
-itself and the start-time(s) plus all multiples of the repetition value. If
-you want to start replication at 8 AM and repeat it every 15 minutes until
-9 AM you would use: `'8:00/15'`
-
-Here you see that if no hour separation (`:`), is used the value gets
-interpreted as minute. If such a separation is used, the value on the left
-denotes the hour(s), and the value on the right denotes the minute(s).
-Further, you can use `*` to match all possible values.
-
-To get additional ideas look at
-xref:pvesr_schedule_format_examples[more Examples below].
-
-Detailed Specification
-~~~~~~~~~~~~~~~~~~~~~~
-
-days:: Days are specified with an abbreviated English version: `sun, mon,
-tue, wed, thu, fri and sat`. You may use multiple days as a comma-separated
-list. A range of days can also be set by specifying the start and end day
-separated by ``..'', for example `mon..fri`. These formats can be mixed.
-If omitted `'*'` is assumed.
-
-time-format:: A time format consists of hours and minutes interval lists.
-Hours and minutes are separated by `':'`. Both hour and minute can be list
-and ranges of values, using the same format as days.
-First are hours, then minutes. Hours can be omitted if not needed. In this
-case `'*'` is assumed for the value of hours.
-The valid range for values is `0-23` for hours and `0-59` for minutes.
-
-[[pvesr_schedule_format_examples]]
-Examples:
-~~~~~~~~~
-
-.Schedule Examples
-[width="100%",options="header"]
-|==============================================================================
-|Schedule String	|Alternative		|Meaning
-|mon,tue,wed,thu,fri	|mon..fri		|Every working day at 0:00
-|sat,sun		|sat..sun		|Only on weekends at 0:00
-|mon,wed,fri		|--			|Only on Monday, Wednesday and Friday at 0:00
-|12:05			|12:05			|Every day at 12:05 PM
-|*/5			|0/5			|Every five minutes
-|mon..wed 30/10		|mon,tue,wed 30/10	|Monday, Tuesday, Wednesday 30, 40 and 50 minutes after every full hour
-|mon..fri 8..17,22:0/15	|--			|Every working day every 15 minutes between 8 AM and 6 PM and between 10 PM and 11 PM
-|fri 12..13:5/20	|fri 12,13:5/20		|Friday at 12:05, 12:25, 12:45, 13:05, 13:25 and 13:45
-|12,14,16,18,20,22:5	|12/2:5			|Every day starting at 12:05 until 22:05, every 2 hours
-|*			|*/1			|Every minute (minimum interval)
-|==============================================================================
+Replication uses xref:chapter_calendar_events[calendar events] for
+configuring the schedule.
 
 Error Handling
 --------------
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH docs 2/3] vzdump: change vzdump.cron to pvescheduler
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 3/3] add pvescheduler docs and manpage Dominik Csapak
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 vzdump.adoc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vzdump.adoc b/vzdump.adoc
index a2b908d..96ae70d 100644
--- a/vzdump.adoc
+++ b/vzdump.adoc
@@ -49,7 +49,10 @@ archiving.
 Backup jobs can be scheduled so that they are executed automatically
 on specific days and times, for selectable nodes and guest systems.
 Configuration of scheduled backups is done at the Datacenter level in
-the GUI, which will generate a cron entry in /etc/cron.d/vzdump.
+the GUI, which will generate a job entry in /etc/pve/jobs.cfg, which
+will in turn be parsed and executed by the `pvescheduler` daemon.
+These jobs use the xref:chapter_calendar_events[calendar events] for
+defining the schedule.
 
 Backup modes
 ------------
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH docs 3/3] add pvescheduler docs and manpage
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 2/3] vzdump: change vzdump.cron to pvescheduler Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 1/5] ui: dc/Backup: never show id input field, autogenerate id Dominik Csapak
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pve-admin-guide.adoc | 18 ++++++++++++++++++
 pvescheduler.adoc    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100644 pvescheduler.adoc

diff --git a/pve-admin-guide.adoc b/pve-admin-guide.adoc
index b32b55b..d0a1637 100644
--- a/pve-admin-guide.adoc
+++ b/pve-admin-guide.adoc
@@ -66,6 +66,8 @@ include::pvestatd.adoc[]
 
 include::spiceproxy.adoc[]
 
+include::pvescheduler.adoc[]
+
 :leveloffset: 0
 
 
@@ -291,6 +293,13 @@ include::pve-ha-lrm.8-synopsis.adoc[]
 
 :leveloffset: 0
 
+*pvescheduler* - {pve} Scheduler Daemon
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+:leveloffset: 1
+include::pvescheduler.8-synopsis.adoc[]
+
+:leveloffset: 0
 
 [appendix]
 Configuration Files
@@ -301,6 +310,15 @@ include::datacenter.cfg.adoc[]
 
 :leveloffset: 0
 
+[appendix]
+Calendar Events
+---------------
+
+:leveloffset: 1
+include::calendar-events.adoc[]
+
+:leveloffset: 0
+
 [appendix]
 Firewall Macro Definitions
 --------------------------
diff --git a/pvescheduler.adoc b/pvescheduler.adoc
new file mode 100644
index 0000000..1d78ed4
--- /dev/null
+++ b/pvescheduler.adoc
@@ -0,0 +1,33 @@
+ifdef::manvolnum[]
+pvescheduler(8)
+===============
+:pve-toplevel:
+
+NAME
+----
+
+pvescheduler - PVE Scheduler Daemon
+
+
+SYNOPSIS
+--------
+
+include::pvescheduler.8-synopsis.adoc[]
+
+DESCRIPTION
+-----------
+endif::manvolnum[]
+
+ifndef::manvolnum[]
+pvescheduler - Proxmox VE Scheduler Daemon
+==========================================
+endif::manvolnum[]
+
+This deamon is responsible for starting jobs according to the schedule,
+such as replication and vzdump jobs.
+
+For vzdump jobs, it gets its configuration from the file `/etc/pve/jobs.cfg`
+
+ifdef::manvolnum[]
+include::pve-copyright.adoc[]
+endif::manvolnum[]
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager 1/5] ui: dc/Backup: never show id input field, autogenerate id
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (2 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 3/3] add pvescheduler docs and manpage Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 2/5] ui: dc/Backup: fix comment sort Dominik Csapak
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

similar to pbs sync jobs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/Backup.js | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index e33f5e27..3f250a76 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -176,24 +176,6 @@ Ext.define('PVE.dc.BackupEdit', {
 	});
 
 	let column1 = [
-	    {
-		xtype: 'pmxDisplayEditField',
-		name: 'id',
-		fieldLabel: gettext('ID'),
-		renderer: Ext.htmlEncode,
-		fieldStyle: me.isCreate ? {} : {
-		    'text-overflow': 'ellipsis',
-		    'overflow': 'hidden',
-		    'white-space': 'nowrap',
-		},
-		editConfig: {
-		    maxLength: 20, // easier to allow more than less in the future..
-		    enforceMaxLength: true,
-		},
-		vtype: 'ConfigId',
-		allowBlank: false,
-		editable: me.isCreate,
-	    },
 	    nodesel,
 	    storagesel,
 	    {
@@ -263,6 +245,10 @@ Ext.define('PVE.dc.BackupEdit', {
 		    delete values.node;
 		}
 
+		if (!values.id && me.isCreate) {
+		    values.id = 'backup-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 13);
+		}
+
 		let selMode = values.selMode;
 		delete values.selMode;
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager 2/5] ui: dc/Backup: fix comment sort
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (3 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 1/5] ui: dc/Backup: never show id input field, autogenerate id Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 3/5] api: cluster: add jobs/schedule-analyze api call Dominik Csapak
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

without this, jobs without comments will not be included in the sort
properly

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/Backup.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index 3f250a76..c25a127e 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -749,6 +749,7 @@ Ext.define('PVE.dc.BackupView', {
 		    header: gettext('Comment'),
 		    dataIndex: 'comment',
 		    renderer: Ext.htmlEncode,
+		    sorter: (a, b) => (a.data.comment || '').localeCompare(b.data.comment || ''),
 		    flex: 1,
 		},
 		{
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager 3/5] api: cluster: add jobs/schedule-analyze api call
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (4 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 2/5] ui: dc/Backup: fix comment sort Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button Dominik Csapak
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

a simple api call to simulate calendar event triggers
takes a schedule, an optional number (default 10), an optional starttime
(default 'now') and returns a list with unix timestamps, as well as
humanly readable utc timestamps.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2/Cluster.pm       |   5 ++
 PVE/API2/Cluster/Jobs.pm  | 107 ++++++++++++++++++++++++++++++++++++++
 PVE/API2/Cluster/Makefile |   1 +
 3 files changed, 113 insertions(+)
 create mode 100644 PVE/API2/Cluster/Jobs.pm

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 3b918e55..205f9883 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -25,6 +25,7 @@ use PVE::API2::ACMEPlugin;
 use PVE::API2::Backup;
 use PVE::API2::Cluster::BackupInfo;
 use PVE::API2::Cluster::Ceph;
+use PVE::API2::Cluster::Jobs;
 use PVE::API2::Cluster::MetricServer;
 use PVE::API2::ClusterConfig;
 use PVE::API2::Firewall::Cluster;
@@ -84,6 +85,10 @@ __PACKAGE__->register_method ({
     path => 'ceph',
 });
 
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Cluster::Jobs",
+    path => 'jobs',
+});
 if ($have_sdn) {
     __PACKAGE__->register_method ({
        subclass => "PVE::API2::Network::SDN",
diff --git a/PVE/API2/Cluster/Jobs.pm b/PVE/API2/Cluster/Jobs.pm
new file mode 100644
index 00000000..79a6e85e
--- /dev/null
+++ b/PVE/API2/Cluster/Jobs.pm
@@ -0,0 +1,107 @@
+package PVE::API2::Cluster::Jobs;
+
+use strict;
+use warnings;
+
+use PVE::RESTHandler;
+use PVE::CalendarEvent;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    description => "Index for jobs related endpoints.",
+    parameters => {
+	additionalProperties => 0,
+	properties => {},
+    },
+    returns => {
+	type => 'array',
+	description => 'Directory index.',
+	items => {
+	    type => "object",
+	    properties => {
+		subdir => {
+		    type => 'string',
+		    description => 'API sub-directory endpoint',
+		},
+	    },
+	},
+	links => [ { rel => 'child', href => "{subdir}" } ],
+    },
+    code => sub {
+	return [
+	   { subdir => 'schedule-analyze' },
+	];
+    }});
+
+__PACKAGE__->register_method({
+    name => 'schedule-analyze',
+    path => 'schedule-analyze',
+    method => 'GET',
+    description => "Returns a list of future schedule runtimes.",
+    permissions => { user => 'all' },
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    schedule => {
+		description => "Backup schedule. The format is a subset of `systemd` calendar events.",
+		type => 'string', format => 'pve-calendar-event',
+		maxLength => 128,
+	    },
+	    starttime => {
+		description => "UNIX timestamp to start the calculation from. Defaults to the current time.",
+		optional => 1,
+		type => 'integer',
+	    },
+	    number => {
+		description => "Number of timestamps to return.",
+		optional => 1,
+		type => 'integer',
+		minimum => 1,
+		maximum => 100,
+		default => 10,
+	    },
+	},
+    },
+    returns => {
+	type => 'array',
+	description => 'Contains the guest objects.',
+	items => {
+	    type => 'object',
+	    properties => {
+		timestamp => {
+		    type => 'integer',
+		    description => 'UNIX timestamp for the run.',
+		},
+		utc => {
+		    type => 'string',
+		    description => "UTC timestamp for the run.",
+		},
+	    },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $starttime = $param->{starttime} // time();
+	my $number = $param->{number} // 10;
+	my $schedule = $param->{schedule};
+
+	my $result = [];
+
+	my $event = PVE::CalendarEvent::parse_calendar_event($schedule);
+
+	for (my $count = 0; $count < $number; $count++) {
+	    my $next = PVE::CalendarEvent::compute_next_event($event, $starttime);
+	    push @$result, {
+		timestamp => $next,
+		utc => scalar(gmtime($next)),
+	    };
+	    $starttime = $next;
+	}
+
+	return $result;
+    }});
diff --git a/PVE/API2/Cluster/Makefile b/PVE/API2/Cluster/Makefile
index 742a1007..8d306507 100644
--- a/PVE/API2/Cluster/Makefile
+++ b/PVE/API2/Cluster/Makefile
@@ -5,6 +5,7 @@ include ../../../defines.mk
 PERLSOURCE= 			\
 	BackupInfo.pm		\
 	MetricServer.pm		\
+	Jobs.pm			\
 	Ceph.pm
 
 all:
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (5 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 3/5] api: cluster: add jobs/schedule-analyze api call Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 5/5] remove pvescheduler manpage generation Dominik Csapak
  2021-11-11 20:04 ` [pve-devel] applied-series: [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Thomas Lamprecht
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

so that a user can simply simulate the schedule

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/Makefile                    |   1 +
 www/manager6/dc/Backup.js                |  15 +++
 www/manager6/window/ScheduleSimulator.js | 118 +++++++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 www/manager6/window/ScheduleSimulator.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 489233f8..a92651a9 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -111,6 +111,7 @@ JSSRC= 							\
 	window/StartupEdit.js				\
 	window/DownloadUrlToStorage.js 			\
 	window/UploadToStorage.js 			\
+	window/ScheduleSimulator.js			\
 	window/Wizard.js				\
 	ha/Fencing.js					\
 	ha/GroupEdit.js					\
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index c25a127e..31600817 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -701,6 +701,21 @@ Ext.define('PVE.dc.BackupView', {
 		edit_btn,
 		detail_btn,
 		'-',
+		{
+		    xtype: 'proxmoxButton',
+		    selModel: null,
+		    text: gettext('Simulate Schedule'),
+		    handler: () => {
+			let record = sm.getSelection()[0];
+			let schedule;
+			if (record) {
+			    schedule = record.data.schedule;
+			}
+			Ext.create('PVE.window.ScheduleSimulator', {
+			    schedule,
+			}).show();
+		    },
+		},
 		run_btn,
 		'->',
 		noBackupJobWarning,
diff --git a/www/manager6/window/ScheduleSimulator.js b/www/manager6/window/ScheduleSimulator.js
new file mode 100644
index 00000000..14b32100
--- /dev/null
+++ b/www/manager6/window/ScheduleSimulator.js
@@ -0,0 +1,118 @@
+Ext.define('PVE.window.ScheduleSimulator', {
+    extend: 'Ext.window.Window',
+
+    title: gettext('Simulate Schedule'),
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+	close: function() { this.getView().close(); },
+	simulate: function() {
+	    let me = this;
+	    let schedule = me.lookup('schedule').getValue();
+	    if (!schedule) {
+		return;
+	    }
+	    let number = me.lookup('number').getValue() || 10;
+	    Proxmox.Utils.API2Request({
+		url: '/cluster/jobs/schedule-analyze',
+		method: 'GET',
+		params: {
+		    schedule,
+		    number,
+		},
+		failure: function(response, opts) {
+		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+		},
+		success: function(response) {
+		    let schedules = response.result.data;
+		    me.lookup('grid').getStore().setData(schedules);
+		},
+	    });
+	},
+
+	scheduleChanged: function(field, value) {
+	    this.lookup('simulateBtn').setDisabled(!value);
+	},
+
+	renderTimestamp: function(value) {
+	    let date = new Date(value*1000);
+	    return date.toLocaleString();
+	},
+
+	init: function(view) {
+	    let me = this;
+	    if (view.schedule) {
+		me.lookup('schedule').setValue(view.schedule);
+	    }
+	},
+    },
+
+    bodyPadding: 10,
+    modal: true,
+    resizable: false,
+    width: 600,
+
+    layout: 'fit',
+
+    items: [
+	{
+	    xtype: 'inputpanel',
+	    column1: [
+		{
+		    xtype: 'pveCalendarEvent',
+		    reference: 'schedule',
+		    fieldLabel: gettext('Schedule'),
+		    listeners: {
+			change: 'scheduleChanged',
+		    },
+		},
+		{
+		    xtype: 'proxmoxintegerfield',
+		    minValue: 1,
+		    maxValue: 100,
+		    value: 10,
+		    reference: 'number',
+		    fieldLabel: gettext('Number'),
+		},
+		{
+		    xtype: 'button',
+		    reference: 'simulateBtn',
+		    text: gettext('Simulate'),
+		    handler: 'simulate',
+		    align: 'right',
+		    disabled: true,
+		},
+	    ],
+
+	    column2: [
+		{
+		    xtype: 'grid',
+		    reference: 'grid',
+		    emptyText: Proxmox.Utils.NoneText,
+		    scrollable: true,
+		    height: 300,
+		    columns: [
+			{
+			    text: gettext('Local Time'),
+			    renderer: 'renderTimestamp',
+			    dataIndex: 'timestamp',
+			    flex: 1,
+			},
+		    ],
+		    store: {
+			fields: ['timestamp'],
+			data: [],
+			sorter: 'timestamp',
+		    },
+		},
+	    ],
+	},
+    ],
+
+    buttons: [
+	{
+	    text: gettext('OK'),
+	    handler: 'close',
+	},
+    ],
+});
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager 5/5] remove pvescheduler manpage generation
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (6 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button Dominik Csapak
@ 2021-11-11 11:07 ` Dominik Csapak
  2021-11-11 20:04 ` [pve-devel] applied-series: [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Thomas Lamprecht
  8 siblings, 0 replies; 11+ messages in thread
From: Dominik Csapak @ 2021-11-11 11:07 UTC (permalink / raw)
  To: pve-devel

pve-docs-generator does this now

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 bin/Makefile | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/bin/Makefile b/bin/Makefile
index 12cb4671..fb475be3 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -52,10 +52,6 @@ pve6to7.1:
 	printf ".TH PVE6TO7 1\n.SH NAME\npve6to7 \- Proxmox VE upgrade checker script for 6.4 to 7.x\n" > $@
 	printf ".SH SYNOPSIS\npve6to7 [--full]\n" >> $@
 
-pvescheduler.8:
-	# FIXME: add to doc-generator
-	echo ".TH pvescheduler 8" > $@
-
 pveversion.1.pod: pveversion
 pveupgrade.1.pod: pveupgrade
 pvereport.1.pod: pvereport
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] applied-series: [PATCH docs 1/3] refactor calendar events into appendix
  2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
@ 2021-11-11 17:03   ` Thomas Lamprecht
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Lamprecht @ 2021-11-11 17:03 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 11.11.21 12:07, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  calendar-events.adoc | 73 ++++++++++++++++++++++++++++++++++++++++++++
>  pvesr.adoc           | 72 ++-----------------------------------------
>  2 files changed, 75 insertions(+), 70 deletions(-)
>  create mode 100644 calendar-events.adoc
> 
>

applied the docs one for now, thanks!




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] applied-series: [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui
  2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
                   ` (7 preceding siblings ...)
  2021-11-11 11:07 ` [pve-devel] [PATCH manager 5/5] remove pvescheduler manpage generation Dominik Csapak
@ 2021-11-11 20:04 ` Thomas Lamprecht
  8 siblings, 0 replies; 11+ messages in thread
From: Thomas Lamprecht @ 2021-11-11 20:04 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 11.11.21 12:07, Dominik Csapak wrote:
> pve-manager:
> 
> Dominik Csapak (5):
>   ui: dc/Backup: never show id input field, autogenerate id
>   ui: dc/Backup: fix comment sort
>   api: cluster: add jobs/schedule-analyze api call
>   ui: dc/Backup: add schedule simulator button
>   remove pvescheduler manpage generation
> 
>  PVE/API2/Cluster.pm                      |   5 +
>  PVE/API2/Cluster/Jobs.pm                 | 107 ++++++++++++++++++++
>  PVE/API2/Cluster/Makefile                |   1 +
>  bin/Makefile                             |   4 -
>  www/manager6/Makefile                    |   1 +
>  www/manager6/dc/Backup.js                |  38 ++++----
>  www/manager6/window/ScheduleSimulator.js | 118 +++++++++++++++++++++++
>  7 files changed, 252 insertions(+), 22 deletions(-)
>  create mode 100644 PVE/API2/Cluster/Jobs.pm
>  create mode 100644 www/manager6/window/ScheduleSimulator.js
> 

applied manager patches now too, thanks! Did a few small (possibly opinionated) followups though:

35fbf427 ui: backup view: move tbar schedule-sim button to the right
11d87ab9 ui: schedule sim: slight title adaption
9e910727 ui: schedule sim: fix right alignment of simulate button
d7f85501 api: cluster: add jobs sub-directory index and set its permissions
167e8817 api: cluster: sort index
1b1476e2 calendar event simulator: rename number parameter to iterations

please holler at me if something is off, thx!




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-11-11 20:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 11:07 [pve-devel] [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH docs 1/3] refactor calendar events into appendix Dominik Csapak
2021-11-11 17:03   ` [pve-devel] applied-series: " Thomas Lamprecht
2021-11-11 11:07 ` [pve-devel] [PATCH docs 2/3] vzdump: change vzdump.cron to pvescheduler Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH docs 3/3] add pvescheduler docs and manpage Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 1/5] ui: dc/Backup: never show id input field, autogenerate id Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 2/5] ui: dc/Backup: fix comment sort Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 3/5] api: cluster: add jobs/schedule-analyze api call Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 4/5] ui: dc/Backup: add schedule simulator button Dominik Csapak
2021-11-11 11:07 ` [pve-devel] [PATCH manager 5/5] remove pvescheduler manpage generation Dominik Csapak
2021-11-11 20:04 ` [pve-devel] applied-series: [PATCH docs/manager] add pvescheduler docs, improve vzdump job gui Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal