def do_ti(install_profile, swap_dump): '''Call the ti module to create the disk layout, create a zfs root pool, create zfs volumes for swap and dump, and to create a be. ''' diskname = install_profile.disk.name logging.debug("Diskname: %s", diskname) mesg = "Preparing disk for %(release)s installation" % RELEASE try: (inst_device, inst_device_size) = \ install_profile.disk.get_install_dev_name_and_size() # The installation size we provide already included the required # swap size (swap_type, swap_size, dump_type, dump_size) = \ swap_dump.calc_swap_dump_size(ti_utils.get_minimum_size(swap_dump), inst_device_size, swap_included=True) tgt_disk = install_profile.disk.to_tgt() tgt.create_disk_target(tgt_disk, False) logging.debug("Completed create_disk_target") INSTALL_STATUS.update(InstallStatus.TI, 20, mesg) rootpool_name = install_profile.disk.get_install_root_pool() rpool = tgt.Zpool(rootpool_name, inst_device) tgt.create_zfs_root_pool(rpool) logging.debug("Completed create_zfs_root_pool") INSTALL_STATUS.update(InstallStatus.TI, 40, mesg) create_swap = False if (swap_type == ti_utils.SwapDump.ZVOL): create_swap = True create_dump = False if (dump_type == ti_utils.SwapDump.ZVOL): create_dump = True logging.debug("Create swap %s Swap size: %s", create_swap, swap_size) logging.debug("Create dump %s Dump size: %s", create_dump, dump_size) tgt.create_zfs_volume(rootpool_name, create_swap, swap_size, create_dump, dump_size) logging.debug("Completed create swap and dump") INSTALL_STATUS.update(InstallStatus.TI, 70, mesg) zfs_datasets = () for ds in reversed( ZFS_SHARED_FS): # must traverse it in reversed order zd = tgt.ZFSDataset(mountpoint=ds) zfs_datasets += (zd, ) tgt.create_be_target(rootpool_name, INIT_BE_NAME, INSTALLED_ROOT_DIR, zfs_datasets) logging.debug("Completed create_be_target") INSTALL_STATUS.update(InstallStatus.TI, 100, mesg) except TypeError, te: logging.error("Failed to initialize disk") logging.exception(te) raise ti_utils.InstallationError
def do_ti(install_profile, swap_dump): '''Call the ti module to create the disk layout, create a zfs root pool, create zfs volumes for swap and dump, and to create a be. ''' for disk in install_profile.disks: diskname = disk.name logging.debug("Diskname: %s", diskname) mesg = "Preparing disks for %(release)s installation" % RELEASE try: inst_device_size = \ install_profile.estimate_pool_size() zfs_datasets = () if not install_profile.install_to_pool: # The installation size we provide already included the required # swap size (swap_type, swap_size, dump_type, dump_size) = \ swap_dump.calc_swap_dump_size(ti_utils.get_minimum_size(swap_dump), inst_device_size, swap_included=True) for disk in install_profile.disks: tgt_disk = disk.to_tgt() tgt.create_disk_target(tgt_disk, False) logging.debug("Completed create_disk_target for disk %s", str(disk)) logging.debug("Completed create_disk_target") INSTALL_STATUS.update(InstallStatus.TI, 20, mesg) rootpool_name = install_profile.disks[0].get_install_root_pool() create_root_pool(install_profile) logging.debug("Completed create_root_pool") INSTALL_STATUS.update(InstallStatus.TI, 40, mesg) create_swap = False if (swap_type == ti_utils.SwapDump.ZVOL): create_swap = True create_dump = False if (dump_type == ti_utils.SwapDump.ZVOL): create_dump = True logging.debug("Create swap %s Swap size: %s", create_swap, swap_size) logging.debug("Create dump %s Dump size: %s", create_dump, dump_size) tgt.create_zfs_volume(rootpool_name, create_swap, swap_size, create_dump, dump_size) logging.debug("Completed create swap and dump") INSTALL_STATUS.update(InstallStatus.TI, 70, mesg) for ds in reversed(ZFS_SHARED_FS): # must traverse it in reversed order zd = tgt.ZFSDataset(mountpoint=ds) zfs_datasets += (zd,) logging.debug("Adding dataset ZFSDataset(%s %s %s %s %s %s %s)", zd.name, zd.mountpoint, zd.be_name, zd.zfs_swap, zd.swap_size, zd.zfs_dump, zd.dump_size) else: rootpool_name = install_profile.pool_name # We don't want to create dump device, but at least provide default config exec_cmd(["/usr/sbin/dumpadm", "-d", "none" ], "setting dump device to none") if install_profile.overwrite_boot_configuration: # We don't use grub, but it's still not completely axed from installer. # So at least pretend to have /boot/grub exec_cmd(["/usr/bin/mkdir", "-p", "/%s" % (rootpool_name) ], "creating /%s directory" % (rootpool_name)) # We set rpool mounpoint to none => /rpool to umount /rpool if it was mounted exec_cmd(["/usr/sbin/zfs", "set", "mountpoint=none", \ rootpool_name ], "setting %s mountpoint to none" % (rootpool_name)) exec_cmd(["/usr/sbin/zfs", "set", "mountpoint=/%s" % (rootpool_name), \ rootpool_name ], "setting %s mountpoint to /%s" \ % (rootpool_name, rootpool_name)) exec_cmd(["/usr/bin/mkdir", "-p", "/%s/boot/grub" % (rootpool_name) ], "creating grub menu directory") logging.debug("rootpol_name %s, init_be_name %s, INSTALLED_ROOT_DIR %s", rootpool_name, install_profile.be_name, INSTALLED_ROOT_DIR) tgt.create_be_target(rootpool_name, install_profile.be_name, INSTALLED_ROOT_DIR, zfs_datasets) logging.debug("Completed create_be_target") INSTALL_STATUS.update(InstallStatus.TI, 100, mesg) except TypeError, te: logging.error("Failed to initialize disk") logging.exception(te) raise ti_utils.InstallationError