]>
git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/HA/Resources.pm
1 package PVE
::HA
::Resources
;
6 use PVE
::JSONSchema
qw(get_standard_option);
7 use PVE
::SectionConfig
;
10 use base
qw(PVE::SectionConfig);
14 type
=> { description
=> "Resource type.", optional
=> 1 },
15 sid
=> get_standard_option
('pve-ha-resource-or-vm-id',
16 { completion
=> \
&PVE
::HA
::Tools
::complete_sid
}),
19 enum
=> ['started', 'stopped', 'enabled', 'disabled'],
22 description
=> "Requested resource state.",
23 verbose_description
=> <<EODESC,
24 Requested resource state. The CRM reads this state and acts accordingly.
25 Please note that `enabled` is just an alias for `started`.
29 The CRM tries to start the resource. Service state is
30 set to `started` after successful start. On node failures, or when start
31 fails, it tries to recover the resource. If everything fails, service
32 state it set to `error`.
36 The CRM tries to keep the resource in `stopped` state, but it
37 still tries to relocate the resources on node failures.
41 The CRM tries to put the resource in `stopped` state, but does not try
42 to relocate the resources on node failures. The main purpose of this
43 state is error recovery, because it is the only way to move a resource out
48 group
=> get_standard_option
('pve-ha-group-id',
50 completion
=> \
&PVE
::HA
::Tools
::complete_group
}),
52 description
=> "Maximal number of tries to restart the service on".
53 " a node after its start failed.",
60 description
=> "Maximal number of service relocate tries when a".
61 " service failes to start.",
68 description
=> "Description.",
77 my ($class, $name) = @_;
79 die "implement this in subclass";
86 sub format_section_header
{
87 my ($class, $type, $sectionId) = @_;
89 my (undef, $name) = split(':', $sectionId, 2);
91 return "$type: $name\n";
94 sub parse_section_header
{
95 my ($class, $line) = @_;
97 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
98 my ($type, $name) = (lc($1), $2);
99 my $errmsg = undef; # set if you want to skip whole section
101 if (my $plugin = $defaultData->{plugins
}->{$type}) {
102 $plugin->verify_name($name);
104 die "no such resource type '$type'\n";
108 my $config = {}; # to return additional attributes
109 return ($type, "$type:$name", $errmsg, $config);
115 my ($class, $haenv, $id) = @_;
117 die "implement in subclass";
121 my ($class, $haenv, $id) = @_;
123 die "implement in subclass";
127 my ($class, $haenv, $id, $target, $online) = @_;
129 die "implement in subclass";
133 my ($class, $id, $nodename) = @_;
135 die "implement in subclass"
139 my ($class, $id, $noerr) = @_;
141 die "implement in subclass"
145 my ($class, $haenv, $id) = @_;
147 die "implement in subclass";
151 my ($self, $haenv, $id, $locks, $service_node) = @_;
153 die "implement in subclass";
157 # package PVE::HA::Resources::IPAddr;
161 # use PVE::Tools qw($IPV4RE $IPV6RE);
163 # use base qw(PVE::HA::Resources);
170 # my ($class, $name) = @_;
172 # die "invalid IP address\n" if $name !~ m!^$IPV6RE|$IPV4RE$!;
177 # state => { optional => 1 },
178 # group => { optional => 1 },
179 # comment => { optional => 1 },