Add support for cloud-init on LXC instances
Images that use cloud-init are not correctly initialized when using libvirt LXC nova driver. One way cloud-init checks if the OpenStack datasource should be used is by checking DMI data that is meaningful for virtual machines but not for containers. Another way cloud-init is using is to check if the 'product_name' env variable for init process (PID 1) is "OpenStack Nova" [1][2]. This commit add that env variable to the instance when the driver is LXC. [1] https://cloudinit.readthedocs.io/en/latest/topics/datasources/openstack.html [2] https://git.launchpad.net/cloud-init/tree/tools/ds-identify#n974 Closes-Bug: 1834506 Change-Id: I2d0a4461081f5284d16df73a783cb7dae3ff0ef5 Signed-off-by: Miguel Herranz <miguel@midokura.com>
This commit is contained in:
parent
b3aed10ee0
commit
8f975bc828
@ -2414,6 +2414,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
self.assertEqual("/sbin/init", cfg.os_init_path)
|
||||
self.assertEqual("console=tty0 console=ttyS0 console=hvc0",
|
||||
cfg.os_cmdline)
|
||||
self.assertEqual("OpenStack Nova", cfg.os_init_env['product_name'])
|
||||
self.assertIsNone(cfg.os_root)
|
||||
self.assertEqual(3, len(cfg.devices))
|
||||
self.assertIsInstance(cfg.devices[0],
|
||||
@ -8665,6 +8666,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||
check = [
|
||||
(lambda t: t.find('.').get('type'), 'lxc'),
|
||||
(lambda t: t.find('./os/type').text, 'exe'),
|
||||
(lambda t: t.find("./os/initenv[@name='product_name']").text,
|
||||
'OpenStack Nova'),
|
||||
(lambda t: t.find('./devices/filesystem/target').get('dir'), '/')]
|
||||
|
||||
for i, (check, expected_result) in enumerate(check):
|
||||
|
@ -5068,6 +5068,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
elif virt_type == "lxc":
|
||||
guest.os_init_path = "/sbin/init"
|
||||
guest.os_cmdline = CONSOLE
|
||||
guest.os_init_env["product_name"] = "OpenStack Nova"
|
||||
elif virt_type == "uml":
|
||||
guest.os_kernel = "/usr/bin/linux"
|
||||
guest.os_root = root_device_name
|
||||
|
4
releasenotes/notes/bug-1834506-7c6875bbdc32ab0b.yaml
Normal file
4
releasenotes/notes/bug-1834506-7c6875bbdc32ab0b.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
LXC instances now support cloud-init.
|
Loading…
Reference in New Issue
Block a user