From: Thomas Lamprecht Date: Fri, 23 Oct 2015 12:04:23 +0000 (+0200) Subject: Adding constants to gain more readability X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=80ec7386e54cbb269f68819a95746a7296cef679;p=pve-ha-manager.git Adding constants to gain more readability Add constants to make some code easier to understand, especially the execution of resource agents and their return codes. Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/HA/Tools.pm b/src/PVE/HA/Tools.pm index fb522e9..a04fd2e 100644 --- a/src/PVE/HA/Tools.pm +++ b/src/PVE/HA/Tools.pm @@ -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) = @_;