]>
git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/HA/Env.pm
b345f682c6fbd0fc2275793abb5e1d33c9a0ca5d
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 # lrm status is written by LRM, protected by ha_agent_lock,
43 # but can be read by any node (CRM)
46 my ($self, $node) = @_;
48 return $self->{plug
}->read_lrm_status($node);
51 sub write_lrm_status
{
52 my ($self, $status_obj) = @_;
54 return $self->{plug
}->write_lrm_status($status_obj);
57 # implement a way to send commands to the CRM master
58 sub queue_crm_commands
{
59 my ($self, $cmd) = @_;
61 return $self->{plug
}->queue_crm_commands($cmd);
64 sub read_crm_commands
{
67 return $self->{plug
}->read_crm_commands();
70 sub read_service_config
{
73 return $self->{plug
}->read_service_config();
76 sub change_service_location
{
77 my ($self, $sid, $current_node, $new_node) = @_;
79 return $self->{plug
}->change_service_location($sid, $current_node, $new_node);
82 sub read_group_config
{
85 return $self->{plug
}->read_group_config();
88 # this should return a hash containing info
89 # what nodes are members and online.
93 return $self->{plug
}->get_node_info();
97 my ($self, $level, @args) = @_;
99 return $self->{plug
}->log($level, @args);
102 # aquire a cluster wide manager lock
103 sub get_ha_manager_lock
{
106 return $self->{plug
}->get_ha_manager_lock();
109 # aquire a cluster wide node agent lock
110 sub get_ha_agent_lock
{
111 my ($self, $node) = @_;
113 return $self->{plug
}->get_ha_agent_lock($node);
116 # return true when cluster is quorate
120 return $self->{plug
}->quorate();
123 # return current time
124 # overwrite that if you want to simulate
128 return $self->{plug
}->get_time();
132 my ($self, $delay) = @_;
134 return $self->{plug
}->sleep($delay);
138 my ($self, $end_time) = @_;
140 return $self->{plug
}->sleep_until($end_time);
143 sub loop_start_hook
{
144 my ($self, @args) = @_;
146 return $self->{plug
}->loop_start_hook(@args);
150 my ($self, @args) = @_;
152 return $self->{plug
}->loop_end_hook(@args);
158 # Note: when using /dev/watchdog, make sure perl does not close
159 # the handle automatically at exit!!
161 return $self->{plug
}->watchdog_open();
164 sub watchdog_update
{
165 my ($self, $wfh) = @_;
167 return $self->{plug
}->watchdog_update($wfh);
171 my ($self, $wfh) = @_;
173 return $self->{plug
}->watchdog_close($wfh);
176 sub exec_resource_agent
{
177 my ($self, $sid, $service_config, $cmd, @params) = @_;
179 return $self->{plug
}->exec_resource_agent($sid, $service_config, $cmd, @params)
182 # hack to support regression tests
186 return $self->{plug
}->can_fork();