Exemple #1
0
def runInstaller(options, config):
    try:
        sys.path.insert(0, options.installer_path)
        from installer import Installer
        from packageselector import PackageSelector
    except:
        raise ImportError('Installer path incorrect!')
    config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file
    
    # Check the installation type
    option_list_json = Utils.jsonread(options.package_list_file)
    options_sorted = option_list_json.items()

    packages = []
    if 'type' in config:
        for install_option in options_sorted:
            if install_option[0] == config['type']:
                packages = PackageSelector.get_packages_to_install(install_option[1]['packagelist_file'],
                                                               options.generated_data_path)
                break
    else:
        if 'packagelist_file' in config:
            packages = PackageSelector.get_packages_to_install(config['packagelist_file'],
                                                               options.generated_data_path)
        if 'additional_packages' in config:
            packages = packages.extend(config['additional_packages'])

    config['packages'] = packages
    # Run the installer
    package_installer = Installer(config, rpm_path=options.rpm_path,
                                  log_path=options.log_path, log_level=options.log_level)
    return package_installer.install(None)
Exemple #2
0
def runInstaller(options, config):
    try:
        sys.path.insert(0, options.installer_path)
        from installer import Installer
        from packageselector import PackageSelector
    except:
        raise ImportError('Installer path incorrect!')
    config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file
    
    # Check the installation type
    option_list_json = Utils.jsonread(options.package_list_file)
    options_sorted = option_list_json.items()

    packages = []
    if 'type' in config:
        for install_option in options_sorted:
            if install_option[0] == config['type']:
                packages = PackageSelector.get_packages_to_install(install_option[1]['packagelist_file'],
                                                               options.generated_data_path)
                break
    else:
        if 'packagelist_file' in config:
            packages = PackageSelector.get_packages_to_install(config['packagelist_file'],
                                                               options.generated_data_path)
        if 'additional_packages' in config:
            packages = packages.extend(config['additional_packages'])

    config['packages'] = packages
    # Run the installer
    package_installer = Installer(config, rpm_path=options.rpm_path,
                                  log_path=options.log_path, log_level=options.log_level)
    return package_installer.install(None)
Exemple #3
0
    def ks_config(self, options_file, ks_config):
        """Load configuration from file"""
        del options_file
        install_config = ks_config
        if self.is_vmware_virtualization(
        ) and 'install_linux_esx' not in install_config:
            install_config['install_linux_esx'] = True

        base_path = os.path.dirname("build_install_options_all.json")
        package_list = []
        if 'packagelist_file' in install_config:
            package_list = PackageSelector.get_packages_to_install(
                install_config['packagelist_file'], base_path)

        if 'additional_packages' in install_config:
            package_list.extend(install_config['additional_packages'])
        install_config['packages'] = package_list

        if "hostname" in install_config:
            evalhostname = os.popen(
                'printf ' + install_config["hostname"].strip(" ")).readlines()
            install_config['hostname'] = evalhostname[0]

        # crypt the password if needed
        if install_config['password']['crypted']:
            install_config['password'] = install_config['password']['text']
        else:
            install_config['password'] = crypt.crypt(
                install_config['password']['text'], "$6$" + "".join([
                    random.choice(string.ascii_letters + string.digits)
                    for _ in range(16)
                ]))
        return install_config
Exemple #4
0
    def ks_install(self, options_file, rpm_path, ks_config):
        install_config = ks_config
        install_config['iso_system'] = False
        if self.is_vmware_virtualization(
        ) and 'install_linux_esx' not in install_config:
            install_config['install_linux_esx'] = True

        json_wrapper_option_list = JsonWrapper(
            "build_install_options_all.json")
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        base_path = os.path.dirname("build_install_options_all.json")
        package_list = []

        package_list = PackageSelector.get_packages_to_install(
            options_sorted, install_config['type'], base_path)
        if 'additional_packages' in install_config:
            package_list.extend(install_config['additional_packages'])
        install_config['packages'] = package_list

        if 'partitions' in install_config:
            partitions = install_config['partitions']
        else:
            partitions = modules.commons.default_partitions

        install_config['disk'] = modules.commons.partition_disk(
            install_config['disk'], partitions)

        if "hostname" in install_config:
            evalhostname = os.popen(
                'printf ' + install_config["hostname"].strip(" ")).readlines()
            install_config['hostname'] = evalhostname[0]
        if "hostname" not in install_config or install_config['hostname'] == "":
            random_id = '%12x' % random.randrange(16**12)
            install_config['hostname'] = "photon-" + random_id.strip()

        # crypt the password if needed
        if install_config['password']['crypted']:
            install_config['password'] = install_config['password']['text']
        else:
            install_config['password'] = crypt.crypt(
                install_config['password']['text'], "$6$" + "".join([
                    random.choice(string.ascii_letters + string.digits)
                    for _ in range(16)
                ]))

        installer = InstallerContainer(install_config,
                                       self.maxy,
                                       self.maxx,
                                       True,
                                       rpm_path=rpm_path,
                                       log_path="/var/log")

        installer.install(None)
Exemple #5
0
    def ks_config(self, options_file, ks_config):
        """Load configuration from file"""
        del options_file
        install_config = ks_config
        install_config['iso_system'] = False
        if self.is_vmware_virtualization() and 'install_linux_esx' not in install_config:
            install_config['install_linux_esx'] = True

        json_wrapper_option_list = JsonWrapper("build_install_options_all.json")
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        base_path = os.path.dirname("build_install_options_all.json")
        package_list = []

        package_list = PackageSelector.get_packages_to_install(options_sorted,
                                                               install_config['type'],
                                                               base_path)
        if 'additional_packages' in install_config:
            package_list.extend(install_config['additional_packages'])
        install_config['packages'] = package_list

        if 'partitions' in install_config:
            partitions = install_config['partitions']
        else:
            partitions = modules.commons.default_partitions

        install_config['disk'] = modules.commons.partition_disk(install_config['disk'], partitions)

        if "hostname" in install_config:
            evalhostname = os.popen('printf ' + install_config["hostname"].strip(" ")).readlines()
            install_config['hostname'] = evalhostname[0]
        if "hostname" not in install_config or install_config['hostname'] == "":
            install_config['hostname'] = "photon-" + self.random_id.strip()

        # crypt the password if needed
        if install_config['password']['crypted']:
            install_config['password'] = install_config['password']['text']
        else:
            install_config['password'] = crypt.crypt(
                install_config['password']['text'],
                "$6$" + "".join([random.choice(
                    string.ascii_letters + string.digits) for _ in range(16)]))
        return install_config
Exemple #6
0
        config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file
        if 'password' in config:
            # crypt the password if needed
            if config['password']['crypted']:
                config['password'] = config['password']['text']
            else:
                config['password'] = crypt.crypt(config['password']['text'], "$6$" + "".join([random.choice(string.ascii_letters + string.digits) for _ in range(16)]))

        # Check the installation type
        json_wrapper_option_list = JsonWrapper(options.package_list_file)
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        packages = []
        packages = PackageSelector.get_packages_to_install(options_sorted, config['type'], options.output_data_path)

        config['packages'] = packages

        if (os.path.isdir(options.working_directory)):
            process = subprocess.Popen(['rm', '-rf', options.working_directory])
            retval = process.wait()

        process = subprocess.Popen(['mkdir', '-p', os.path.join(options.working_directory, "photon-chroot")])
        retval = process.wait()

        config['working_directory'] = options.working_directory

        # Run the installer
        package_installer = Installer(config, rpm_path = options.rpm_path, log_path = options.log_path)
        package_installer.install(None)
            if config['password']['crypted']:
                config['password'] = config['password']['text']
            else:
                config['password'] = crypt.crypt(
                    config['password']['text'], "$6$" + "".join([
                        random.choice(string.ascii_letters + string.digits)
                        for _ in range(16)
                    ]))

        # Check the installation type
        json_wrapper_option_list = JsonWrapper(options.package_list_file)
        option_list_json = json_wrapper_option_list.read()
        options_sorted = option_list_json.items()

        packages = []
        packages = PackageSelector.get_packages_to_install(
            options_sorted, config['type'], options.output_data_path)

        config['packages'] = packages

        if (os.path.isdir(options.working_directory)):
            process = subprocess.Popen(
                ['rm', '-rf', options.working_directory])
            retval = process.wait()

        process = subprocess.Popen([
            'mkdir', '-p',
            os.path.join(options.working_directory, "photon-chroot")
        ])
        retval = process.wait()

        config['working_directory'] = options.working_directory
Exemple #8
0
    # Check the installation type
    json_wrapper_option_list = JsonWrapper(options.package_list_file)
    option_list_json = json_wrapper_option_list.read()
    options_sorted = option_list_json.items()
    base_path = os.path.dirname(options.package_list_file)

    packages = []
    if config['iso_system'] == True:
        for install_option in options_sorted:
            if install_option[0] == "iso":
                json_wrapper_package_list = JsonWrapper(os.path.join(base_path, install_option[1]["file"]))
                package_list_json = json_wrapper_package_list.read()
                packages = package_list_json["packages"]
    else:
        packages = PackageSelector.get_packages_to_install(options_sorted, base_path, config['type'])

    config['packages'] = packages

    # Cleanup the working directory
    if not options.force:
        proceed = query_yes_no("This will remove everything under {0}. Are you sure?".format(options.working_directory))
        if not proceed:
            sys.exit(0)

    if (os.path.isdir(options.working_directory)):
        process = subprocess.Popen(['rm', '-rf', options.working_directory])
        retval = process.wait()
    else:
        process = subprocess.Popen(['mkdir', '-p', options.working_directory])
        retval = process.wait()