]> git.proxmox.com Git - pve-container.git/blame - src/pct
implement update_vm API (change hostname for now)
[pve-container.git] / src / pct
CommitLineData
f76a2828
DM
1#!/usr/bin/perl -T
2
3use strict;
4use warnings;
5use lib qw(. ..);
6
7use PVE::SafeSyslog;
8use PVE::Cluster;
9use PVE::INotify;
10use PVE::RPCEnvironment;
11use PVE::JSONSchema qw(get_standard_option);
12use PVE::CLIHandler;
13use PVE::API2::LXC;
14
15use Data::Dumper;
16
17use base qw(PVE::CLIHandler);
18
19$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
20
21initlog ('pct');
22
23die "please run as root\n" if $> != 0;
24
25PVE::INotify::inotify_init();
26
27my $rpcenv = PVE::RPCEnvironment->init('cli');
28$rpcenv->init_request();
29$rpcenv->set_language($ENV{LANG});
30$rpcenv->set_user('root@pam');
31
32my $nodename = PVE::INotify::nodename();
33
34my $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
61my $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
88my $cmd = shift;
89
90PVE::CLIHandler::handle_cmd($cmddef, "pct", $cmd, \@ARGV, undef, $0);
91
92exit 0;
93
94__END__
95
96=head1 NAME
97
98pct - Tool to manage Linux Containers on Proxmox VE
99
100=head1 SYNOPSIS
101
102=include synopsis
103
104=head1 DESCRIPTION
105
106Tool to manage linux containers.
107
108=include pve_copyright