diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 528740d8..209f2c7f 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -630,7 +630,8 @@ class HostIPContext(context.OSContextGenerator): ctxt = {} # Use the address used in the cloud-compute relation in templates for # this host - host_ip = get_relation_ip('cloud-compute') + host_ip = get_relation_ip('cloud-compute', + cidr_network=config('os-internal-network')) if host_ip: # NOTE: do not format this even for ipv6 (see bug 1499656) diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 01a8cd05..f7de45a2 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -316,7 +316,8 @@ def compute_joined(rid=None): # add the hostname configured locally to the relation. settings = { 'hostname': gethostname(), - 'private-address': get_relation_ip('cloud-compute'), + 'private-address': get_relation_ip( + 'cloud-compute', cidr_network=config('os-internal-network')), } if migration_enabled(): diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 31dae263..7844f651 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -432,7 +432,8 @@ class NovaComputeContextTests(CharmTestCase): self.get_relation_ip.return_value = '172.24.0.79' host_ip = context.HostIPContext() self.assertEqual({'host_ip': '172.24.0.79'}, host_ip()) - self.get_relation_ip.assert_called_with('cloud-compute') + self.get_relation_ip.assert_called_with('cloud-compute', + cidr_network=None) @patch('subprocess.call') def test_host_IP_context_ipv6(self, _call):