]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/remote.pm
5d04e3a87cc21e73793dfe907c9e359e0f305030
1 package PVE
::APIClient
::Commands
::remote
;
6 use PVE
::JSONSchema
qw(get_standard_option);
7 use PVE
::APIClient
::Config
;
11 use PVE
::APIClient
::LWP
;
14 use base
qw(PVE::CLIHandler);
17 return PVE
::PTY
::read_password
("Remote password: ")
20 __PACKAGE__-
>register_method ({
24 description
=> "List remotes from your config file.",
26 additionalProperties
=> 0,
28 returns
=> { type
=> 'null' },
30 my $config = PVE
::APIClient
::Config-
>new();
31 my $known_remotes = $config->remote_names;
33 printf("%10s %10s %10s %10s %100s\n", "Name", "Host", "Port", "Username", "Fingerprint");
34 for my $name (@$known_remotes) {
35 my $remote = $config->lookup_remote($name);
36 printf("%10s %10s %10s %10s %100s\n", $name, $remote->{'host'},
37 $remote->{'port'}, $remote->{'username'}, $remote->{'fingerprint'});
43 __PACKAGE__-
>register_method ({
47 description
=> "Add a remote to your config file.",
49 additionalProperties
=> 0,
51 name
=> get_standard_option
('pveclient-remote-name', { completion
=> sub {} }),
53 description
=> "The host.",
58 description
=> "The username.",
62 description
=> "The users password",
66 description
=> "The port",
73 returns
=> { type
=> 'null'},
77 my $config = PVE
::APIClient
::Config-
>new();
78 my $known_remotes = $config->remotes;
80 if (exists($known_remotes->{$param->{name
}})) {
81 die "Remote \"$param->{name}\" exists, remove it first\n";
85 my $api = PVE
::APIClient
::LWP-
>new(
86 username
=> $param->{username
},
87 password
=> $param->{password
},
88 host
=> $param->{host
},
89 port
=> $param->{port
} // 8006,
90 manual_verification
=> 1,
91 register_fingerprint_cb
=> sub {
98 $config->add_remote($param->{name
}, $param->{host
}, $param->{port
} // 8006,
99 $last_fp, $param->{username
}, $param->{password
});
105 __PACKAGE__-
>register_method ({
109 description
=> "Removes a remote from your config file.",
111 additionalProperties
=> 0,
113 name
=> get_standard_option
('pveclient-remote-name'),
116 returns
=> { type
=> 'null'},
120 my $config = PVE
::APIClient
::Config-
>new();
121 $config->remove_remote($param->{name
});
128 add
=> [ __PACKAGE__
, 'add', ['name', 'host', 'username']],
129 remove
=> [ __PACKAGE__
, 'remove', ['name']],
130 list
=> [__PACKAGE__
, 'list'],