]>
git.proxmox.com Git - pve-manager.git/blob - bin/pvectl
f8ae3ad12a9cb7e3278d2f45dd23f779dea469d4
6 use PVE
::Tools
qw(extract_param);
7 use PVE
::Cluster
qw(cfs_register_file cfs_read_file);
10 use PVE
::RPCEnvironment
;
12 use PVE
::API2
::OpenVZ
;
14 use Data
::Dumper
; # fixme: remove
16 use base
qw(PVE::CLIHandler);
18 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
22 die "please run as root\n" if $> != 0;
24 PVE
::INotify
::inotify_init
();
25 my $nodename = PVE
::INotify
::nodename
();
27 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
29 $rpcenv->init_request();
30 $rpcenv->set_language($ENV{LANG
});
31 $rpcenv->set_user('root@pam');
35 my $status = PVE
::Tools
::upid_read_status
($upid);
36 exit($status eq 'OK' ?
0 : -1);
41 list
=> [ "PVE::API2::OpenVZ", 'vmlist', [],
42 { node
=> $nodename }, sub {
45 exit 0 if (!scalar(@$vmlist));
47 printf "%10s %-20s %-10s %-10s %-12s\n",
48 qw(VMID NAME STATUS MEM(MB) DISK
(GB
));
50 foreach my $rec (sort { $a->{vmid
} <=> $b->{vmid
} } @$vmlist) {
51 printf "%10s %-20s %-10s %-10s %-12.2f\n", $rec->{vmid
}, $rec->{name
} || '',
53 ($rec->{maxmem
} || 0)/(1024*1024),
54 ($rec->{maxdisk
} || 0)/(1024*1024*1024);
58 create
=> [ 'PVE::API2::OpenVZ', 'create_vm', ['vmid', 'ostemplate'], { node
=> $nodename }, $upid_exit ],
59 destroy
=> [ 'PVE::API2::OpenVZ', 'destroy_vm', ['vmid'], { node
=> $nodename }, $upid_exit ],
61 set
=> [ "PVE::API2::OpenVZ", 'update_vm', ['vmid'], { node
=> $nodename } ],
63 config
=> [ "PVE::API2::OpenVZ", 'vm_config', ['vmid'],
64 { node
=> $nodename }, sub {
66 foreach my $k (sort (keys %$config)) {
67 next if $k eq 'digest';
68 my $v = $config->{$k};
69 if ($k eq 'description') {
70 $v = PVE
::Tools
::encode_text
($v);
76 start
=> [ 'PVE::API2::OpenVZ', 'vm_start', ['vmid'], { node
=> $nodename }, $upid_exit],
77 shutdown => [ 'PVE::API2::OpenVZ', 'vm_shutdown', ['vmid'], { node
=> $nodename }, $upid_exit],
78 stop
=> [ 'PVE::API2::OpenVZ', 'vm_stop', ['vmid'], { node
=> $nodename }, $upid_exit],
79 mount
=> [ 'PVE::API2::OpenVZ', 'vm_mount', ['vmid'], { node
=> $nodename }, $upid_exit],
80 umount
=> [ 'PVE::API2::OpenVZ', 'vm_umount', ['vmid'], { node
=> $nodename }, $upid_exit],
81 migrate
=> [ "PVE::API2::OpenVZ", 'migrate_vm', ['vmid', 'target'], { node
=> $nodename }, $upid_exit],
86 PVE
::CLIHandler
::handle_cmd
($cmddef, "pvectl", $cmd, \
@ARGV, undef, $0);
94 pvectl - vzctl wrapper to manage OpenVZ containers
102 This is a small wrapper around vztl.
104 =include pve_copyright