Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
def do_ti_install(install_data, screen, update_status_func):
    '''Installation engine for text installer.
       Raises InstallationError for any error occurred during install.
    '''

    sysconfig_profile = sysconfig.profile.from_engine()

    #
    # The following information is needed for installation.
    # Make sure they are provided before even starting
    #

    # timezone
    timezone = sysconfig_profile.system.tz_timezone
    LOGGER.debug("time zone: %s", timezone)

    # Validate the value specified for timezone
    if not tz_isvalid(timezone):
        LOGGER.error("Timezone value specified (%s) is not valid", timezone)
        raise ti_utils.InstallationError

    # Compute the time to set.
    install_time = datetime.datetime.now() + \
        sysconfig_profile.system.time_offset

    # Set the system time to the time specified by the user.
    cmd = ["/usr/bin/date", install_time.strftime("%m%d%H%M%y")]
    Popen.check_call(cmd,
                     stdout=Popen.STORE,
                     stderr=Popen.STORE,
                     logger=LOGGER)

    hostname = sysconfig_profile.system.hostname
    LOGGER.debug("hostname: " + hostname)

    engine = InstallEngine.get_instance()
    doc = engine.doc

    # look to see if the target disk has 'whole_disk' set
    disk = get_desired_target_disk(doc)
    if disk.whole_disk:
        inst_device_size = disk.disk_prop.dev_size
    else:
        # look for a GPT partition first
        gpt_partition = get_solaris_gpt_partition(doc)

        if gpt_partition is None:
            solaris_slice = get_solaris_slice(doc)
            if solaris_slice is None:
                raise ti_utils.InstallationError("Unable to find solaris "
                                                 "slice")
            inst_device_size = solaris_slice.size
        else:
            inst_device_size = gpt_partition.size

    LOGGER.info("Installation Device Size: %s", inst_device_size)

    minimum_size = screen.tc.minimum_target_size
    LOGGER.info("Minimum required size: %s", minimum_size)
    if inst_device_size < minimum_size:
        LOGGER.error("Size of device specified for installation "
                     "is too small")
        LOGGER.error("Size of install device: %s", inst_device_size)
        LOGGER.error("Minimum required size: %s", minimum_size)
        raise ti_utils.InstallationError

    recommended_size = screen.tc.recommended_target_size
    LOGGER.info("Recommended size: %s", 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.
        LOGGER.warning("Size of device specified for installation is "
                       "not optimal")
        LOGGER.warning("Size of install device: %s", inst_device_size)
        LOGGER.warning("Recommended size: %s", recommended_size)

    (swap_type, swap_size, dump_type, dump_size) = \
        screen.tc.calc_swap_dump_size(minimum_size, inst_device_size,
                                      swap_included=True)

    desired_zpool = get_desired_target_zpool(doc)
    if swap_type == TargetController.SWAP_DUMP_ZVOL:
        desired_zpool.add_zvol("swap",
                               swap_size.get(Size.mb_units),
                               Size.mb_units,
                               use="swap")

    if dump_type == TargetController.SWAP_DUMP_ZVOL:
        desired_zpool.add_zvol("dump",
                               dump_size.get(Size.mb_units),
                               Size.mb_units,
                               use="dump",
                               create_failure_ok=True)

    LOGGER.info("Swap type: %s", swap_type)
    LOGGER.info("Swap size: %s", swap_size)
    LOGGER.info("Dump type: %s", dump_type)
    LOGGER.info("Dump size: %s", dump_size)

    # Specify for the shared datasets <root_pool>/export and
    # <root_pool>/export/home be created.  We will specify
    # a mountpoint for <root_pool>/export dataset.
    # We must not specify a mountpoint for <root_pool>/export/home.
    # It should inherit the mountpoint from <root_pool>/export.

    desired_zpool.add_filesystem("export", mountpoint="/export")
    desired_zpool.add_filesystem("export/home")

    # Add the list of packages to be removed after the install to the DOC
    pkg_remove_list = [
        'pkg:/system/install/media/internal',
        'pkg:/system/install/text-install'
    ]
    pkg_spec = IPSSpec(action=IPSSpec.UNINSTALL, contents=pkg_remove_list)
    pkg_rm_node = Software(CLEANUP_CPIO_INSTALL, type="IPS")
    pkg_rm_node.insert_children(pkg_spec)
    doc.volatile.insert_children(pkg_rm_node)

    # execute the prepare transfer checkpoint.  This checkpoint must be
    # executed by itself, before executing any of the transfer related
    # checkpoints.  The transfer checkpoints requires data setup from the
    # prepare transfer checkpoint.
    status, failed_cp = engine.execute_checkpoints(
        start_from=TRANSFER_PREP, pause_before=VARSHARE_DATASET)

    if status != InstallEngine.EXEC_SUCCESS:
        err_data = errsvc.get_errors_by_mod_id(TRANSFER_PREP)[0]
        LOGGER.error("%s checkpoint failed" % TRANSFER_PREP)
        err = err_data.error_data[liberrsvc.ES_DATA_EXCEPTION]
        LOGGER.error(err)
        raise ti_utils.InstallationError("Failed to execute checkpoint "
                                         "%s", TRANSFER_PREP)

    global INSTALL_STATUS
    INSTALL_STATUS = InstallStatus(screen, update_status_func)

    LOGGER.debug("Executing rest of checkpoints")

    engine.execute_checkpoints(callback=exec_callback,
                               dry_run=install_data.no_install_mode)

    INSTALL_STATUS.report_status()

    if INSTALL_STATUS.exec_status is InstallEngine.EXEC_CANCELED:
        raise ti_utils.InstallationCanceledError("User selected cancel.")

    if INSTALL_STATUS.exec_status is InstallEngine.EXEC_FAILED:
        raise ti_utils.InstallationError("Failed executing checkpoints")

    if install_data.no_install_mode:
        # all subsequent code depends on the install target being setup
        return

    new_be = get_desired_target_be(doc)
    install_mountpoint = new_be.mountpoint

    # If swap was created, add appropriate entry to <target>/etc/vfstab
    LOGGER.debug("install mountpoint: %s", install_mountpoint)
    LOGGER.debug("new_be: %s", new_be)
    screen.tc.setup_vfstab_for_swap(ROOT_POOL, install_mountpoint)

    post_install_cleanup(install_data)
def do_ti_install(install_data, screen, update_status_func):
    '''Installation engine for text installer.
       Raises InstallationError for any error occurred during install.

    '''

    sysconfig_profile = sysconfig.profile.from_engine()

    #
    # The following information is needed for installation.
    # Make sure they are provided before even starting
    #

    # timezone
    timezone = sysconfig_profile.system.tz_timezone
    LOGGER.debug("time zone: %s", timezone)

    # Validate the value specified for timezone
    if not tz_isvalid(timezone):
        LOGGER.error("Timezone value specified (%s) is not valid", timezone)
        raise ti_utils.InstallationError

    # Compute the time to set.
    install_time = datetime.datetime.now() + \
        sysconfig_profile.system.time_offset

    # Set the system time to the time specified by the user.
    cmd = ["/usr/bin/date", install_time.strftime("%m%d%H%M%y")]
    Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE,
                     logger=LOGGER)

    hostname = sysconfig_profile.system.hostname
    LOGGER.debug("hostname: " + hostname)

    engine = InstallEngine.get_instance()
    doc = engine.doc
    solaris_slice = get_solaris_slice(doc)
    if solaris_slice is None:
        raise ti_utils.InstallationError("Unable to find solaris slice")
    inst_device_size = solaris_slice.size

    LOGGER.info("Installation Device Size: %sMB", inst_device_size)

    minimum_size = screen.tc.minimum_target_size
    LOGGER.info("Minimum required size: %s", minimum_size)
    if (inst_device_size < minimum_size):
        LOGGER.error("Size of device specified for installation "
                     "is too small")
        LOGGER.error("Size of install device: %s", inst_device_size)
        LOGGER.error("Minimum required size: %s", minimum_size)
        raise ti_utils.InstallationError

    recommended_size = screen.tc.recommended_target_size
    LOGGER.info("Recommended size: %s", 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.
        LOGGER.warning("Size of device specified for installation is "
                       "not optimal")
        LOGGER.warning("Size of install device: %s", inst_device_size)
        LOGGER.warning("Recommended size: %s", recommended_size)

    (swap_type, swap_size, dump_type, dump_size) = \
        screen.tc.calc_swap_dump_size(minimum_size, inst_device_size,
                                      swap_included=True)

    desired_zpool = get_desired_target_zpool(doc)
    if (swap_type == TargetController.SWAP_DUMP_ZVOL):
        swap_zvol = desired_zpool.add_zvol("swap", \
            swap_size.get(Size.mb_units), Size.mb_units, use="swap")

    if (dump_type == TargetController.SWAP_DUMP_ZVOL):
        dump_zvol = desired_zpool.add_zvol("dump", \
            dump_size.get(Size.mb_units), Size.mb_units, use="dump",
            create_failure_ok=True)

    LOGGER.info("Swap type: %s", swap_type)
    LOGGER.info("Swap size: %s", swap_size)
    LOGGER.info("Dump type: %s", dump_type)
    LOGGER.info("Dump size: %s", dump_size)

    # Specify for the shared datasets <root_pool>/export and
    # <root_pool>/export/home be created.  We will specify
    # a mountpoint for <root_pool>/export dataset.
    # We must not specify a mountpoint for <root_pool>/export/home.
    # It should inherit the mountpoint from <root_pool>/export.

    desired_zpool.add_filesystem("export", mountpoint="/export")
    desired_zpool.add_filesystem("export/home")

    # Add the list of packages to be removed after the install to the DOC
    pkg_remove_list = ['pkg:/system/install/media/internal',
                       'pkg:/system/install/text-install']
    pkg_spec = IPSSpec(action=IPSSpec.UNINSTALL, contents=pkg_remove_list)
    pkg_rm_node = Software(CLEANUP_CPIO_INSTALL, type="IPS")
    pkg_rm_node.insert_children(pkg_spec)
    doc.volatile.insert_children(pkg_rm_node)

    # execute the prepare transfer checkpoint.  This checkpoint must
    # be executed by itself, before executing any of the transfer
    # related checkpoints.  The transfer checkpoints requires
    # data setup from the prepare transfer checkpoint.

    (status, failed_cp) = engine.execute_checkpoints(
        start_from=TRANSFER_PREP, pause_before=VAR_SHARED_DATASET)

    if status != InstallEngine.EXEC_SUCCESS:
        err_data = (errsvc.get_errors_by_mod_id(TRANSFER_PREP))[0]
        LOGGER.error("%s checkpoint failed" % TRANSFER_PREP)
        err = err_data.error_data[liberrsvc.ES_DATA_EXCEPTION]
        LOGGER.error(err)
        raise ti_utils.InstallationError("Failed to execute checkpoint "
                                         "%s", TRANSFER_PREP)

    global INSTALL_STATUS
    INSTALL_STATUS = InstallStatus(screen, update_status_func)

    LOGGER.debug("Executing rest of checkpoints")

    engine.execute_checkpoints(callback=exec_callback, \
        dry_run=install_data.no_install_mode)

    INSTALL_STATUS.report_status()

    if INSTALL_STATUS.exec_status is InstallEngine.EXEC_CANCELED:
        raise ti_utils.InstallationCanceledError("User selected cancel.")

    if INSTALL_STATUS.exec_status is InstallEngine.EXEC_FAILED:
        raise ti_utils.InstallationError("Failed executing checkpoints")

    if install_data.no_install_mode:
        # all subsequent code depends on the install target being
        # setup, so, can not execute them.
        return

    new_be = get_desired_target_be(doc)
    install_mountpoint = new_be.mountpoint

    # If swap was created, add appropriate entry to <target>/etc/vfstab
    LOGGER.debug("install mountpoint: %s", install_mountpoint)
    LOGGER.debug("new_be: %s", new_be)
    screen.tc.setup_vfstab_for_swap(ROOT_POOL, install_mountpoint)

    # Fix up the timezone before we reboot
    default_init_loc = install_mountpoint + '/etc/default/init'
    tzfile = open(default_init_loc, 'w')
    tzfile.write('TZ="' + timezone + '"\nCMASK=022\n')
    tzfile.close()

    # Write out the selected hostname
    nodename_log = install_mountpoint + '/etc/nodename'
    nodefile = open(nodename_log, 'w')
    nodefile.write(hostname + '\n')
    nodefile.close()

    post_install_cleanup(install_data)