[pve-devel] [PATCH cluster 3/4] remote: add option/completion
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Apr 13 14:16:27 CEST 2021
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
data/PVE/RemoteConfig.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/data/PVE/RemoteConfig.pm b/data/PVE/RemoteConfig.pm
index 7c395ba..563e5c1 100644
--- a/data/PVE/RemoteConfig.pm
+++ b/data/PVE/RemoteConfig.pm
@@ -5,7 +5,7 @@ use warnings;
use PVE::APIClient::LWP;
use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
-use PVE::JSONSchema qw(get_standard_option);
+use PVE::JSONSchema qw(get_standard_option register_standard_option);
use PVE::Tools;
use PVE::SectionConfig;
@@ -33,6 +33,11 @@ my $defaultData = {
},
};
+register_standard_option('pve-remote-cluster', {
+ description => "A remote cluster identifier.",
+ type => 'string', format => 'pve-node',
+});
+
sub private {
return $defaultData;
}
@@ -180,7 +185,6 @@ sub get_remote_info {
my $api_token = $cluster_info->{token} // $api_node->{token};
my $conn_args = {
- username => 'root at pam',
protocol => 'https',
host => $api_node->{endpoint},
apitoken => $api_token,
@@ -213,6 +217,18 @@ sub get_remote_info {
return ($res, $conn_args);
}
+sub complete_remote_cluster {
+ my $conf = PVE::RemoteConfig->new();
+ my $sections = $conf->{ids};
+ return [ grep { $sections->{$_}->{type} eq 'pvecluster' } keys %$sections ];
+}
+
+sub complete_remote_node {
+ my $conf = PVE::RemoteConfig->new();
+ my $sections = $conf->{ids};
+ return [ grep { $sections->{$_}->{type} eq 'pvenode' } keys %$sections ];
+}
+
package PVE::RemoteConfig::Cluster;
use PVE::RemoteConfig;
--
2.20.1
More information about the pve-devel
mailing list