assert(d.ports)
servers.append({
'name': f"{spec.backend_service}.{rank}",
- 'ip': d.ip or resolve_ip(str(d.hostname)),
+ 'ip': d.ip or resolve_ip(self.mgr.inventory.get_addr(str(d.hostname))),
'port': d.ports[0],
})
else:
servers = [
{
'name': d.name(),
- 'ip': d.ip or resolve_ip(str(d.hostname)),
+ 'ip': d.ip or resolve_ip(self.mgr.inventory.get_addr(str(d.hostname))),
'port': d.ports[0],
} for d in daemons if d.ports
]
# other_ips in conf file and converter to ips
if host in hosts:
hosts.remove(host)
- other_ips = [resolve_ip(h) for h in hosts]
+ other_ips = [resolve_ip(self.mgr.inventory.get_addr(h)) for h in hosts]
keepalived_conf = self.mgr.template.render(
'services/ingress/keepalived.conf.j2',
'interface': interface,
'state': state,
'other_ips': other_ips,
- 'host_ip': resolve_ip(host),
+ 'host_ip': resolve_ip(self.mgr.inventory.get_addr(host)),
}
)
if not spec:
logger.warning('No ServiceSpec found for %s', dd)
continue
- ip = utils.resolve_ip(dd.hostname)
+ ip = utils.resolve_ip(self.mgr.inventory.get_addr(dd.hostname))
# IPv6 URL encoding requires square brackets enclosing the ip
if type(ip_address(ip)) is IPv6Address:
ip = f'[{ip}]'
from orchestrator._interface import DaemonDescription
+class FakeInventory:
+ def get_addr(self, name: str) -> str:
+ return '1.2.3.4'
+
+
class FakeMgr:
def __init__(self):
self.config = ''
self.mon_command = MagicMock(side_effect=self._check_mon_command)
self.template = MagicMock()
self.log = MagicMock()
+ self.inventory = FakeInventory()
def _check_mon_command(self, cmd_dict, inbuf=None):
prefix = cmd_dict.get('prefix')