]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
Adding constants to gain more readability
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 23 Oct 2015 12:04:23 +0000 (14:04 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 29 Oct 2015 06:50:43 +0000 (07:50 +0100)
Add constants to make some code easier to understand, especially the
execution of resource agents and their return codes.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/HA/Tools.pm

index fb522e93d7de1113cb9c68b8c679ab6f700eb018..a04fd2ea4041fda4094904d3e76c6cc0b938ee27 100644 (file)
@@ -7,6 +7,24 @@ use PVE::JSONSchema;
 use PVE::Tools;
 use PVE::Cluster;
 
+# return codes used in the ha environment
+# mainly by the resource agents
+use constant {
+    SUCCESS => 0, # action finished as expected
+    ERROR => 1, # action was erroneous
+    ETRY_AGAIN => 2, # action was erroneous and needs to be repeated
+    EWRONG_NODE => 3, # needs to fixup the service location
+    EUNKNOWN_SERVICE_TYPE => 4, # no plugin for this type service found
+    EUNKNOWN_COMMAND => 5,
+    EINVALID_PARAMETER => 6,
+};
+
+# get constants out of package in a somewhat easy way
+use base 'Exporter';
+our @EXPORT_OK = qw(SUCCESS ERROR EWRONG_NODE EUNKNOWN_SERVICE_TYPE
+ EUNKNOWN_COMMAND EINVALID_PARAMETER ETRY_AGAIN);
+our %EXPORT_TAGS = ( 'exit_codes' => [@EXPORT_OK] );
+
 PVE::JSONSchema::register_format('pve-ha-resource-id', \&pve_verify_ha_resource_id);
 sub pve_verify_ha_resource_id {
     my ($sid, $noerr) = @_;