]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/remote.pm
1 package PVE
::APIClient
::Commands
::remote
;
6 use PVE
::JSONSchema
qw(register_standard_option get_standard_option);
7 use PVE
::APIClient
::Config
;
11 use PVE
::APIClient
::LWP
;
14 use base
qw(PVE::CLIHandler);
16 my $complete_remote_name = sub {
18 my $config = PVE
::APIClient
::Config-
>new();
19 return $config->remote_names;
22 register_standard_option
('pveclient-remote-name', {
23 description
=> "The name of the remote.",
26 completion
=> $complete_remote_name,
30 return PVE
::PTY
::read_password
("Remote password: ")
33 __PACKAGE__-
>register_method ({
37 description
=> "Add a remote to your config file.",
39 additionalProperties
=> 0,
41 name
=> get_standard_option
('pveclient-remote-name', { completion
=> sub {} }),
43 description
=> "The host.",
48 description
=> "The username.",
52 description
=> "The users password",
56 description
=> "The port",
63 returns
=> { type
=> 'null'},
67 my $config = PVE
::APIClient
::Config-
>new();
68 my $known_remotes = $config->remotes;
70 if (exists($known_remotes->{$param->{name
}})) {
71 die "Remote \"$param->{name}\" exists, remove it first\n";
75 my $api = PVE
::APIClient
::LWP-
>new(
76 username
=> $param->{username
},
77 password
=> $param->{password
},
78 host
=> $param->{host
},
79 port
=> $param->{port
} // 8006,
80 manual_verification
=> 1,
81 register_fingerprint_cb
=> sub {
88 $config->add_remote($param->{name
}, $param->{host
}, $param->{port
} // 8006,
89 $last_fp, $param->{username
}, $param->{password
});
95 __PACKAGE__-
>register_method ({
99 description
=> "Removes a remote from your config file.",
101 additionalProperties
=> 0,
103 name
=> get_standard_option
('pveclient-remote-name'),
106 returns
=> { type
=> 'null'},
115 add
=> [ __PACKAGE__
, 'add', ['name', 'host', 'username']],
116 remove
=> [ __PACKAGE__
, 'remove', ['name']],