]> git.proxmox.com Git - pve-client.git/blame_incremental - pveclient
add stub for lxc commands
[pve-client.git] / pveclient
... / ...
CommitLineData
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use lib '/usr/share/pve-client';
6use lib '.';
7use Data::Dumper;
8
9use PVE::JSONSchema;
10use PVE::CLIHandler;
11
12use PVE::APIClient::LWP;
13use PVE::APIClient::Helpers;
14use PVE::APIClient::Commands::remote;
15use PVE::APIClient::Commands::lxc;
16
17use JSON;
18
19sub print_usage {
20
21 my $text = "pveclient usage:\n\n";
22
23 $text .= "pveclient remote <help|add|remove> {options}\n\n";
24
25 $text .= "pveclient lxc <help|create|destroy|...> {options}\n\n";
26
27 $text .= "pveclient <get/set/create/delete> <path> {options}\n\n";
28
29 print STDERR $text;
30
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);
39 my $param = PVE::JSONSchema::get_options($info->{parameters}, $args);
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
63my $cmd = shift || (print_usage() && exit(-1));
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";
79} elsif ($cmd eq 'lxc') {
80 PVE::APIClient::Commands::lxc->run_cli_handler();
81} elsif ($cmd eq 'remote') {
82 PVE::APIClient::Commands::remote->run_cli_handler();
83} else {
84 print_usage();
85}
86
87exit(0);