]>
git.proxmox.com Git - pve-container.git/blob - src/pct
3a186f4111c89260c16c967a6ef25282a478f42f
8 use PVE
::Tools
qw(extract_param);
11 use PVE
::RPCEnvironment
;
12 use PVE
::JSONSchema
qw(get_standard_option);
18 use base
qw(PVE::CLIHandler);
20 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
24 die "please run as root\n" if $> != 0;
26 PVE
::INotify
::inotify_init
();
28 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
29 $rpcenv->init_request();
30 $rpcenv->set_language($ENV{LANG
});
31 $rpcenv->set_user('root@pam');
33 my $nodename = PVE
::INotify
::nodename
();
37 my $status = PVE
::Tools
::upid_read_status
($upid);
38 exit($status eq 'OK' ?
0 : -1);
41 __PACKAGE__-
>register_method ({
45 description
=> "Launch a console for the specified container.",
47 additionalProperties
=> 0,
49 vmid
=> get_standard_option
('pve-vmid'),
52 returns
=> { type
=> 'null' },
57 # test if container exists on this node
58 PVE
::LXC
::load_config
($param->{vmid
});
60 exec('lxc-console', '-n', $param->{vmid
});
63 __PACKAGE__-
>register_method ({
67 description
=> "Launch a shell for the specified container.",
69 additionalProperties
=> 0,
71 vmid
=> get_standard_option
('pve-vmid'),
74 returns
=> { type
=> 'null' },
79 # test if container exists on this node
80 PVE
::LXC
::load_config
($param->{vmid
});
82 exec('lxc-attach', '-n', $param->{vmid
});
86 #test => [ __PACKAGE__, 'test', [], {}, sub {} ],
87 list
=> [ 'PVE::API2::LXC', 'vmlist', [], { node
=> $nodename }, sub {
89 return if !scalar(@$res);
90 my $format = "%-10s %-10s %-20s\n";
91 printf($format, 'VMID', 'Status', 'Name');
92 foreach my $d (sort {$a->{vmid
} <=> $b->{vmid
} } @$res) {
93 printf($format, $d->{vmid
}, $d->{status
}, $d->{name
});
96 config
=> [ "PVE::API2::LXC", 'vm_config', ['vmid'],
97 { node
=> $nodename }, sub {
99 foreach my $k (sort (keys %$config)) {
100 next if $k eq 'digest';
101 my $v = $config->{$k};
102 if ($k eq 'description') {
103 $v = PVE
::Tools
::encode_text
($v);
108 set
=> [ 'PVE::API2::LXC', 'update_vm', ['vmid'], { node
=> $nodename }],
110 create
=> [ 'PVE::API2::LXC', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename }, $upid_exit ],
111 restore
=> [ 'PVE::API2::LXC', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename, restore
=> 1 }, $upid_exit ],
113 start
=> [ 'PVE::API2::LXC', 'vm_start', ['vmid'], { node
=> $nodename }, $upid_exit],
114 suspend
=> [ 'PVE::API2::LXC', 'vm_suspend', ['vmid'], { node
=> $nodename }, $upid_exit],
115 resume
=> [ 'PVE::API2::LXC', 'vm_resume', ['vmid'], { node
=> $nodename }, $upid_exit],
116 shutdown => [ 'PVE::API2::LXC', 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit],
117 stop
=> [ 'PVE::API2::LXC', 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit],
118 migrate
=> [ "PVE::API2::LXC", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit],
120 console
=> [ __PACKAGE__
, 'console', ['vmid']],
121 enter
=> [ __PACKAGE__
, 'enter', ['vmid']],
123 destroy
=> [ 'PVE::API2::LXC', 'destroy_vm', ['vmid'],
124 { node
=> $nodename }, $upid_exit ],
126 snapshot
=> [ "PVE::API2::LXC", 'snapshot', ['vmid', 'snapname'],
127 { node
=> $nodename } , $upid_exit ],
129 delsnapshot
=> [ "PVE::API2::LXC", 'delsnapshot', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
131 rollback
=> [ "PVE::API2::LXC", 'rollback', ['vmid', 'snapname'], { node
=> $nodename } , $upid_exit ],
136 PVE
::CLIHandler
::handle_cmd
($cmddef, "pct", $cmd, \
@ARGV, undef, $0);
144 pct - Tool to manage Linux Containers on Proxmox VE
152 Tool to manage linux containers.
154 =include pve_copyright