]>
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 # we use this to enable/disbale ha
58 sub manager_status_exists
{
61 die "this is not used?!"; # fixme:
63 return $self->{plug
}->manager_status_exists();
66 # implement a way to send commands to the CRM master
67 sub queue_crm_commands
{
68 my ($self, $cmd) = @_;
70 return $self->{plug
}->queue_crm_commands($cmd);
73 sub read_crm_commands
{
76 return $self->{plug
}->read_crm_commands();
79 sub read_service_config
{
82 return $self->{plug
}->read_service_config();
85 sub change_service_location
{
86 my ($self, $sid, $node) = @_;
88 return $self->{plug
}->change_service_location($sid, $node);
91 sub read_group_config
{
94 return $self->{plug
}->read_group_config();
97 # this should return a hash containing info
98 # what nodes are members and online.
102 return $self->{plug
}->get_node_info();
106 my ($self, $level, @args) = @_;
108 return $self->{plug
}->log($level, @args);
111 # aquire a cluster wide manager lock
112 sub get_ha_manager_lock
{
115 return $self->{plug
}->get_ha_manager_lock();
118 # aquire a cluster wide node agent lock
119 sub get_ha_agent_lock
{
122 return $self->{plug
}->get_ha_agent_lock();
125 # same as get_ha_agent_lock(), but immeditaley release the lock on success
126 sub test_ha_agent_lock
{
127 my ($self, $node) = @_;
129 return $self->{plug
}->test_ha_agent_lock($node);
132 # return true when cluster is quorate
136 return $self->{plug
}->quorate();
139 # return current time
140 # overwrite that if you want to simulate
144 return $self->{plug
}->get_time();
148 my ($self, $delay) = @_;
150 return $self->{plug
}->sleep($delay);
154 my ($self, $end_time) = @_;
156 return $self->{plug
}->sleep_until($end_time);
159 sub loop_start_hook
{
160 my ($self, @args) = @_;
162 return $self->{plug
}->loop_start_hook(@args);
166 my ($self, @args) = @_;
168 return $self->{plug
}->loop_end_hook(@args);
174 # Note: when using /dev/watchdog, make sure perl does not close
175 # the handle automatically at exit!!
177 return $self->{plug
}->watchdog_open();
180 sub watchdog_update
{
181 my ($self, $wfh) = @_;
183 return $self->{plug
}->watchdog_update($wfh);
187 my ($self, $wfh) = @_;
189 return $self->{plug
}->watchdog_close($wfh);
192 sub exec_resource_agent
{
193 my ($self, $sid, $cmd, @params) = @_;
195 return $self->{plug
}->exec_resource_agent($sid, $cmd, @params)