]>
git.proxmox.com Git - pve-manager.git/blob - PVE/API2/Cluster/Jobs.pm
8166333dcf5ea395b6bec16a33577d2cb8c082a3
1 package PVE
::API2
::Cluster
::Jobs
;
7 use PVE
::CalendarEvent
;
9 use base
qw(PVE::RESTHandler);
11 __PACKAGE__-
>register_method({
15 description
=> "Index for jobs related endpoints.",
16 permissions
=> { user
=> 'all' },
18 additionalProperties
=> 0,
23 description
=> 'Directory index.',
29 description
=> 'API sub-directory endpoint',
33 links
=> [ { rel
=> 'child', href
=> "{subdir}" } ],
37 { subdir
=> 'schedule-analyze' },
41 __PACKAGE__-
>register_method({
42 name
=> 'schedule-analyze',
43 path
=> 'schedule-analyze',
45 description
=> "Returns a list of future schedule runtimes.",
46 permissions
=> { user
=> 'all' },
48 additionalProperties
=> 0,
51 description
=> "Job schedule. The format is a subset of `systemd` calendar events.",
52 type
=> 'string', format
=> 'pve-calendar-event',
56 description
=> "UNIX timestamp to start the calculation from. Defaults to the current time.",
61 description
=> "Number of event-iteration to simulate and return.",
72 description
=> 'An array of the next <iterations> events since <starttime>.',
78 description
=> 'UNIX timestamp for the run.',
82 description
=> "UTC timestamp for the run.",
90 my $starttime = $param->{starttime
} // time();
91 my $iterations = $param->{iterations
} // 10;
92 my $schedule = $param->{schedule
};
96 my $event = PVE
::CalendarEvent
::parse_calendar_event
($schedule);
98 for (my $count = 0; $count < $iterations; $count++) {
99 my $next = PVE
::CalendarEvent
::compute_next_event
($event, $starttime);
100 last if !defined($next);
103 utc
=> scalar(gmtime($next)),