Signed-off-by: Fabian Grünbichler <f.gruenbich...@proxmox.com> --- PVE/API2/Nodes.pm | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index ba6621c6..b30d0739 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -222,6 +222,7 @@ __PACKAGE__->register_method ({ my ($param) = @_; my $result = [ + { name => 'addr' }, { name => 'aplinfo' }, { name => 'apt' }, { name => 'capabilities' }, @@ -2183,6 +2184,75 @@ __PACKAGE__->register_method ({ return undef; }}); +__PACKAGE__->register_method ({ + name => 'get_node_addr', + path => 'addr', + method => 'GET', + proxyto => 'node', + permissions => { + check => ['perm', '/', [ 'Sys.Audit' ]], + }, + description => "Get the content of /etc/hosts.", + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + cidr => { + type => 'string', + format => 'CIDR', + format_description => 'CIDR', + description => 'Extra network for which to retrieve local address(es).', + optional => 1, + }, + }, + }, + returns => { + type => 'object', + properties => { + default => { + type => 'string', + description => 'Default node IP.', + format => 'ip', + }, + migration => { + type => 'array', + items => { + type => 'string', + description => 'Migration network IP(s).', + format => 'ip', + }, + optional => 1, + }, + extra => { + type => 'array', + items => { + type => 'string', + description => 'Extra network IP(s).', + format => 'ip', + }, + optional => 1, + }, + }, + }, + code => sub { + my ($param) = @_; + + my $data = {}; + + my $default = PVE::Cluster::remote_node_ip($param->{node}); + + my $dc_conf = cfs_read_file('datacenter.cfg'); + my $migration = $dc_conf->{migration}->{network}; + + $data->{default} = $default if defined($default); + $data->{migration} = PVE::Network::get_local_ip_from_cidr($migration, 1) + if $migration; + $data->{extra} = PVE::Network::get_local_ip_from_cidr($param->{cidr}, 1) + if $param->{cidr}; + + return $data; + }}); + # bash completion helper sub complete_templet_repo { -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel