Using the new 'extra-args' options for command arguments. Examples: # pct exec 100 ls / # pct exec 100 -- ls -l / --- src/pct | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/src/pct b/src/pct index 6821ea3..9e0a843 100755 --- a/src/pct +++ b/src/pct @@ -86,6 +86,32 @@ __PACKAGE__->register_method ({ exec('lxc-attach', '-n', $param->{vmid}); }}); +__PACKAGE__->register_method ({ + name => 'exec', + path => 'exec', + method => 'GET', + description => "Launch a command inside the specified container.", + parameters => { + additionalProperties => 0, + properties => { + vmid => get_standard_option('pve-vmid'), + 'extra-args' => get_standard_option('extra-args'), + }, + }, + returns => { type => 'null' }, + + code => sub { + my ($param) = @_; + + # test if container exists on this node + PVE::LXC::load_config($param->{vmid}); + + if (!$param->{'extra-args'}) { + die "missing command"; + } + exec('lxc-attach', '-n', $param->{vmid}, '--', @{$param->{'extra-args'}}); + }}); + my $cmddef = { #test => [ __PACKAGE__, 'test', [], {}, sub {} ], list=> [ 'PVE::API2::LXC', 'vmlist', [], { node => $nodename }, sub { @@ -124,6 +150,7 @@ my $cmddef = { console => [ __PACKAGE__, 'console', ['vmid']], enter => [ __PACKAGE__, 'enter', ['vmid']], + exec => [ __PACKAGE__, 'exec', ['vmid', 'extra-args']], destroy => [ 'PVE::API2::LXC', 'destroy_vm', ['vmid'], { node => $nodename }, $upid_exit ], -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel