Make cloud-compute hostname same as nova.conf host
To avoid inconsistency between the fqdn added to the nova.conf 'host' config and the hostname set of the cloud-compute relation we need to ensure that both are using the same means of determining the host fqdn. This is so that the when nova-cloud-controller charm populates ssh known_hosts and shares with all computes it definitely contains an entry for the nova.conf host config since this is sometimes used as part of a live-migration. Change-Id: Iddcf3fdacf7e7374b57b628edf1e6d0df4da082c Closes-Bug: #2089781
This commit is contained in:
parent
7c60a92414
commit
25a0aba59d
@ -438,7 +438,7 @@ def compute_joined(rid=None):
|
||||
# record so won't get scanned based on private-address which is an IP
|
||||
# add the hostname configured locally to the relation.
|
||||
settings = {
|
||||
'hostname': gethostname(),
|
||||
'hostname': NovaComputeHostInfoContext()().get('host_fqdn'),
|
||||
'private-address': get_relation_ip(
|
||||
'migration', cidr_network=config('libvirt-migration-network')),
|
||||
}
|
||||
|
@ -597,8 +597,10 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
'availability_zone': 'az1',
|
||||
})
|
||||
|
||||
@patch.object(NovaComputeHostInfoContext, '__call__')
|
||||
@patch('nova_compute_context.config')
|
||||
def test_compute_joined_with_ssh_migration(self, config):
|
||||
def test_compute_joined_with_ssh_migration(self, config, mock_get_fqdn):
|
||||
mock_get_fqdn.return_value = {'host_fqdn': 'testserver.foreal'}
|
||||
config.side_effect = self.test_config.get
|
||||
self.migration_enabled.return_value = True
|
||||
self.test_config.set('migration-auth-type', 'ssh')
|
||||
@ -608,7 +610,7 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
'relation_id': None,
|
||||
'ssh_public_key': 'foo',
|
||||
'migration_auth_type': 'ssh',
|
||||
'hostname': 'testserver',
|
||||
'hostname': 'testserver.foreal',
|
||||
'private-address': '10.0.0.50',
|
||||
})
|
||||
hooks.compute_joined(rid='cloud-compute:2')
|
||||
@ -616,15 +618,17 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
'relation_id': 'cloud-compute:2',
|
||||
'ssh_public_key': 'foo',
|
||||
'migration_auth_type': 'ssh',
|
||||
'hostname': 'testserver',
|
||||
'hostname': 'testserver.foreal',
|
||||
'private-address': '10.0.0.50',
|
||||
})
|
||||
self.get_relation_ip.assert_called_with(
|
||||
'migration', cidr_network=None
|
||||
)
|
||||
|
||||
@patch.object(NovaComputeHostInfoContext, '__call__')
|
||||
@patch('nova_compute_context.config')
|
||||
def test_compute_joined_with_resize(self, config):
|
||||
def test_compute_joined_with_resize(self, config, mock_get_fqdn):
|
||||
mock_get_fqdn.return_value = {'host_fqdn': 'testserver.foreal'}
|
||||
config.side_effect = self.test_config.get
|
||||
self.migration_enabled.return_value = False
|
||||
self.test_config.set('enable-resize', True)
|
||||
@ -633,14 +637,14 @@ class NovaComputeRelationsTests(CharmTestCase):
|
||||
self.relation_set.assert_called_with(**{
|
||||
'relation_id': None,
|
||||
'nova_ssh_public_key': 'bar',
|
||||
'hostname': 'testserver',
|
||||
'hostname': 'testserver.foreal',
|
||||
'private-address': '10.0.0.50',
|
||||
})
|
||||
hooks.compute_joined(rid='cloud-compute:2')
|
||||
self.relation_set.assert_called_with(**{
|
||||
'relation_id': 'cloud-compute:2',
|
||||
'nova_ssh_public_key': 'bar',
|
||||
'hostname': 'testserver',
|
||||
'hostname': 'testserver.foreal',
|
||||
'private-address': '10.0.0.50',
|
||||
})
|
||||
self.get_relation_ip.assert_called_with(
|
||||
|
Loading…
Reference in New Issue
Block a user