]> git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/HA/Env.pm
mark dead code
[pve-ha-manager.git] / src / 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 # manager status is stored on cluster, protected by ha_manager_lock
30 sub read_manager_status {
31 my ($self) = @_;
32
33 return $self->{plug}->read_manager_status();
34 }
35
36 sub write_manager_status {
37 my ($self, $status_obj) = @_;
38
39 return $self->{plug}->write_manager_status($status_obj);
40 }
41
42 # lrm status is written by LRM, protected by ha_agent_lock,
43 # but can be read by any node (CRM)
44
45 sub read_lrm_status {
46 my ($self, $node) = @_;
47
48 return $self->{plug}->read_lrm_status($node);
49 }
50
51 sub write_lrm_status {
52 my ($self, $status_obj) = @_;
53
54 return $self->{plug}->write_lrm_status($status_obj);
55 }
56
57 # we use this to enable/disbale ha
58 sub manager_status_exists {
59 my ($self) = @_;
60
61 die "this is not used?!"; # fixme:
62
63 return $self->{plug}->manager_status_exists();
64 }
65
66 # implement a way to send commands to the CRM master
67 sub queue_crm_commands {
68 my ($self, $cmd) = @_;
69
70 return $self->{plug}->queue_crm_commands($cmd);
71 }
72
73 sub read_crm_commands {
74 my ($self) = @_;
75
76 return $self->{plug}->read_crm_commands();
77 }
78
79 sub read_service_config {
80 my ($self) = @_;
81
82 return $self->{plug}->read_service_config();
83 }
84
85 sub change_service_location {
86 my ($self, $sid, $node) = @_;
87
88 return $self->{plug}->change_service_location($sid, $node);
89 }
90
91 sub read_group_config {
92 my ($self) = @_;
93
94 return $self->{plug}->read_group_config();
95 }
96
97 # this should return a hash containing info
98 # what nodes are members and online.
99 sub get_node_info {
100 my ($self) = @_;
101
102 return $self->{plug}->get_node_info();
103 }
104
105 sub log {
106 my ($self, $level, @args) = @_;
107
108 return $self->{plug}->log($level, @args);
109 }
110
111 # aquire a cluster wide manager lock
112 sub get_ha_manager_lock {
113 my ($self) = @_;
114
115 return $self->{plug}->get_ha_manager_lock();
116 }
117
118 # aquire a cluster wide node agent lock
119 sub get_ha_agent_lock {
120 my ($self) = @_;
121
122 return $self->{plug}->get_ha_agent_lock();
123 }
124
125 # same as get_ha_agent_lock(), but immeditaley release the lock on success
126 sub test_ha_agent_lock {
127 my ($self, $node) = @_;
128
129 return $self->{plug}->test_ha_agent_lock($node);
130 }
131
132 # return true when cluster is quorate
133 sub quorate {
134 my ($self) = @_;
135
136 return $self->{plug}->quorate();
137 }
138
139 # return current time
140 # overwrite that if you want to simulate
141 sub get_time {
142 my ($self) = @_;
143
144 return $self->{plug}->get_time();
145 }
146
147 sub sleep {
148 my ($self, $delay) = @_;
149
150 return $self->{plug}->sleep($delay);
151 }
152
153 sub sleep_until {
154 my ($self, $end_time) = @_;
155
156 return $self->{plug}->sleep_until($end_time);
157 }
158
159 sub loop_start_hook {
160 my ($self, @args) = @_;
161
162 return $self->{plug}->loop_start_hook(@args);
163 }
164
165 sub loop_end_hook {
166 my ($self, @args) = @_;
167
168 return $self->{plug}->loop_end_hook(@args);
169 }
170
171 sub watchdog_open {
172 my ($self) = @_;
173
174 # Note: when using /dev/watchdog, make sure perl does not close
175 # the handle automatically at exit!!
176
177 return $self->{plug}->watchdog_open();
178 }
179
180 sub watchdog_update {
181 my ($self, $wfh) = @_;
182
183 return $self->{plug}->watchdog_update($wfh);
184 }
185
186 sub watchdog_close {
187 my ($self, $wfh) = @_;
188
189 return $self->{plug}->watchdog_close($wfh);
190 }
191
192 sub exec_resource_agent {
193 my ($self, $sid, $cmd, @params) = @_;
194
195 return $self->{plug}->exec_resource_agent($sid, $cmd, @params)
196 }
197
198 1;