]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RESTEnvironment.pm
1 package PMG
::RESTEnvironment
;
7 use PVE
::RESTEnvironment
;
10 use PMG
::ClusterConfig
;
12 use base
qw(PVE::RESTEnvironment);
14 my $nodename = PVE
::INotify
::nodename
();
16 # initialize environment - must be called once at program startup
18 my ($class, $type, %params) = @_;
20 $class = ref($class) || $class;
22 my $self = $class->SUPER::init
($type, %params);
29 # init_request - must be called before each RPC request
31 my ($self, %params) = @_;
33 $self->SUPER::init_request
(%params);
35 $self->{cinfo
} = PVE
::INotify
::read_file
("cluster.conf");
38 sub check_node_is_master
{
41 my $master = PMG
::Cluster
::get_master_node
($self->{cinfo
});
43 return 1 if $master eq 'localhost' || $master eq $nodename;
45 return undef if $noerr;
47 die "this node ('$nodename') is not the master node\n";