]>
git.proxmox.com Git - pve-ha-manager.git/blob - PVE/HA/Env.pm
9 # abstract out the cluster environment for a single node
12 my ($this, $baseclass, $node, @args) = @_;
14 my $class = ref($this) || $this;
16 my $plug = $baseclass->new($node, @args);
18 my $self = bless { plug
=> $plug }, $class;
26 return $self->{plug
}->nodename();
29 # manager status is stored on cluster, protected by ha_manager_lock
30 sub read_manager_status
{
33 return $self->{plug
}->read_manager_status();
36 sub write_manager_status
{
37 my ($self, $status_obj) = @_;
39 return $self->{plug
}->write_manager_status($status_obj);
42 # we use this to enable/disbale ha
43 sub manager_status_exists
{
46 return $self->{plug
}->manager_status_exists();
49 sub read_service_config
{
52 return $self->{plug
}->read_service_config();
55 # this should return a hash containing info
56 # what nodes are members and online.
60 return $self->{plug
}->get_node_info();
64 my ($self, $level, @args) = @_;
66 return $self->{plug
}->log($level, @args);
69 # aquire a cluster wide manager lock
70 sub get_ha_manager_lock
{
73 return $self->{plug
}->get_ha_manager_lock();
76 # aquire a cluster wide node agent lock
77 sub get_ha_agent_lock
{
80 return $self->{plug
}->get_ha_agent_lock();
83 sub test_ha_agent_lock
{
84 my ($self, $node) = @_;
86 return $self->{plug
}->test_ha_agent_lock($node);
89 # return true when cluster is quorate
93 return $self->{plug
}->quorate();
97 # overwrite that if you want to simulate
101 return $self->{plug
}->get_time();
105 my ($self, $delay) = @_;
107 return $self->{plug
}->sleep($delay);
111 my ($self, $end_time) = @_;
113 return $self->{plug
}->sleep_until($end_time);
116 sub loop_start_hook
{
117 my ($self, @args) = @_;
119 return $self->{plug
}->loop_start_hook(@args);
123 my ($self, @args) = @_;
125 return $self->{plug
}->loop_end_hook(@args);
131 # Note: when using /dev/watchdog, make sure perl does not close
132 # the handle automatically at exit!!
134 return $self->{plug
}->watchdog_open();
137 sub watchdog_update
{
138 my ($self, $wfh) = @_;
140 return $self->{plug
}->watchdog_update($wfh);
144 my ($self, $wfh) = @_;
146 return $self->{plug
}->watchdog_close($wfh);