mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-13 19:34:21 +00:00
use starttime hh:mm instead of hour and minute
This commit is contained in:
parent
8f630c2984
commit
7625ea19ee
@ -59,7 +59,7 @@ sub parse_dow {
|
|||||||
|
|
||||||
$dowstr = '1,2,3,4,5,6,7' if $dowstr eq '*';
|
$dowstr = '1,2,3,4,5,6,7' if $dowstr eq '*';
|
||||||
|
|
||||||
foreach my $day (split (/,/, $dowstr)) {
|
foreach my $day (PVE::Tools::split_list($dowstr)) {
|
||||||
if ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun)-(mon|tue|wed|thu|fri|sat|sun)$/i) {
|
if ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun)-(mon|tue|wed|thu|fri|sat|sun)$/i) {
|
||||||
for (my $i = $dowmap->{lc($1)}; $i <= $dowmap->{lc($2)}; $i++) {
|
for (my $i = $dowmap->{lc($1)}; $i <= $dowmap->{lc($2)}; $i++) {
|
||||||
my $r = $rdowmap->{$i};
|
my $r = $rdowmap->{$i};
|
||||||
@ -115,8 +115,7 @@ sub parse_vzdump_cron_config {
|
|||||||
|
|
||||||
$opts->{id} = "$digest:$jid";
|
$opts->{id} = "$digest:$jid";
|
||||||
$jid++;
|
$jid++;
|
||||||
$opts->{hour} = $hour;
|
$opts->{starttime} = sprintf "%02d:%02d", $hour, $minute;
|
||||||
$opts->{minute} = $minute;
|
|
||||||
$opts->{dow} = &$dowhash_to_dow($dowhash);
|
$opts->{dow} = &$dowhash_to_dow($dowhash);
|
||||||
|
|
||||||
push @$jobs, $opts;
|
push @$jobs, $opts;
|
||||||
@ -161,17 +160,27 @@ sub write_vzdump_cron_config {
|
|||||||
$dow = '*' if !$dow;
|
$dow = '*' if !$dow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my ($hour, $minute);
|
||||||
|
|
||||||
|
die "no job start time specified\n" if !$job->{starttime};
|
||||||
|
if ($job->{starttime} =~ m/^(\d{1,2}):(\d{1,2})$/) {
|
||||||
|
($hour, $minute) = (int($1), int($2));
|
||||||
|
die "hour '$hour' out of range\n" if $hour < 0 || $hour > 23;
|
||||||
|
die "minute '$minute' out of range\n" if $minute < 0 || $minute > 59;
|
||||||
|
} else {
|
||||||
|
die "unable to parse job start time\n";
|
||||||
|
}
|
||||||
|
|
||||||
my $param = "";
|
my $param = "";
|
||||||
foreach my $p (keys %$job) {
|
foreach my $p (keys %$job) {
|
||||||
next if $p eq 'id' || $p eq 'vmid' || $p eq 'hour' ||
|
next if $p eq 'id' || $p eq 'vmid' || $p eq 'starttime' || $p eq 'dow';
|
||||||
$p eq 'minute' || $p eq 'dow';
|
|
||||||
my $v = $job->{$p};
|
my $v = $job->{$p};
|
||||||
$param .= " --$p " . PVE::Tools::shellquote($v) if defined($v) && $v ne '';
|
$param .= " --$p " . PVE::Tools::shellquote($v) if defined($v) && $v ne '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$param .= " $job->{vmid}" if $job->{vmid};
|
$param .= " $job->{vmid}" if $job->{vmid};
|
||||||
|
|
||||||
$out .= sprintf "$job->{minute} $job->{hour} * * %-11s root vzdump$param\n", $dow;
|
$out .= sprintf "$minute $hour * * %-11s root vzdump$param\n", $dow;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ejobs = $cfg->{ejobs} || [];
|
my $ejobs = $cfg->{ejobs} || [];
|
||||||
@ -223,19 +232,11 @@ __PACKAGE__->register_method({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => PVE::VZDump::json_config_properties({
|
properties => PVE::VZDump::json_config_properties({
|
||||||
hour => {
|
starttime => {
|
||||||
type => 'integer',
|
type => 'string',
|
||||||
description => "Start time (hour).",
|
description => "Job Start time.",
|
||||||
minimum => 0,
|
pattern => '\d{1,2}:\d{1,2}',
|
||||||
maximum => 23,
|
typetext => 'HH:MM',
|
||||||
},
|
|
||||||
minute => {
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
description => "Start time (minute).",
|
|
||||||
minimum => 0,
|
|
||||||
maximum => 59,
|
|
||||||
default => 0,
|
|
||||||
},
|
},
|
||||||
dow => {
|
dow => {
|
||||||
type => 'string', format => 'pve-day-of-week-list',
|
type => 'string', format => 'pve-day-of-week-list',
|
||||||
@ -367,19 +368,11 @@ __PACKAGE__->register_method({
|
|||||||
description => "The job ID.",
|
description => "The job ID.",
|
||||||
maxLength => 50,
|
maxLength => 50,
|
||||||
},
|
},
|
||||||
hour => {
|
starttime => {
|
||||||
type => 'integer',
|
type => 'string',
|
||||||
optional => 1,
|
description => "Job Start time.",
|
||||||
description => "Start time (hour).",
|
pattern => '\d{1,2}:\d{1,2}',
|
||||||
minimum => 0,
|
typetext => 'HH:MM',
|
||||||
maximum => 23,
|
|
||||||
},
|
|
||||||
minute => {
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
description => "Start time (minute).",
|
|
||||||
minimum => 0,
|
|
||||||
maximum => 59,
|
|
||||||
},
|
},
|
||||||
dow => {
|
dow => {
|
||||||
type => 'string', format => 'pve-day-of-week-list',
|
type => 'string', format => 'pve-day-of-week-list',
|
||||||
|
Loading…
Reference in New Issue
Block a user