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. ''' 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(install_profile, screen, update_status_func, quit_event, time_change_event): '''Installation engine for text installer. Raises InstallationError for any error occurred during install. ''' # # The following information is needed for installation. # Make sure they are provided before even starting # # locale locale = install_profile.system.locale logging.debug("default locale: %s", locale) # timezone timezone = install_profile.system.tz_timezone logging.debug("time zone: %s", timezone) # hostname hostname = install_profile.system.hostname logging.debug("hostname: %s", hostname) ulogin = None user_home_dir = "" root_user = install_profile.users[0] root_pass = root_user.password reg_user = install_profile.users[1] ureal_name = reg_user.real_name ulogin = reg_user.login_name upass = reg_user.password logging.debug("Root password: %s", root_pass) if ulogin: user_home_dir = "/export/home/" + ulogin ZFS_SHARED_FS.insert(0, user_home_dir) logging.debug("User real name: %s", ureal_name) logging.debug("User login: %s", ulogin) logging.debug("User password: %s", upass) (inst_device, inst_device_size) = \ install_profile.disk.get_install_dev_name_and_size() logging.debug("Installation Device Name: %s", inst_device) logging.debug("Installation Device Size: %sMB", inst_device_size) swap_dump = ti_utils.SwapDump() min_inst_size = ti_utils.get_minimum_size(swap_dump) logging.debug("Minimum required size: %sMB", min_inst_size) if (inst_device_size < min_inst_size): logging.error("Size of device specified for installation " "is too small") logging.error("Size of install device: %sMB", inst_device_size) logging.error("Minimum required size: %sMB", min_inst_size) raise ti_utils.InstallationError recommended_size = ti_utils.get_recommended_size(swap_dump) logging.debug("Recommended size: %sMB", recommended_size) if (inst_device_size < recommended_size): # Warn users that their install target size is not optimal # Just log the warning, but continue with the installation. logging.warning("Size of device specified for installation is " "not optimal") logging.warning("Size of install device: %sMB", inst_device_size) logging.warning("Recommended size: %sMB", recommended_size) # Validate the value specified for timezone if not tz_isvalid(timezone): logging.error("Timezone value specified (%s) is not valid", timezone) raise ti_utils.InstallationError # Compute the time to set here. It will be set after the rtc # command is run, if on x86. install_time = datetime.datetime.now() + install_profile.system.time_offset if platform.processor() == "i386": # # At this time, the /usr/sbin/rtc command does not work in alternate # root. It hard codes to use /etc/rtc_config. # Therefore, we set the value for rtc_config in the live environment # so it will get copied over to the alternate root. # exec_cmd([RTC_CMD, "-z", timezone], "set timezone") exec_cmd([RTC_CMD, "-c"], "set timezone") # # Set the system time to the time specified by the user # The value to set the time to is computed before the "rtc" commands. # This is required because rtc will mess up the computation of the # time to set. The rtc command must be run before the command # to set time. Otherwise, the time that we set will be overwritten # after running /usr/sbin/rtc. # cmd = ["/usr/bin/date", install_time.strftime("%m%d%H%M%y")] exec_cmd(cmd, "set system time") time_change_event.set() global INSTALL_STATUS INSTALL_STATUS = InstallStatus(screen, update_status_func, quit_event) rootpool_name = install_profile.disk.get_install_root_pool() cleanup_existing_install_target(install_profile, inst_device) do_ti(install_profile, swap_dump) do_transfer() ict_mesg = "Completing transfer process" INSTALL_STATUS.update(InstallStatus.ICT, 0, ict_mesg) # Save the timezone in the installed root's /etc/default/init file ti_utils.save_timezone_in_init(INSTALLED_ROOT_DIR, timezone) # If swap was created, add appropriate entry to <target>/etc/vfstab swap_device = swap_dump.get_swap_device(rootpool_name) logging.debug("Swap device: %s", swap_device) ti_utils.setup_etc_vfstab_for_swap(swap_device, INSTALLED_ROOT_DIR) try: run_ICTs(install_profile, hostname, ict_mesg, inst_device, locale, root_pass, ulogin, upass, ureal_name, rootpool_name) finally: post_install_cleanup(install_profile, rootpool_name) INSTALL_STATUS.update(InstallStatus.ICT, 100, ict_mesg)
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
def do_ti_install(install_profile, screen, update_status_func, quit_event, time_change_event): '''Installation engine for text installer. Raises InstallationError for any error occurred during install. ''' # # The following information is needed for installation. # Make sure they are provided before even starting # # locale locale = install_profile.system.locale logging.debug("default locale: %s", locale) # timezone timezone = install_profile.system.tz_timezone logging.debug("time zone: %s", timezone) # hostname hostname = install_profile.system.hostname logging.debug("hostname: %s", hostname) ulogin = None user_home_dir = "" root_user = install_profile.users[0] root_pass = root_user.password reg_user = install_profile.users[1] ureal_name = reg_user.real_name ulogin = reg_user.login_name upass = reg_user.password logging.debug("Root password: %s", root_pass) if ulogin: user_home_dir = "/export/home/" + ulogin ZFS_SHARED_FS.insert(0, user_home_dir) logging.debug("User real name: %s", ureal_name) logging.debug("User login: %s", ulogin) logging.debug("User password: %s", upass) (inst_device, inst_device_size) = \ install_profile.disk.get_install_dev_name_and_size() logging.debug("Installation Device Name: %s", inst_device) logging.debug("Installation Device Size: %sMB", inst_device_size) swap_dump = ti_utils.SwapDump() min_inst_size = ti_utils.get_minimum_size(swap_dump) logging.debug("Minimum required size: %sMB", min_inst_size) if (inst_device_size < min_inst_size): logging.error("Size of device specified for installation " "is too small") logging.error("Size of install device: %sMB", inst_device_size) logging.error("Minimum required size: %sMB", min_inst_size) raise ti_utils.InstallationError recommended_size = ti_utils.get_recommended_size(swap_dump) logging.debug("Recommended size: %sMB", recommended_size) if (inst_device_size < recommended_size): # Warn users that their install target size is not optimal # Just log the warning, but continue with the installation. logging.warning("Size of device specified for installation is " "not optimal") logging.warning("Size of install device: %sMB", inst_device_size) logging.warning("Recommended size: %sMB", recommended_size) # Validate the value specified for timezone if not tz_isvalid(timezone): logging.error("Timezone value specified (%s) is not valid", timezone) raise ti_utils.InstallationError # Compute the time to set here. It will be set after the rtc # command is run, if on x86. install_time = datetime.datetime.now() + install_profile.system.time_offset if platform.processor() == "i386": # # At this time, the /usr/sbin/rtc command does not work in alternate # root. It hard codes to use /etc/rtc_config. # Therefore, we set the value for rtc_config in the live environment # so it will get copied over to the alternate root. # exec_cmd([RTC_CMD, "-z", timezone], "set timezone") exec_cmd([RTC_CMD, "-c"], "set timezone") # # Set the system time to the time specified by the user # The value to set the time to is computed before the "rtc" commands. # This is required because rtc will mess up the computation of the # time to set. The rtc command must be run before the command # to set time. Otherwise, the time that we set will be overwritten # after running /usr/sbin/rtc. # cmd = ["/usr/bin/date", install_time.strftime("%m%d%H%M%y")] exec_cmd(cmd, "set system time") time_change_event.set() global INSTALL_STATUS INSTALL_STATUS = InstallStatus(screen, update_status_func, quit_event) rootpool_name = install_profile.disk.get_install_root_pool() cleanup_existing_install_target(install_profile, inst_device) do_ti(install_profile, swap_dump) do_transfer() ict_mesg = "Completing transfer process" INSTALL_STATUS.update(InstallStatus.ICT, 0, ict_mesg) # Save the timezone in the installed root's /etc/default/init file ti_utils.save_timezone_in_init(INSTALLED_ROOT_DIR, timezone) # If swap was created, add appropriate entry to <target>/etc/vfstab swap_device = swap_dump.get_swap_device(rootpool_name) logging.debug("Swap device: %s", swap_device) ti_utils.setup_etc_vfstab_for_swap(swap_device, INSTALLED_ROOT_DIR) # # The /etc/.sysIDtool.state file needs to be written before calling # the ICTs, because it gets copied over by the ICTs into the installed # system. # create_sysid_file() try: run_ICTs(install_profile, hostname, ict_mesg, inst_device, locale, root_pass, ulogin, upass, ureal_name, rootpool_name) finally: post_install_cleanup(install_profile, rootpool_name) INSTALL_STATUS.update(InstallStatus.ICT, 100, ict_mesg)