]>
git.proxmox.com Git - pve-manager.git/blob - bin/pvectl
834c9e2b0e1fbd216155f0567c5e2aa803cd795e
5 use PVE
::Tools
qw(extract_param);
6 use PVE
::Cluster
qw(cfs_register_file cfs_read_file);
9 use PVE
::RPCEnvironment
;
11 use PVE
::API2
::OpenVZ
;
13 use Data
::Dumper
; # fixme: remove
15 use base
qw(PVE::CLIHandler);
17 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
21 die "please run as root\n" if $> != 0;
23 PVE
::INotify
::inotify_init
();
24 my $nodename = PVE
::INotify
::nodename
();
26 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
28 $rpcenv->init_request();
29 $rpcenv->set_language($ENV{LANG
});
30 $rpcenv->set_user('root@pam');
34 my $status = PVE
::Tools
::upid_read_status
($upid);
35 exit($status eq 'OK' ?
0 : -1);
40 list
=> [ "PVE::API2::OpenVZ", 'vmlist', [],
41 { node
=> $nodename }, sub {
44 exit 0 if (!scalar(@$vmlist));
46 printf "%10s %-20s %-10s %-10s %-12s\n",
47 qw(VMID NAME STATUS MEM(MB) DISK
(GB
));
49 foreach my $rec (sort { $a->{vmid
} <=> $b->{vmid
} } @$vmlist) {
50 printf "%10s %-20s %-10s %-10s %-12.2f\n", $rec->{vmid
}, $rec->{name
} || '',
52 ($rec->{maxmem
} || 0)/(1024*1024),
53 ($rec->{maxdisk
} || 0)/(1024*1024*1024);
57 create
=> [ 'PVE::API2::OpenVZ', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename }, $upid_exit ],
58 destroy
=> [ 'PVE::API2::OpenVZ', 'destroy_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
60 set
=> [ "PVE::API2::OpenVZ", 'update_vm', ['vmid'], { node
=> $nodename } ],
62 config
=> [ "PVE::API2::OpenVZ", 'vm_config', ['vmid'],
63 { node
=> $nodename }, sub {
65 foreach my $k (sort (keys %$config)) {
66 next if $k eq 'digest';
67 my $v = $config->{$k};
68 if ($k eq 'description') {
69 $v = PVE
::Tools
::encode_text
($v);
75 start
=> [ 'PVE::API2::OpenVZ', 'vm_start', ['vmid'], { node
=> $nodename }, $upid_exit],
76 shutdown => [ 'PVE::API2::OpenVZ', 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit],
77 stop
=> [ 'PVE::API2::OpenVZ', 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit],
78 mount
=> [ 'PVE::API2::OpenVZ', 'vm_mount', ['vmid'], { node
=> $nodename }, $upid_exit],
79 umount
=> [ 'PVE::API2::OpenVZ', 'vm_umount', ['vmid'], { node
=> $nodename }, $upid_exit],
80 migrate
=> [ "PVE::API2::OpenVZ", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit],
85 PVE
::CLIHandler
::handle_cmd
($cmddef, "pvectl", $cmd, \
@ARGV, undef, $0);
93 pvectl - vzctl wrapper to manage OpenVZ containers
101 This is a small wrapper around vztl.
103 =include pve_copyright