add stub for lxc commands
[pve-client.git] / pveclient
CommitLineData
29505e2c
DM
1#!/usr/bin/perl
2
3use strict;
4use warnings;
565bbc73 5use lib '/usr/share/pve-client';
c5111270 6use lib '.';
29505e2c
DM
7use Data::Dumper;
8
a04fd959 9use PVE::JSONSchema;
565bbc73
DM
10use PVE::CLIHandler;
11
29505e2c
DM
12use PVE::APIClient::LWP;
13use PVE::APIClient::Helpers;
565bbc73 14use PVE::APIClient::Commands::remote;
adf285bf 15use PVE::APIClient::Commands::lxc;
565bbc73 16
29505e2c
DM
17use JSON;
18
19sub print_usage {
20
c5111270
DM
21 my $text = "pveclient usage:\n\n";
22
23 $text .= "pveclient remote <help|add|remove> {options}\n\n";
24
adf285bf
DM
25 $text .= "pveclient lxc <help|create|destroy|...> {options}\n\n";
26
c5111270
DM
27 $text .= "pveclient <get/set/create/delete> <path> {options}\n\n";
28
29 print STDERR $text;
30
29505e2c
DM
31}
32
33sub call_method {
34 my ($path, $method, $args) = @_;
35
36 die "missing API path\n" if !defined($path);
37
38 my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
a04fd959 39 my $param = PVE::JSONSchema::get_options($info->{parameters}, $args);
29505e2c
DM
40 print Dumper($param);
41
42 die "implement me";
43}
44
45# NOTE: This binary is just a placeholer - nothing implemented so far!
46
47#my $hostname = 'localhost';
48#my $username = 'root@pam';
49#
50#my $conn = PVE::APIClient::LWP->new(
51# username => $username,
52# #password => 'yourpassword',
53# #ticket => $ticket,
54# #csrftoken => $csrftoken,
55# host => $hostname,
56# # allow manual fingerprint verification
57# manual_verification => 1,
58# );
59
60#my $res = $conn->get("/", {});
61#print to_json($res, { pretty => 1, canonical => 1});
62
c5111270 63my $cmd = shift || (print_usage() && exit(-1));
29505e2c
DM
64
65if ($cmd eq 'get') {
66 my $method = 'GET';
67 my $path;
68 if (scalar(@ARGV) && $ARGV[0] !~ m/^\-/) {
69 $path = shift @ARGV;
70 }
71 my $res = call_method($path, $method, \@ARGV);
72 die "implement me";
73} elsif ($cmd eq 'set') {
74 die "implement me";
75} elsif ($cmd eq 'create') {
76 die "implement me";
77} elsif ($cmd eq 'delete') {
78 die "implement me";
adf285bf
DM
79} elsif ($cmd eq 'lxc') {
80 PVE::APIClient::Commands::lxc->run_cli_handler();
565bbc73
DM
81} elsif ($cmd eq 'remote') {
82 PVE::APIClient::Commands::remote->run_cli_handler();
29505e2c
DM
83} else {
84 print_usage();
85}
86
565bbc73 87exit(0);