[cbjchen,r=hopem]
Making sure libvirt daemon gets a unique host_uuid on every host.
This commit is contained in:
commit
9c4de964e2
|
@ -1,3 +1,5 @@
|
|||
import uuid
|
||||
|
||||
from charmhelpers.contrib.openstack import context
|
||||
from charmhelpers.core.host import service_running, service_start
|
||||
from charmhelpers.fetch import apt_install, filter_installed_packages
|
||||
|
@ -119,6 +121,7 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
|
|||
if config('disk-cachemodes'):
|
||||
ctxt['disk_cachemodes'] = config('disk-cachemodes')
|
||||
|
||||
ctxt['host_uuid'] = '%s' % uuid.uuid4()
|
||||
return ctxt
|
||||
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ auth_unix_rw = "none"
|
|||
# NB This default all-zeros UUID will not work. Replace
|
||||
# it with the output of the 'uuidgen' command and then
|
||||
# uncomment this entry
|
||||
#host_uuid = "00000000-0000-0000-0000-000000000000"
|
||||
host_uuid = "{{ host_uuid }}"
|
||||
|
||||
###################################################################
|
||||
# Keepalive protocol:
|
||||
|
|
|
@ -171,22 +171,38 @@ class NovaComputeContextTests(CharmTestCase):
|
|||
with patch.object(qplugin, '_ensure_packages'):
|
||||
self.assertEquals({}, qplugin())
|
||||
|
||||
def test_libvirt_bin_context_no_migration(self):
|
||||
@patch.object(context.uuid, 'uuid4')
|
||||
def test_libvirt_bin_context_no_migration(self, mock_uuid):
|
||||
self.test_config.set('enable-live-migration', False)
|
||||
mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertEquals({'libvirtd_opts': '-d', 'listen_tls': 0}, libvirt())
|
||||
|
||||
def test_libvirt_bin_context_migration_tcp_listen(self):
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d',
|
||||
'listen_tls': 0,
|
||||
'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'}, libvirt())
|
||||
|
||||
@patch.object(context.uuid, 'uuid4')
|
||||
def test_libvirt_bin_context_migration_tcp_listen(self, mock_uuid):
|
||||
self.test_config.set('enable-live-migration', True)
|
||||
mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertEquals(
|
||||
{'libvirtd_opts': '-d -l', 'listen_tls': 0}, libvirt())
|
||||
|
||||
def test_libvirt_disk_cachemodes(self):
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d -l',
|
||||
'listen_tls': 0,
|
||||
'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'}, libvirt())
|
||||
|
||||
@patch.object(context.uuid, 'uuid4')
|
||||
def test_libvirt_disk_cachemodes(self, mock_uuid):
|
||||
self.test_config.set('disk-cachemodes', 'file=unsafe,block=none')
|
||||
mock_uuid.return_value = 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7'
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertEquals(
|
||||
{'libvirtd_opts': '-d', 'listen_tls': 0,
|
||||
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d',
|
||||
'listen_tls': 0,
|
||||
'host_uuid': 'e46e530d-18ae-4a67-9ff0-e6e2ba7c60a7',
|
||||
'disk_cachemodes': 'file=unsafe,block=none'}, libvirt())
|
||||
|
||||
@patch.object(context.NeutronComputeContext, 'network_manager')
|
||||
|
|
Loading…
Reference in New Issue