[pve-devel] [RFC pve-manager] use standard output option 'quiet'

Dietmar Maurer dietmar at proxmox.com
Mon Jul 23 12:09:00 CEST 2018


Instead of defining an extra parameter.

Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/API2/APT.pm    | 13 +++----------
 PVE/API2/VZDump.pm |  8 ++++----
 PVE/VZDump.pm      |  6 ------
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index f5709747..76671997 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -289,19 +289,13 @@ __PACKAGE__->register_method({
 		optional => 1,
 		default => 0,
 	    },
-	    quiet => {
-		type => 'boolean',
-		description => "Only produces output suitable for logging, omitting progress indicators.",
-		optional => 1,
-		default => 0,
-	    },
 	},
     },
     returns => {
 	type => 'string',
     },
     code => sub {
-	my ($param) = @_;
+	my ($param, $options) = @_;
 
 	my $rpcenv = PVE::RPCEnvironment::get();
 
@@ -322,11 +316,10 @@ __PACKAGE__->register_method({
 
 	    my $cmd = ['apt-get', 'update'];
 
-	    print "starting apt-get update\n" if !$param->{quiet};
-	    
-	    if ($param->{quiet}) {
+	    if ($options->{quiet}) {
 		PVE::Tools::run_command($cmd, outfunc => sub {}, errfunc => sub {});
 	    } else {
+		print "starting apt-get update\n";
 		PVE::Tools::run_command($cmd);
 	    }
 
diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index 448917a8..aa98cdbe 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -40,7 +40,7 @@ __PACKAGE__->register_method ({
     },
     returns => { type => 'string' },
     code => sub {
-	my ($param) = @_;
+	my ($param, $options) = @_;
 
 	my $rpcenv = PVE::RPCEnvironment::get();
 
@@ -69,7 +69,7 @@ __PACKAGE__->register_method ({
 	# silent exit if we run on wrong node
 	return 'OK' if $param->{node} && $param->{node} ne $nodename;
 	
-	my $cmdline = PVE::VZDump::command_line($param);
+	my $cmdline = PVE::VZDump::command_line({ %$param, %$options });
 
 	# convert string lists to arrays
 	my @vmids = PVE::Tools::split_list(extract_param($param, 'vmid'));
@@ -147,8 +147,8 @@ __PACKAGE__->register_method ({
 	    $vzdump->exec_backup($rpcenv, $user); 
 	}; 
 
-	open STDOUT, '>/dev/null' if $param->{quiet} && !$param->{stdout};
-	open STDERR, '>/dev/null' if $param->{quiet};
+	open STDOUT, '>/dev/null' if $options->{quiet} && !$param->{stdout};
+	open STDERR, '>/dev/null' if $options->{quiet};
 
 	if ($rpcenv->{type} eq 'cli') {
 	    if ($param->{stdout}) {
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 7fc69f98..5136bf3c 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -66,12 +66,6 @@ my $confdesc = {
 	optional => 1,
 	default => 0,
     },
-    quiet => {
-	type => 'boolean',
-	description => "Be quiet.",
-	optional => 1,
-	default => 0,
-    },
     mode => {
 	type => 'string',
 	description => "Backup mode.",
-- 
2.11.0




More information about the pve-devel mailing list