From aab4f80bd4c13e53754e20bac4ab49d515ed30e8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 12 Mar 2015 06:55:19 +0100 Subject: [PATCH] add command line tool --- src/Makefile | 9 ++++++- src/ha-manager | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100755 src/ha-manager diff --git a/src/Makefile b/src/Makefile index 688b097..4c6c519 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,16 +23,21 @@ pve-ha-crm.1.pod: pve-ha-crm pve-ha-lrm.1.pod: pve-ha-lrm perl -I. ./pve-ha-lrm printmanpod >$@ +ha-manager.1.pod: ha-manager + perl -I. ./ha-manager printmanpod >$@ + watchdog-mux: watchdog-mux.c 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 pve-ha-crm.1.pod pve-ha-crm.1.gz pve-ha-lrm.1.pod pve-ha-lrm.1.gz +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 perl -I. ./pve-ha-crm verifyapi perl -I. ./pve-ha-lrm verifyapi + perl -I. ./ha-manager verifyapi install -d ${DESTDIR}${SBINDIR} install -m 0755 pve-ha-crm ${DESTDIR}${SBINDIR} install -m 0755 pve-ha-lrm ${DESTDIR}${SBINDIR} + install -m 0755 ha-manager ${DESTDIR}${SBINDIR} install -m 0755 watchdog-mux ${DESTDIR}${SBINDIR} make -C PVE install install -d ${DESTDIR}/usr/share/man/man1 @@ -41,6 +46,8 @@ install: watchdog-mux pve-ha-crm pve-ha-lrm pve-ha-crm.1.pod pve-ha-crm.1.gz pve install -m 0644 pve-ha-crm.1.pod ${DESTDIR}/${PODDIR} install -m 0644 pve-ha-lrm.1.gz ${DESTDIR}/usr/share/man/man1/ install -m 0644 pve-ha-lrm.1.pod ${DESTDIR}/${PODDIR} + install -m 0644 ha-manager.1.gz ${DESTDIR}/usr/share/man/man1/ + install -m 0644 ha-manager.1.pod ${DESTDIR}/${PODDIR} .PHONY: installsim installsim: pve-ha-simulator diff --git a/src/ha-manager b/src/ha-manager new file mode 100755 index 0000000..b7e7eff --- /dev/null +++ b/src/ha-manager @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use PVE::INotify; +use PVE::JSONSchema; +use PVE::CLIHandler; +use PVE::Cluster; + +use base qw(PVE::CLIHandler); + +$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; +$ENV{LC_ALL} = 'C'; + +die "please run as root\n" if $> != 0; + +my $nodename = PVE::INotify::nodename(); + +__PACKAGE__->register_method ({ + name => 'test', + path => 'test', + method => 'GET', + description => "A stupid test.", + parameters => { + additionalProperties => 0, + properties => { + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + print "TEST\n"; + + return undef; + }}); + +my $cmddef = { + test => [ __PACKAGE__, 'test', []], +}; +my $cmd = shift; + +if ($cmd && $cmd ne 'printmanpod' && $cmd ne 'verifyapi') { + PVE::Cluster::check_cfs_is_mounted(); + PVE::Cluster::cfs_update(); +} + +PVE::CLIHandler::handle_cmd($cmddef, "ha-manager", $cmd, \@ARGV, undef, $0); + +exit 0; + +__END__ + +=head1 NAME + +pvecm - Proxmox VE HA Command Line Interface + +=head1 SYNOPSIS + +=include synopsis + +=head1 DESCRIPTION + +ha-manager is a program to manage the HA configuration. + +=include pve_copyright + + -- 2.39.2