rm -f $@
cat $<|pod2man -n $* -s 1 -r ${VERSION} -c "Proxmox Documentation"|gzip -c9 >$@
-pve-ha-crm.1.pod: pve-ha-crm
- perl -I. ./pve-ha-crm printmanpod >$@
+pve-ha-crm.1.pod:
+ perl -I. -T -e "use PVE::Service::pve_ha_crm; PVE::Service::pve_ha_crm->generate_pod_manpage();" >$@
+
+pve-ha-crm.bash-completion:
+ perl -I. -T -e "use PVE::Service::pve_ha_crm; PVE::Service::pve_ha_crm->generate_bash_completions();" >$@
pve-ha-lrm.1.pod:
perl -I. -T -e "use PVE::Service::pve_ha_lrm; PVE::Service::pve_ha_lrm->generate_pod_manpage();" >$@
gcc watchdog-mux.c -o watchdog-mux -Wall -Wl,-z,relro $$(pkg-config --libs --cflags libsystemd-daemon)
.PHONY: install
-install: watchdog-mux pve-ha-crm pve-ha-lrm ha-manager.1.pod ha-manager.1.gz pve-ha-crm.1.pod pve-ha-crm.1.gz pve-ha-lrm.1.pod pve-ha-lrm.1.gz ha-manager.bash-completion pve-ha-lrm.bash-completion
- perl -I. ./pve-ha-crm verifyapi
+install: watchdog-mux pve-ha-crm pve-ha-lrm ha-manager.1.pod ha-manager.1.gz pve-ha-crm.1.pod pve-ha-crm.1.gz pve-ha-lrm.1.pod pve-ha-lrm.1.gz ha-manager.bash-completion pve-ha-lrm.bash-completion pve-ha-crm.bash-completion
+ perl -I. -T -e "use PVE::Service::pve_ha_crm; PVE::Service::pve_ha_crm->verify_api();"
perl -I. -T -e "use PVE::Service::pve_ha_lrm; PVE::Service::pve_ha_lrm->verify_api();"
perl -I. -T -e "use PVE::CLI::ha_manager; PVE::CLI::ha_manager->verify_api();"
install -d ${DESTDIR}${SBINDIR}
install -m 0755 pve-ha-lrm ${DESTDIR}${SBINDIR}
install -m 0755 ha-manager ${DESTDIR}${SBINDIR}
install -m 0755 watchdog-mux ${DESTDIR}${SBINDIR}
+ install -m 0644 -D pve-ha-crm.bash-completion ${DESTDIR}${BASHCOMPLDIR}/pve-ha-crm
install -m 0644 -D pve-ha-lrm.bash-completion ${DESTDIR}${BASHCOMPLDIR}/pve-ha-lrm
install -m 0644 -D ha-manager.bash-completion ${DESTDIR}${BASHCOMPLDIR}/ha-manager
make -C PVE install
-SOURCES=pve_ha_lrm.pm
+SOURCES=pve_ha_lrm.pm pve_ha_crm.pm
.PHONY: install
install: ${SOURCES}
--- /dev/null
+package PVE::Service::pve_ha_crm;
+
+use strict;
+use warnings;
+
+use PVE::SafeSyslog;
+use PVE::Daemon;
+use Data::Dumper;
+
+use PVE::HA::Env;
+use PVE::HA::Env::PVE2;
+use PVE::HA::CRM;
+
+use base qw(PVE::Daemon);
+
+our $exename = "pve-ha-crm";
+
+my $cmdline = [$0, @ARGV];
+
+my %daemon_options = (stop_wait_time => 60);
+
+my $daemon = __PACKAGE__->new('pve-ha-crm', $cmdline, %daemon_options);
+
+sub run {
+ my ($self) = @_;
+
+ $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
+
+ $self->{crm} = PVE::HA::CRM->new($self->{haenv});
+
+ for (;;) {
+ $self->{haenv}->loop_start_hook();
+
+ my $repeat = $self->{crm}->do_one_iteration();
+
+ $self->{haenv}->loop_end_hook();
+
+ last if !$repeat;
+ }
+}
+
+sub shutdown {
+ my ($self) = @_;
+
+ $self->{crm}->shutdown_request();
+}
+
+$daemon->register_start_command();
+$daemon->register_stop_command();
+$daemon->register_status_command();
+
+our $cmddef = {
+ start => [ __PACKAGE__, 'start', []],
+ stop => [ __PACKAGE__, 'stop', []],
+ status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+pve-ha-crm - PVE Cluster Ressource Manager Daemon
+
+=head1 SYNOPSIS
+
+=include synopsis
+
+=head1 DESCRIPTION
+
+This is the Cluster Ressource Manager.
+
+=include pve_copyright
use strict;
use warnings;
-use PVE::SafeSyslog;
-use PVE::Daemon;
-use Data::Dumper;
-use PVE::RPCEnvironment;
-use PVE::HA::Env;
-use PVE::HA::Env::PVE2;
-use PVE::HA::CRM;
+use PVE::Service::pve_ha_crm;
-use base qw(PVE::Daemon);
+use PVE::RPCEnvironment;
$SIG{'__WARN__'} = sub {
my $err = $@;
$@ = $err;
};
-my $cmdline = [$0, @ARGV];
-
-my %daemon_options = (stop_wait_time => 60);
-
-my $daemon = __PACKAGE__->new('pve-ha-crm', $cmdline, %daemon_options);
-
-my $rpcenv = PVE::RPCEnvironment->init('cli');
-
-$rpcenv->init_request();
-$rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam');
-
-sub run {
- my ($self) = @_;
-
- $self->{haenv} = PVE::HA::Env->new('PVE::HA::Env::PVE2', $self->{nodename});
-
- $self->{crm} = PVE::HA::CRM->new($self->{haenv});
-
- for (;;) {
- $self->{haenv}->loop_start_hook();
-
- my $repeat = $self->{crm}->do_one_iteration();
-
- $self->{haenv}->loop_end_hook();
+my $prepare = sub {
+ my $rpcenv = PVE::RPCEnvironment->init('cli');
- last if !$repeat;
- }
-}
+ $rpcenv->init_request();
+ $rpcenv->set_language($ENV{LANG});
+ $rpcenv->set_user('root@pam');
-sub shutdown {
- my ($self) = @_;
-
- $self->{crm}->shutdown_request();
-}
-
-$daemon->register_start_command();
-$daemon->register_stop_command();
-$daemon->register_status_command();
-
-my $cmddef = {
- start => [ __PACKAGE__, 'start', []],
- stop => [ __PACKAGE__, 'stop', []],
- status => [ __PACKAGE__, 'status', [], undef, sub { print shift . "\n";} ],
};
-my $cmd = shift;
-
-PVE::CLIHandler::handle_cmd($cmddef, $0, $cmd, \@ARGV, undef, $0);
-
-exit (0);
-
-__END__
-
-=head1 NAME
-
-pve-ha-crm - PVE Cluster Ressource Manager Daemon
-
-=head1 SYNOPSIS
-
-=include synopsis
-
-=head1 DESCRIPTION
-
-This is the Cluster Ressource Manager.
-
-=include pve_copyright
+PVE::Service::pve_ha_crm->run_cli(undef, undef, $prepare);