}
my $disable_proxy = 0;
+my $opt_nooutput = 0;
my $cmd = shift;
-if ($cmd && $cmd eq '--noproxy') {
- $cmd = shift;
- $disable_proxy = 1;
-}
+my $optmatch;
+do {
+ $optmatch = 0;
+ if ($cmd) {
+ if ($cmd eq '--noproxy') {
+ $cmd = shift;
+ $disable_proxy = 1;
+ $optmatch = 1;
+ } elsif ($cmd eq '--nooutput') {
+ # we use this when starting task in CLI (suppress printing upid)
+ # for example 'pvesh --nooutput create /nodes/localhost/stopall'
+ $cmd = shift;
+ $opt_nooutput = 1;
+ $optmatch = 1;
+ }
+ }
+} while ($optmatch);
if ($cmd) {
if ($cmd eq 'verifyapi') {
exit 0;
} elsif ($cmd eq 'ls' || $cmd eq 'get' || $cmd eq 'create' ||
$cmd eq 'set' || $cmd eq 'delete' ||$cmd eq 'help' ) {
- pve_command([ $cmd, @ARGV]);
+ pve_command([ $cmd, @ARGV], $opt_nooutput);
exit(0);
} else {
print_usage ("unknown command '$cmd'");
}
sub call_method {
- my ($dir, $cmd, $args) = @_;
+ my ($dir, $cmd, $args, $nooutput) = @_;
my $method = map_cmd($cmd);
my $data = $handler->cli_handler("$cmd $dir", $info->{name}, $args, [], $uri_param, $read_password);
+ return if $nooutput;
+
warn "200 OK\n"; # always print OK status if successful
if ($info && $info->{returns} && $info->{returns}->{type}) {
sub pve_command {
- my $args = shift;
+ my ($args, $nooutput) = @_;
PVE::Cluster::cfs_update();
$path = shift @$args;
}
- call_method(abs_path($cdir, $path), $cmd, $args);
+ call_method(abs_path($cdir, $path), $cmd, $args, $nooutput);
} elsif ($cmd eq 'delete') {