]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/APIClient/Commands/remote.pm
use packages from PVE::APIClient
[pve-client.git] / PVE / APIClient / Commands / remote.pm
index e8c876a7259921cff5f83452537f828e66985063..8deac33dc61849c4cc42e707ae30a40780086e8a 100644 (file)
@@ -3,16 +3,16 @@ package PVE::APIClient::Commands::remote;
 use strict;
 use warnings;
 
-use PVE::JSONSchema qw(get_standard_option);
-use PVE::Tools qw(extract_param);
+use PVE::APIClient::JSONSchema qw(get_standard_option);
+use PVE::APIClient::Tools qw(extract_param);
 use PVE::APIClient::Config;
 
-use PVE::CLIHandler;
+use PVE::APIClient::CLIHandler;
 
 use PVE::APIClient::LWP;
-use PVE::PTY ();
+use PVE::APIClient::PTY;
 
-use base qw(PVE::CLIHandler);
+use base qw(PVE::APIClient::CLIHandler);
 
 sub read_password {
    return PVE::PTY::read_password("Remote password: ")
@@ -32,9 +32,10 @@ __PACKAGE__->register_method ({
 
        printf("%10s %10s %10s %10s %100s\n", "Name", "Host", "Port", "Username", "Fingerprint");
        for my $name (keys %{$config->{ids}}) {
-           my $remote = $config->{ids}->{$name};
-           printf("%10s %10s %10s %10s %100s\n", $name, $remote->{'host'},
-                  $remote->{'port'} // '-', $remote->{'username'}, $remote->{'fingerprint'} // '-');
+           my $data = $config->{ids}->{$name};
+           next if $data->{type} ne 'remote';
+           printf("%10s %10s %10s %10s %100s\n", $name, $data->{'host'},
+                  $data->{'port'} // '-', $data->{'username'}, $data->{'fingerprint'} // '-');
        }
 
        return undef;
@@ -45,7 +46,7 @@ __PACKAGE__->register_method ({
     path => 'add',
     method => 'POST',
     description => "Add a remote to your config file.",
-    parameters => PVE::APIClient::Config->createSchema(1),
+    parameters => PVE::APIClient::RemoteConfig->createSchema(1),
     returns => { type => 'null'},
     code => sub {
        my ($param) = @_;
@@ -61,9 +62,14 @@ __PACKAGE__->register_method ({
 
        my $last_fp = 0;
 
+       my $password = $param->{password};
+       if (!defined($password)) {
+           $password = PVE::PTY::read_password("Remote password: ");
+       }
+
        my $setup = {
            username                => $param->{username},
-           password                => $param->{password},
+           password                => $password,
            host                    => $param->{host},
            port                    => $param->{port} // 8006,
        };
@@ -98,7 +104,7 @@ __PACKAGE__->register_method ({
     path => 'update',
     method => 'PUT',
     description => "Update a remote configuration.",
-    parameters => PVE::APIClient::Config->updateSchema(1),
+    parameters => PVE::APIClient::RemoteConfig->updateSchema(1),
     returns => { type => 'null'},
     code => sub {
        my ($param) = @_;
@@ -121,7 +127,7 @@ __PACKAGE__->register_method ({
 
        if ($delete) {
            my $options = $plugin->private()->{options}->{'remote'};
-           foreach my $k (PVE::Tools::split_list($delete)) {
+           foreach my $k (PVE::APIClient::Tools::APIClient::split_list($delete)) {
                my $d = $options->{$k} ||
                    die "no such option '$k'\n";
                die "unable to delete required option '$k'\n"