]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/PVE/HA/Resources.pm
cleanup backup & mounted locks after recovery (fixes #1100)
[pve-ha-manager.git] / src / PVE / HA / Resources.pm
index b0c396321bc015071ac0753132418caf2c3e79d3..96d2f8fe95faa9c66b50be3748ebb6237261c1b3 100644 (file)
@@ -13,7 +13,8 @@ use base qw(PVE::SectionConfig);
 my $defaultData = {
     propertyList => {
        type => { description => "Resource type.", optional => 1 },
-       sid => get_standard_option('pve-ha-resource-id'),
+       sid => get_standard_option('pve-ha-resource-or-vm-id',
+                                  { completion => \&PVE::HA::Tools::complete_sid }),
        state => {
            description => "Resource state.",
            type => 'string',
@@ -21,7 +22,25 @@ my $defaultData = {
            optional => 1,
            default => 'enabled',
        },
-       group => get_standard_option('pve-ha-group-id', { optional => 1 }),
+       group => get_standard_option('pve-ha-group-id',
+                                   { optional => 1,
+                                     completion => \&PVE::HA::Tools::complete_group }),
+       max_restart => {
+           description => "Maximal number of tries to restart the service on".
+                         " a node after its start failed.",
+           type => 'integer',
+           optional => 1,
+           default => 1,
+           minimum => 0,
+       },
+       max_relocate => {
+           description => "Maximal number of service relocate tries when a".
+                         " service failes to start.",
+           type => 'integer',
+           optional => 1,
+           default => 1,
+           minimum => 0,
+       },
        comment => {
            description => "Description.",
            type => 'string',
@@ -58,6 +77,8 @@ sub parse_section_header {
        eval {
            if (my $plugin = $defaultData->{plugins}->{$type}) {
                $plugin->verify_name($name);
+           } else {
+               die "no such resource type '$type'\n";
            }
        };
        $errmsg = $@ if $@;
@@ -67,55 +88,73 @@ sub parse_section_header {
     return undef;
 }
 
-package PVE::HA::Resources::PVEVM;
+sub start {
+    my ($class, $haenv, $id) = @_;
 
-use strict;
-use warnings;
+    die "implement in subclass";
+}
 
-use base qw(PVE::HA::Resources);
+sub shutdown {
+    my ($class, $haenv, $id) = @_;
 
-sub type {
-    return 'vm';
+    die "implement in subclass";
 }
 
-sub verify_name {
-    my ($class, $name) = @_;
+sub migrate {
+    my ($class, $haenv, $id, $target, $online) = @_;
 
-    die "invalid VMID\n" if $name !~ m/^[1-9][0-9]+$/;
+    die "implement in subclass";
 }
 
-sub options {
-    return {
-       state => { optional => 1 },
-       group => { optional => 1 },
-       comment => { optional => 1 },
-    };
+sub config_file {
+    my ($class, $id, $nodename) = @_;
+
+    die "implement in subclass"
 }
 
-package PVE::HA::Resources::IPAddr;
+sub exists {
+    my ($class, $id, $noerr) = @_;
 
-use strict;
-use warnings;
-use PVE::Tools qw($IPV4RE $IPV6RE);
+    die "implement in subclass"
+}
 
-use base qw(PVE::HA::Resources);
+sub check_running {
+    my ($class, $haenv, $id) = @_;
 
-sub type {
-    return 'ipaddr';
+    die "implement in subclass";
 }
 
-sub verify_name {
-    my ($class, $name) = @_;
+sub remove_locks {
+    my ($self, $haenv, $id, $locks, $service_node) = @_;
 
-    die "invalid IP address\n" if $name !~ m!^$IPV6RE|$IPV4RE$!;
+    die "implement in subclass";
 }
 
-sub options {
-    return {
-       state => { optional => 1 },
-       group => { optional => 1 },
-       comment => { optional => 1 },
-    };
-}
+
+# package PVE::HA::Resources::IPAddr;
+
+# use strict;
+# use warnings;
+# use PVE::Tools qw($IPV4RE $IPV6RE);
+
+# use base qw(PVE::HA::Resources);
+
+# sub type {
+#     return 'ipaddr';
+# }
+
+# sub verify_name {
+#     my ($class, $name) = @_;
+
+#     die "invalid IP address\n" if $name !~ m!^$IPV6RE|$IPV4RE$!;
+# }
+
+# sub options {
+#     return {
+#      state => { optional => 1 },
+#      group => { optional => 1 },
+#      comment => { optional => 1 },
+#     };
+# }
 
 1;