]>
git.proxmox.com Git - pve-common.git/blob - src/PVE/Job/Registry.pm
1 package PVE
::Job
::Registry
;
6 # The job (config) base class, normally you would use this in one of two variants:
8 # 1) base of directly in manager and handle everything there; great for stuff that isn't residing
9 # outside of the manager, so that there is no cyclic dependency (forbidden!) required
11 # 2) use two (or even more) classes, one in the library (e.g., guest-common, access-control, ...)
12 # basing off this module, providing the basic config implementation. Then one in pve-manager
13 # (where every dependency is available) basing off the intermediate config one, that then holds
14 # the implementation of the 'run` method and is used in the job manager
16 use base
qw(PVE::SectionConfig);
20 type
=> { description
=> "Section type." },
22 description
=> "The ID of the job.",
24 format
=> 'pve-configid',
28 description
=> "Determines if the job is enabled.",
34 description
=> "Backup schedule. The format is a subset of `systemd` calendar events.",
35 type
=> 'string', format
=> 'pve-calendar-event',
41 description
=> "Description for the Job.",
47 description
=> "If true, the job will be run as soon as possible if it was missed".
48 " while the scheduler was not running.",
59 my ($class, $cfg, $id) = @_;
66 my ($class, $filename, $raw, $allow_unknown) = @_;
68 my $cfg = $class->SUPER::parse_config
($filename, $raw, $allow_unknown);
70 foreach my $id (sort keys %{$cfg->{ids
}}) {
71 my $data = $cfg->{ids
}->{$id};
74 $data->{enabled
} //= 1;
76 $data->{comment
} = PVE
::Tools
::decode_text
($data->{comment
}) if defined($data->{comment
});
82 # call the plugin specific decode/encode code
84 my ($class, $type, $key, $value) = @_;
86 my $plugin = __PACKAGE__-
>lookup($type);
87 return $plugin->decode_value($type, $key, $value);
91 my ($class, $type, $key, $value) = @_;
93 my $plugin = __PACKAGE__-
>lookup($type);
94 return $plugin->encode_value($type, $key, $value);
98 my ($class, $filename, $cfg, $allow_unknown) = @_;
100 for my $job (values $cfg->{ids
}->%*) {
101 $job->{comment
} = PVE
::Tools
::encode_text
($job->{comment
}) if defined($job->{comment
});
104 $class->SUPER::write_config
($filename, $cfg, $allow_unknown);
108 my ($class, $cfg) = @_;
110 die "not implemented"; # implement in subclass