]>
git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/HA/Resources.pm
1 package PVE
::HA
::Resources
;
7 use PVE
::JSONSchema
qw(get_standard_option);
8 use PVE
::SectionConfig
;
11 use base
qw(PVE::SectionConfig);
15 type
=> { description
=> "Resource type.", optional
=> 1 },
16 sid
=> get_standard_option
('pve-ha-resource-or-vm-id',
17 { completion
=> \
&PVE
::HA
::Tools
::complete_sid
}),
19 description
=> "Resource state.",
21 enum
=> ['enabled', 'disabled'],
25 group
=> get_standard_option
('pve-ha-group-id',
27 completion
=> \
&PVE
::HA
::Tools
::complete_group
}),
29 description
=> "Maximal number of tries to restart the service on".
30 " a node after its start failed.",
37 description
=> "Maximal number of service relocate tries when a".
38 " service failes to start.",
45 description
=> "Description.",
54 my ($class, $name) = @_;
56 die "implement this in subclass";
63 sub format_section_header
{
64 my ($class, $type, $sectionId) = @_;
66 my (undef, $name) = split(':', $sectionId, 2);
68 return "$type: $name\n";
71 sub parse_section_header
{
72 my ($class, $line) = @_;
74 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
75 my ($type, $name) = (lc($1), $2);
76 my $errmsg = undef; # set if you want to skip whole section
78 if (my $plugin = $defaultData->{plugins
}->{$type}) {
79 $plugin->verify_name($name);
81 die "no such resource type '$type'\n";
85 my $config = {}; # to return additional attributes
86 return ($type, "$type:$name", $errmsg, $config);
92 my ($class, $haenv, $id) = @_;
94 die "implement in subclass";
98 my ($class, $haenv, $id) = @_;
100 die "implement in subclass";
104 my ($class, $haenv, $id, $target, $online) = @_;
106 die "implement in subclass";
110 my ($class, $id, $nodename) = @_;
112 die "implement in subclass"
116 my ($class, $id, $noerr) = @_;
118 die "implement in subclass"
122 my ($class, $haenv, $id) = @_;
124 die "implement in subclass";
128 my ($self, $haenv, $id, $locks, $service_node) = @_;
130 die "implement in subclass";
134 # package PVE::HA::Resources::IPAddr;
138 # use PVE::Tools qw($IPV4RE $IPV6RE);
140 # use base qw(PVE::HA::Resources);
147 # my ($class, $name) = @_;
149 # die "invalid IP address\n" if $name !~ m!^$IPV6RE|$IPV4RE$!;
154 # state => { optional => 1 },
155 # group => { optional => 1 },
156 # comment => { optional => 1 },