]>
git.proxmox.com Git - pve-ha-manager.git/blob - src/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 # 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 # we use this to enable/disbale ha
71 sub service_config_exists
{
74 return $self->{plug
}->service_config_exists();
77 sub read_service_config
{
80 return $self->{plug
}->read_service_config();
83 sub change_service_location
{
84 my ($self, $sid, $current_node, $new_node) = @_;
86 return $self->{plug
}->change_service_location($sid, $current_node, $new_node);
89 sub read_group_config
{
92 return $self->{plug
}->read_group_config();
95 # this should return a hash containing info
96 # what nodes are members and online.
100 return $self->{plug
}->get_node_info();
104 my ($self, $level, @args) = @_;
106 return $self->{plug
}->log($level, @args);
109 # aquire a cluster wide manager lock
110 sub get_ha_manager_lock
{
113 return $self->{plug
}->get_ha_manager_lock();
116 # aquire a cluster wide node agent lock
117 sub get_ha_agent_lock
{
118 my ($self, $node) = @_;
120 return $self->{plug
}->get_ha_agent_lock($node);
123 # return true when cluster is quorate
127 return $self->{plug
}->quorate();
130 # return current time
131 # overwrite that if you want to simulate
135 return $self->{plug
}->get_time();
139 my ($self, $delay) = @_;
141 return $self->{plug
}->sleep($delay);
145 my ($self, $end_time) = @_;
147 return $self->{plug
}->sleep_until($end_time);
150 sub loop_start_hook
{
151 my ($self, @args) = @_;
153 return $self->{plug
}->loop_start_hook(@args);
157 my ($self, @args) = @_;
159 return $self->{plug
}->loop_end_hook(@args);
165 # Note: when using /dev/watchdog, make sure perl does not close
166 # the handle automatically at exit!!
168 return $self->{plug
}->watchdog_open();
171 sub watchdog_update
{
172 my ($self, $wfh) = @_;
174 return $self->{plug
}->watchdog_update($wfh);
178 my ($self, $wfh) = @_;
180 return $self->{plug
}->watchdog_close($wfh);
183 sub exec_resource_agent
{
184 my ($self, $sid, $service_config, $cmd, @params) = @_;
186 return $self->{plug
}->exec_resource_agent($sid, $service_config, $cmd, @params)
189 # hack to support regression tests
193 return $self->{plug
}->can_fork();