]> git.proxmox.com Git - pve-ha-manager.git/blob - PVE/HA/Env.pm
implement get_node_info
[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
8 # abstract out the cluster environment
9
10 sub new {
11 my ($this) = @_;
12
13 my $class = ref($this) || $this;
14
15 my $self = bless {}, $class;
16
17 return $self;
18 }
19
20 # this should return a hash containing info
21 # what nodes are members and online.
22 sub get_node_info {
23 my ($self) = @_;
24
25 die "implement me";
26
27 # return { node1 => { online => 1, join_time => X }, node2 => ... }
28 }
29
30 sub log {
31 my ($self, $level, $msg) = @_;
32
33 syslog($level, $msg);
34 }
35
36 # aquire a cluster wide lock
37 sub get_ha_manager_lock {
38 my ($self) = @_;
39
40 die "implement me";
41 }
42
43 # return current time
44 # overwrite that if you want to simulate
45 sub get_time {
46 my ($self) = @_;
47
48 return time();
49 }
50
51 sub sleep {
52 my ($self, $delay) = @_;
53
54 sleep($delay);
55 }
56
57 sub loop_start_hook {
58 my ($self) = @_;
59
60 # do nothing
61 }
62
63 sub loop_end_hook {
64 my ($self) = @_;
65
66 # do nothing
67 }
68
69
70 1;