def test_get_volume_uuid(self, mock_util): path = "/dev/sda1" expected_call = ["blkid", "-o", "export", path] mock_util.subp.return_value = (""" UUID=182e8e23-5322-46c9-a1b8-cf2c6a88f9f7 """, "") uuid = block.get_volume_uuid(path) mock_util.subp.assert_called_with(expected_call, capture=True) self.assertEqual(uuid, "182e8e23-5322-46c9-a1b8-cf2c6a88f9f7")
def setup_zipl(cfg, target): if platform.machine() != 's390x': return # assuming that below gives the "/" rootfs target_dev = block.get_devices_for_mp(target)[0] root_arg = None # not mapped rootfs, use UUID if 'mapper' in target_dev: root_arg = target_dev else: uuid = block.get_volume_uuid(target_dev) if uuid: root_arg = "UUID=%s" % uuid if not root_arg: msg = "Failed to identify root= for %s at %s." % (target, target_dev) LOG.warn(msg) raise ValueError(msg) zipl_conf = """ # This has been modified by the MAAS curtin installer [defaultboot] default=ubuntu [ubuntu] target = /boot image = /boot/vmlinuz ramdisk = /boot/initrd.img parameters = root=%s """ % root_arg futil.write_files( files={"zipl_conf": { "path": "/etc/zipl.conf", "content": zipl_conf }}, base_dir=target)