From 820c1545bf4e0735101bd792fe068a8b70b18066 Mon Sep 17 00:00:00 2001 From: Anton Todorov Date: Wed, 13 May 2026 17:18:05 +0300 Subject: [PATCH] F #7675: option to configure FQDN for remote_addr So the resolver on the host will provide the IP address for the opennebula-gate service. This way, with DNS view or a line in /etc/hosts the tproxy service will pick the desired IP to connect to the opennebula-gate --- src/vnm_mad/remotes/OpenNebulaNetwork.conf | 4 +++- src/vnm_mad/remotes/lib/tproxy.rb | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/vnm_mad/remotes/OpenNebulaNetwork.conf b/src/vnm_mad/remotes/OpenNebulaNetwork.conf index 8ac3804fdb..72d3881a53 100644 --- a/src/vnm_mad/remotes/OpenNebulaNetwork.conf +++ b/src/vnm_mad/remotes/OpenNebulaNetwork.conf @@ -124,7 +124,9 @@ # - :networks: [0, vnet1] # # The simplest example of an OneGate proxy config applied to all VNETs: +# When a FQDN is configured for :remote_addr:, the host resolver will resolve +# it to an IP. # :tproxy: # - :service_port: 5030 -# :remote_addr: 10.11.12.13 # HA VIP +# :remote_addr: 10.11.12.13 # HA VIP or FQDN # :remote_port: 5030 diff --git a/src/vnm_mad/remotes/lib/tproxy.rb b/src/vnm_mad/remotes/lib/tproxy.rb index 1d45c38b8b..8e2fbd70ff 100644 --- a/src/vnm_mad/remotes/lib/tproxy.rb +++ b/src/vnm_mad/remotes/lib/tproxy.rb @@ -44,7 +44,20 @@ def self.setup_tproxy(nic, direction) && (nets & nic.slice(:network, :network_id).values.map(&:to_s)).empty? next if conf[:service_port].nil? - next if conf[:remote_addr].nil? || conf[:remote_addr] !~ Resolv::IPv4::Regex + next if conf[:remote_addr].nil? || conf[:remote_addr].to_s.strip.empty? + + unless conf[:remote_addr] =~ Resolv::IPv4::Regex + begin + remote_ip = Resolv.getaddress(conf[:remote_addr]) + next unless remote_ip =~ Resolv::IPv4::Regex + + OpenNebula::DriverLogger.log_info "Resolved remote_addr #{conf[:remote_addr]} to #{remote_ip}" + conf[:remote_addr] = remote_ip + rescue Resolv::ResolvError + OpenNebula::DriverLogger.log_warning "Can't resolve remote_addr #{conf[:remote_addr]}. Skipping." + next + end + end next if conf[:remote_port].nil? opts = {