]> git.proxmox.com Git - pve-manager.git/blobdiff - bin/pvesubscription
convert pvesubscription into a PVE::CLI class
[pve-manager.git] / bin / pvesubscription
index 12d992e4f466583e097551ef8191f6e42b7ca283..75772cc5fe92c4acd22f7674c4c7b147108252f1 100755 (executable)
@@ -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();