]> git.proxmox.com Git - pve-ha-manager.git/blob - PVE/HA/Env.pm
use better name for local status
[pve-ha-manager.git] / PVE / HA / Env.pm
1 package PVE::HA::Env;
2
3 use strict;
4 use warnings;
5
6 use PVE::SafeSyslog;
7 use PVE::Tools;
8
9 # abstract out the cluster environment for a single node
10
11 sub new {
12 my ($this, $baseclass, $node, @args) = @_;
13
14 my $class = ref($this) || $this;
15
16 my $plug = $baseclass->new($node, @args);
17
18 my $self = bless { plug => $plug }, $class;
19
20 return $self;
21 }
22
23 sub nodename {
24 my ($self) = @_;
25
26 return $self->{plug}->nodename();
27 }
28
29 sub read_local_status {
30 my ($self, $name) = @_;
31
32 return $self->{plug}->read_local_status($name);
33 }
34
35 sub write_local_status {
36 my ($self, $name, $status) = @_;
37
38 return $self->{plug}->write_local_status($name, $status);
39 }
40
41 # manager status is stored on cluster, protected by ha_manager_lock
42 sub read_manager_status {
43 my ($self) = @_;
44
45 return $self->{plug}->read_manager_status();
46 }
47
48 sub write_manager_status {
49 my ($self, $status_obj) = @_;
50
51 return $self->{plug}->write_manager_status($status_obj);
52 }
53
54 # we use this to enable/disbale ha
55 sub manager_status_exists {
56 my ($self) = @_;
57
58 return $self->{plug}->manager_status_exists();
59 }
60
61 sub read_service_config {
62 my ($self) = @_;
63
64 return $self->{plug}->read_service_config();
65 }
66
67 # this should return a hash containing info
68 # what nodes are members and online.
69 sub get_node_info {
70 my ($self) = @_;
71
72 return $self->{plug}->get_node_info();
73 }
74
75 sub log {
76 my ($self, $level, @args) = @_;
77
78 return $self->{plug}->log($level, @args);
79 }
80
81 # aquire a cluster wide manager lock
82 sub get_ha_manager_lock {
83 my ($self) = @_;
84
85 return $self->{plug}->get_ha_manager_lock();
86 }
87
88 # aquire a cluster wide node agent lock
89 sub get_ha_agent_lock {
90 my ($self) = @_;
91
92 return $self->{plug}->get_ha_agent_lock();
93 }
94
95 sub test_ha_agent_lock {
96 my ($self, $node) = @_;
97
98 return $self->{plug}->test_ha_agent_lock($node);
99 }
100
101 # return true when cluster is quorate
102 sub quorate {
103 my ($self) = @_;
104
105 return $self->{plug}->quorate();
106 }
107
108 # return current time
109 # overwrite that if you want to simulate
110 sub get_time {
111 my ($self) = @_;
112
113 return $self->{plug}->get_time();
114 }
115
116 sub sleep {
117 my ($self, $delay) = @_;
118
119 return $self->{plug}->sleep($delay);
120 }
121
122 sub sleep_until {
123 my ($self, $end_time) = @_;
124
125 return $self->{plug}->sleep_until($end_time);
126 }
127
128 sub loop_start_hook {
129 my ($self, @args) = @_;
130
131 return $self->{plug}->loop_start_hook(@args);
132 }
133
134 sub loop_end_hook {
135 my ($self, @args) = @_;
136
137 return $self->{plug}->loop_end_hook(@args);
138 }
139
140 sub watchdog_open {
141 my ($self) = @_;
142
143 return $self->{plug}->watchdog_open();
144 }
145
146 sub watchdog_update {
147 my ($self, $wfh) = @_;
148
149 return $self->{plug}->watchdog_update($wfh);
150 }
151
152 sub watchdog_close {
153 my ($self, $wfh) = @_;
154
155 return $self->{plug}->watchdog_close($wfh);
156 }
157
158 1;