]>
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', 'ignored'],
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 The resource gets removed from the manager status and so the CRM and the LRM do
49 not touch the resource anymore. All {pve} API calls affecting this resource
50 will be executed, directly bypassing the HA stack. CRM commands will be thrown
51 away while there source is in this state. The resource will not get relocated
56 group
=> get_standard_option
('pve-ha-group-id',
58 completion
=> \
&PVE
::HA
::Tools
::complete_group
}),
60 description
=> "Maximal number of tries to restart the service on".
61 " a node after its start failed.",
68 description
=> "Maximal number of service relocate tries when a".
69 " service failes to start.",
76 description
=> "Description.",
85 my ($class, $name) = @_;
87 die "implement this in subclass";
94 sub format_section_header
{
95 my ($class, $type, $sectionId) = @_;
97 my (undef, $name) = split(':', $sectionId, 2);
99 return "$type: $name\n";
102 sub parse_section_header
{
103 my ($class, $line) = @_;
105 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
106 my ($type, $name) = (lc($1), $2);
107 my $errmsg = undef; # set if you want to skip whole section
109 if (my $plugin = $defaultData->{plugins
}->{$type}) {
110 $plugin->verify_name($name);
112 die "no such resource type '$type'\n";
116 my $config = {}; # to return additional attributes
117 return ($type, "$type:$name", $errmsg, $config);
123 my ($class, $haenv, $id) = @_;
125 die "implement in subclass";
129 my ($class, $haenv, $id) = @_;
131 die "implement in subclass";
135 my ($class, $haenv, $id, $target, $online) = @_;
137 die "implement in subclass";
141 my ($class, $id, $nodename) = @_;
143 die "implement in subclass"
147 my ($class, $id, $noerr) = @_;
149 die "implement in subclass"
153 my ($class, $haenv, $id) = @_;
155 die "implement in subclass";
159 my ($self, $haenv, $id, $locks, $service_node) = @_;
161 die "implement in subclass";
165 # package PVE::HA::Resources::IPAddr;
169 # use PVE::Tools qw($IPV4RE $IPV6RE);
171 # use base qw(PVE::HA::Resources);
178 # my ($class, $name) = @_;
180 # die "invalid IP address\n" if $name !~ m!^$IPV6RE|$IPV4RE$!;
185 # state => { optional => 1 },
186 # group => { optional => 1 },
187 # comment => { optional => 1 },