mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 13:36:37 +00:00
refactor pveam to use it with our CLI Handler.
This commit is contained in:
parent
c8969ecb19
commit
108b722948
@ -1,6 +1,6 @@
|
|||||||
include ../../defines.mk
|
include ../../defines.mk
|
||||||
|
|
||||||
SOURCES=vzdump.pm pvesubscription.pm pveceph.pm
|
SOURCES=vzdump.pm pvesubscription.pm pveceph.pm pveam.pm
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
|
88
PVE/CLI/pveam.pm
Normal file
88
PVE/CLI/pveam.pm
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package PVE::CLI::pveam;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use PVE::Cluster;
|
||||||
|
use PVE::APLInfo;
|
||||||
|
use Data::Dumper;
|
||||||
|
use PVE::SafeSyslog;
|
||||||
|
use PVE::Tools qw(extract_param);
|
||||||
|
use PVE::Cluster;
|
||||||
|
use PVE::INotify;
|
||||||
|
use PVE::RPCEnvironment;
|
||||||
|
use PVE::JSONSchema qw(get_standard_option);
|
||||||
|
use PVE::CLIHandler;
|
||||||
|
|
||||||
|
use base qw(PVE::CLIHandler);
|
||||||
|
|
||||||
|
my $nodename = PVE::INotify::nodename();
|
||||||
|
|
||||||
|
my $upid_exit = sub {
|
||||||
|
my $upid = shift;
|
||||||
|
my $status = PVE::Tools::upid_read_status($upid);
|
||||||
|
exit($status eq 'OK' ? 0 : -1);
|
||||||
|
};
|
||||||
|
|
||||||
|
__PACKAGE__->register_method ({
|
||||||
|
name => 'update',
|
||||||
|
path => 'update',
|
||||||
|
method => 'PUT',
|
||||||
|
description => "Update Container Template Database.",
|
||||||
|
parameters => {
|
||||||
|
additionalProperties => 0,
|
||||||
|
},
|
||||||
|
returns => { type => 'null'},
|
||||||
|
code => sub {
|
||||||
|
|
||||||
|
my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
|
||||||
|
print Data::Dumper::Dumper $dccfg;
|
||||||
|
print STDERR "update failed - see /var/log/pveam.log for details\n"
|
||||||
|
if !PVE::APLInfo::update($dccfg->{http_proxy});
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
|
||||||
|
}});
|
||||||
|
|
||||||
|
our $cmddef = {
|
||||||
|
update => [ __PACKAGE__, 'update', []],
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
pveam Tool to manage Linux Container templates on Proxmox VE
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
=include synopsis
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
pveam can manage Container templates like updating the Database,
|
||||||
|
destroying, downloading and showing templates.
|
||||||
|
This tool support bash completion
|
||||||
|
|
||||||
|
=head1 EXAMPLES
|
||||||
|
|
||||||
|
Updating the DB
|
||||||
|
pveam update
|
||||||
|
|
||||||
|
downloading a template in background
|
||||||
|
pveam download debian-8.0-standard --storage local --bg 1
|
||||||
|
|
||||||
|
removing a template
|
||||||
|
pveam destroy debian-8.0-standard --storage local
|
||||||
|
|
||||||
|
showing all templates what are available
|
||||||
|
pveam show
|
||||||
|
|
||||||
|
=head1 FILES
|
||||||
|
|
||||||
|
Log-files
|
||||||
|
/var/log/pveam.log
|
||||||
|
|
||||||
|
=include pve_copyright
|
@ -3,13 +3,12 @@ include ../defines.mk
|
|||||||
SUBDIRS = init.d ocf test
|
SUBDIRS = init.d ocf test
|
||||||
|
|
||||||
SERVICES = pvestatd pveproxy pvedaemon spiceproxy
|
SERVICES = pvestatd pveproxy pvedaemon spiceproxy
|
||||||
CLITOOLS = vzdump pvesubscription pveceph
|
CLITOOLS = vzdump pvesubscription pveceph pveam
|
||||||
|
|
||||||
SCRIPTS = \
|
SCRIPTS = \
|
||||||
${SERVICES} \
|
${SERVICES} \
|
||||||
${CLITOOLS} \
|
${CLITOOLS} \
|
||||||
pvesh \
|
pvesh \
|
||||||
pveam \
|
|
||||||
pvebanner \
|
pvebanner \
|
||||||
pveversion \
|
pveversion \
|
||||||
pvemailforward.pl \
|
pvemailforward.pl \
|
||||||
@ -27,7 +26,7 @@ CLI_MANS = \
|
|||||||
pveupgrade.1 \
|
pveupgrade.1 \
|
||||||
pveperf.1 \
|
pveperf.1 \
|
||||||
pvesh.1 \
|
pvesh.1 \
|
||||||
pvereport.1
|
pvereport.1 \
|
||||||
|
|
||||||
CLI_PODS = $(addsuffix .pod, ${CLI_MANS})
|
CLI_PODS = $(addsuffix .pod, ${CLI_MANS})
|
||||||
|
|
||||||
|
21
bin/pveam
21
bin/pveam
@ -1,23 +1,8 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl -T
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use PVE::Cluster;
|
|
||||||
use PVE::APLInfo;
|
|
||||||
|
|
||||||
if (scalar (@ARGV) != 1) {
|
use PVE::CLI::pveam;
|
||||||
print STDERR "usage: $0 CMD\n";
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $cmd = shift;
|
PVE::CLI::pveam->run_cli();
|
||||||
|
|
||||||
if ($cmd eq 'update') {
|
|
||||||
my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
|
|
||||||
exit (0) if PVE::APLInfo::update($dccfg->{http_proxy});
|
|
||||||
print STDERR "update failed - see /var/log/pveam.log for details\n";
|
|
||||||
exit (-1);
|
|
||||||
} else {
|
|
||||||
print STDERR "unknown CMD '$cmd'\n";
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user