Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +++ OpenVZ.pm 2012-04-04 16:08:38.000000000 +0200
- @@ -530,6 +530,7 @@
- { subdir => 'initlog' },
- { subdir => 'rrd' },
- { subdir => 'rrddata' },
- + { subdir => 'exec2' },
- ];
- return $res;
- @@ -1413,4 +1414,58 @@
- }
- }});
- +__PACKAGE__->register_method({
- + name => 'vm_exec2',
- + path => '{vmid}/exec2',
- + method => 'POST',
- + protected => 1,
- + proxyto => 'node',
- + description => "Execute command in container.",
- + permissions => {
- + check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
- + },
- + parameters => {
- + additionalProperties => 1,
- + properties => {
- + node => get_standard_option('pve-node'),
- + vmid => get_standard_option('pve-vmid'),
- + execcmd => {
- + type => 'string',
- + description => "Command to execute insite CT",
- + },
- + },
- + },
- + returns => {
- + type => 'string',
- + },
- + code => sub {
- + my ($param) = @_;
- +
- + my $rpcenv = PVE::RPCEnvironment::get();
- +
- + my $authuser = $rpcenv->get_user();
- +
- + my $node = extract_param($param, 'node');
- +
- + my $vmid = extract_param($param, 'vmid');
- +
- + my $execcmd = extract_param($param, 'execcmd');
- +
- + die "CT $vmid not running\n" if !PVE::OpenVZ::check_running($vmid);
- +
- + my $realcmd = sub {
- + my $upid = shift;
- +
- + syslog('info', "Exec CT $vmid: $upid\n");
- +
- + my $cmd = ['vzctl', 'exec2', $vmid, $execcmd ];
- + run_command($cmd);
- +
- + return;
- + };
- +
- + return $rpcenv->fork_worker('vzexec2', $vmid, $authuser, $realcmd);
- + }});
- +
- +
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement