Commit b3874f00 authored by Dietmar Maurer's avatar Dietmar Maurer

convert pvesubscription into a PVE::CLI class

parent 96860456
include ../../defines.mk
SOURCES=vzdump.pm
SOURCES=vzdump.pm pvesubscription.pm
.PHONY: install
install: ${SOURCES}
......
package PVE::CLI::pvesubscription;
use strict;
use warnings;
use PVE::Tools;
use PVE::SafeSyslog;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::CLIHandler;
use PVE::API2::Subscription;
use base qw(PVE::CLIHandler);
my $nodename = PVE::INotify::nodename();
our $cmddef = {
update => [ 'PVE::API2::Subscription', 'update', undef, { node => $nodename } ],
get => [ 'PVE::API2::Subscription', 'get', undef, { node => $nodename },
sub {
my $info = shift;
foreach my $k (sort keys %$info) {
print "$k: $info->{$k}\n";
}
}],
set => [ 'PVE::API2::Subscription', 'set', ['key'], { node => $nodename } ],
};
1;
__END__
=head1 NAME
pvesubscription - Proxmox VE subscription mamager
=head1 SYNOPSIS
=include synopsis
=head1 DESCRIPTION
This tool is used to handle pve subscriptions.
=include pve_copyright
......@@ -3,7 +3,7 @@ include ../defines.mk
SUBDIRS = init.d cron ocf test
SERVICES = pvestatd pveproxy
CLITOOLS = vzdump
CLITOOLS = vzdump pvesubscription
SCRIPTS = \
${SERVICES} \
......@@ -15,7 +15,6 @@ SCRIPTS = \
pvedaemon \
spiceproxy \
pveversion \
pvesubscription \
pvemailforward.pl \
pveupgrade \
pveperf
......@@ -28,7 +27,6 @@ CLI_MANS = \
pvedaemon.1 \
spiceproxy.1 \
pveversion.1 \
pvesubscription.1 \
pveupgrade.1 \
pveperf.1
......@@ -56,10 +54,6 @@ pveversion.1.pod: pveversion
podselect $< > $@.tmp
mv $@.tmp $@
pvesubscription.1.pod: pvesubscription
podselect $< > $@.tmp
mv $@.tmp $@
pveupgrade.1.pod: pveupgrade
podselect $< > $@.tmp
mv $@.tmp $@
......@@ -88,9 +82,6 @@ pvectl.1.pod: pvectl
pveceph.1.pod: pveceph
perl -I.. -T ./pveceph printmanpod >$@
pvesubscription.1.pod: pvesubscription
perl -I.. -T ./pvesubscription printmanpod >$@
vzrestore.1.pod: vzrestore
perl -I.. ./vzrestore printmanpod >$@
......@@ -111,7 +102,6 @@ install: ${SCRIPTS} ${CLI_MANS} ${SERVICE_MANS} pvemailforward $(addsuffix .serv
install -m 0644 ${SERVICE_MANS} ${MAN8DIR}
install -d ${PODDIR}
for i in ${CLITOOLS}; do install -m 0644 $$i.1.pod ${PODDIR}; done
install -m 0644 pvesubscription.1.pod ${PODDIR}
for i in ${CLITOOLS}; do install -m 0644 -D $$i.bash-completion ${BASHCOMPLDIR}/$$i; done
for i in ${SERVICES}; do install -m 0644 -D $$i.service-bash-completion ${BASHCOMPLDIR}/$$i; done
set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done
......
......@@ -3,65 +3,6 @@
use strict;
use warnings;
use PVE::Tools;
use PVE::SafeSyslog;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::CLIHandler;
use PVE::API2::Subscription;
use PVE::CLI::pvesubscription;
use base qw(PVE::CLIHandler);
my $nodename = PVE::INotify::nodename();
sub prepare {
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
initlog('pvesubscription');
die "please run as root\n" if $> != 0;
PVE::INotify::inotify_init();
my $rpcenv = PVE::RPCEnvironment->init('cli');
$rpcenv->init_request();
$rpcenv->set_language($ENV{LANG});
$rpcenv->set_user('root@pam');
}
my $cmddef = {
update => [ 'PVE::API2::Subscription', 'update', undef, { node => $nodename } ],
get => [ 'PVE::API2::Subscription', 'get', undef, { node => $nodename },
sub {
my $info = shift;
foreach my $k (sort keys %$info) {
print "$k: $info->{$k}\n";
}
}],
set => [ 'PVE::API2::Subscription', 'set', ['key'], { node => $nodename } ],
};
my $cmd = shift;
PVE::CLIHandler::handle_cmd($cmddef, "pvesubscription", $cmd, \@ARGV, undef, $0, \&prepare);
exit 0;
__END__
=head1 NAME
pvesubscription - Proxmox VE subscription mamager
=head1 SYNOPSIS
=include synopsis
=head1 DESCRIPTION
This tool is used to handle pve subscriptions.
=include pve_copyright
PVE::CLI::pvesubscription->run_cli();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment