]>
Commit | Line | Data |
---|---|---|
f76a2828 DM |
1 | #!/usr/bin/perl -T |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use lib qw(. ..); | |
6 | ||
7 | use PVE::SafeSyslog; | |
8 | use PVE::Cluster; | |
9 | use PVE::INotify; | |
10 | use PVE::RPCEnvironment; | |
11 | use PVE::JSONSchema qw(get_standard_option); | |
12 | use PVE::CLIHandler; | |
13 | use PVE::API2::LXC; | |
14 | ||
15 | use Data::Dumper; | |
16 | ||
17 | use base qw(PVE::CLIHandler); | |
18 | ||
19 | $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; | |
20 | ||
21 | initlog ('pct'); | |
22 | ||
23 | die "please run as root\n" if $> != 0; | |
24 | ||
25 | PVE::INotify::inotify_init(); | |
26 | ||
27 | my $rpcenv = PVE::RPCEnvironment->init('cli'); | |
28 | $rpcenv->init_request(); | |
29 | $rpcenv->set_language($ENV{LANG}); | |
30 | $rpcenv->set_user('root@pam'); | |
31 | ||
32 | my $nodename = PVE::INotify::nodename(); | |
33 | ||
34 | my $upid_exit = sub { | |
35 | my $upid = shift; | |
36 | my $status = PVE::Tools::upid_read_status($upid); | |
37 | exit($status eq 'OK' ? 0 : -1); | |
38 | }; | |
39 | ||
40 | __PACKAGE__->register_method ({ | |
41 | name => 'test', | |
42 | path => 'test', | |
43 | method => 'GET', | |
44 | description => "Test only", | |
45 | parameters => { | |
46 | additionalProperties => 0, | |
47 | properties => { | |
48 | }, | |
49 | }, | |
50 | returns => { type => 'null' }, | |
51 | ||
52 | code => sub { | |
53 | my ($param) = @_; | |
54 | ||
55 | print "TEST\n"; | |
56 | ||
57 | return undef; | |
58 | }}); | |
59 | ||
60 | ||
61 | my $cmddef = { | |
9c2d4ce9 | 62 | #test => [ __PACKAGE__, 'test', [], {}, sub {} ], |
f76a2828 DM |
63 | list=> [ 'PVE::API2::LXC', 'vmlist', [], { node => $nodename }, sub { |
64 | my $res = shift; | |
65 | print Dumper($res); | |
66 | }], | |
67 | config => [ "PVE::API2::LXC", 'vm_config', ['vmid'], | |
68 | { node => $nodename }, sub { | |
69 | my $config = shift; | |
70 | foreach my $k (sort (keys %$config)) { | |
71 | next if $k eq 'digest'; | |
72 | my $v = $config->{$k}; | |
73 | if ($k eq 'description') { | |
74 | $v = PVE::Tools::encode_text($v); | |
75 | } | |
76 | print "$k: $v\n"; | |
77 | } | |
78 | }], | |
ec52ac21 DM |
79 | set => [ 'PVE::API2::LXC', 'update_vm', ['vmid'], { node => $nodename }], |
80 | ||
9c2d4ce9 | 81 | create => [ 'PVE::API2::LXC', 'create_vm', ['vmid', 'ostemplate'], { node => $nodename }, $upid_exit ], |
f76a2828 DM |
82 | |
83 | destroy => [ 'PVE::API2::LXC', 'destroy_vm', ['vmid'], | |
84 | { node => $nodename }, $upid_exit ], | |
85 | ||
86 | }; | |
87 | ||
88 | my $cmd = shift; | |
89 | ||
90 | PVE::CLIHandler::handle_cmd($cmddef, "pct", $cmd, \@ARGV, undef, $0); | |
91 | ||
92 | exit 0; | |
93 | ||
94 | __END__ | |
95 | ||
96 | =head1 NAME | |
97 | ||
98 | pct - Tool to manage Linux Containers on Proxmox VE | |
99 | ||
100 | =head1 SYNOPSIS | |
101 | ||
102 | =include synopsis | |
103 | ||
104 | =head1 DESCRIPTION | |
105 | ||
106 | Tool to manage linux containers. | |
107 | ||
108 | =include pve_copyright |