mirror of
https://git.proxmox.com/git/pve-client
synced 2025-10-04 12:04:36 +00:00
Add a basic implementation of remote list
Signed-off-by: René Jochum <r.jochum@proxmox.com>
This commit is contained in:
parent
2d0ebe218c
commit
e2ca543cee
@ -30,6 +30,29 @@ sub read_password {
|
|||||||
return PVE::PTY::read_password("Remote password: ")
|
return PVE::PTY::read_password("Remote password: ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__PACKAGE__->register_method ({
|
||||||
|
name => 'list',
|
||||||
|
path => 'list',
|
||||||
|
method => 'GET',
|
||||||
|
description => "List remotes from your config file.",
|
||||||
|
parameters => {
|
||||||
|
additionalProperties => 0,
|
||||||
|
},
|
||||||
|
returns => { type => 'null' },
|
||||||
|
code => sub {
|
||||||
|
my $config = PVE::APIClient::Config->new();
|
||||||
|
my $known_remotes = $config->remote_names;
|
||||||
|
|
||||||
|
printf("%10s %10s %10s %10s %100s\n", "Name", "Host", "Port", "Username", "Fingerprint");
|
||||||
|
for my $name (@$known_remotes) {
|
||||||
|
my $remote = $config->lookup_remote($name);
|
||||||
|
printf("%10s %10s %10s %10s %100s\n", $name, $remote->{'host'},
|
||||||
|
$remote->{'port'}, $remote->{'username'}, $remote->{'fingerprint'});
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}});
|
||||||
|
|
||||||
__PACKAGE__->register_method ({
|
__PACKAGE__->register_method ({
|
||||||
name => 'add',
|
name => 'add',
|
||||||
path => 'add',
|
path => 'add',
|
||||||
@ -114,6 +137,7 @@ __PACKAGE__->register_method ({
|
|||||||
our $cmddef = {
|
our $cmddef = {
|
||||||
add => [ __PACKAGE__, 'add', ['name', 'host', 'username']],
|
add => [ __PACKAGE__, 'add', ['name', 'host', 'username']],
|
||||||
remove => [ __PACKAGE__, 'remove', ['name']],
|
remove => [ __PACKAGE__, 'remove', ['name']],
|
||||||
|
list => [__PACKAGE__, 'list'],
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user