Exemplo n.º 1
0
    def setUp(self):
        # We could mock out the db for this, but we ultimately want to make
        # sure that the debconf questions its getting exist.
        self.page = ubi_partman.Page(None)
        self.page.db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
        self.addCleanup(self.page.db.shutdown)

        find_in_os_prober = mock.patch('ubiquity.misc.find_in_os_prober')
        find_in_os_prober.start()
        self.addCleanup(find_in_os_prober.stop)

        get_release = mock.patch('ubiquity.misc.get_release')
        get_release.start()
        self.addCleanup(get_release.stop)
        self.release = misc.ReleaseInfo('Ubuntu', '11.04')
        misc.get_release.return_value = self.release

        # Don't cache descriptions.
        self.page.description_cache = {}

        # Always checked, never SUBST'ed.
        question = 'ubiquity/partitioner/advanced'
        question_has_variables(question, ['DISTRO'])
        self.page.db.subst(question, 'DISTRO', self.release.name)
        title = self.page.description(question)
        desc = self.page.extended_description(question)
        self.manual = ubi_partman.PartitioningOption(title, desc)
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
Exemplo n.º 3
0
    def setUp(self):
        # We could mock out the db for this, but we ultimately want to make
        # sure that the debconf questions it's getting exist.
        self.page = ubi_partman.Page(None, ui=mock.Mock())
        self.page.db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
        self.addCleanup(self.page.db.shutdown)

        # Don't cache descriptions.
        self.page.description_cache = {}
Exemplo n.º 4
0
 def setUp(self):
     self.ubi_timezone = plugin_manager.load_plugin('ubi-timezone')
     with EnvironmentVarGuard() as env:
         env["LC_ALL"] = "en_US.UTF-8"
         db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
     self.addCleanup(db.shutdown)
     controller = mock.Mock()
     controller.dbfilter = self.ubi_timezone.Page(None, db=db)
     self.gtk = self.ubi_timezone.PageGtk(controller)
Exemplo n.º 5
0
def install_drivers(cfg, pkg_install_func):
    if not isinstance(cfg, dict):
        raise TypeError("'drivers' config expected dict, found '%s': %s" %
                        (type_utils.obj_name(cfg), cfg))

    cfgpath = "nvidia/license-accepted"
    # Call translate_bool to ensure that we treat string values like "yes" as
    # acceptance and _don't_ treat string values like "nah" as acceptance
    # because they're True-ish
    nv_acc = util.translate_bool(util.get_cfg_by_path(cfg, cfgpath))
    if not nv_acc:
        LOG.debug("Not installing NVIDIA drivers. %s=%s", cfgpath, nv_acc)
        return

    if not subp.which("ubuntu-drivers"):
        LOG.debug("'ubuntu-drivers' command not available.  "
                  "Installing ubuntu-drivers-common")
        pkg_install_func(["ubuntu-drivers-common"])

    driver_arg = "nvidia"
    version_cfg = util.get_cfg_by_path(cfg, "nvidia/version")
    if version_cfg:
        driver_arg += ":{}".format(version_cfg)

    LOG.debug(
        "Installing and activating NVIDIA drivers (%s=%s, version=%s)",
        cfgpath,
        nv_acc,
        version_cfg if version_cfg else "latest",
    )

    # Register and set debconf selection linux/nvidia/latelink = true
    tdir = temp_utils.mkdtemp(needs_exe=True)
    debconf_file = os.path.join(tdir, "nvidia.template")
    try:
        util.write_file(debconf_file, NVIDIA_DEBCONF_CONTENT)
        with debconf.DebconfCommunicator("cloud-init") as dc:
            dc.command(X_LOADTEMPLATEFILE, debconf_file)
    except Exception as e:
        util.logexc(LOG, "Failed to register NVIDIA debconf template: %s",
                    str(e))
        raise
    finally:
        if os.path.isdir(tdir):
            util.del_dir(tdir)

    try:
        subp.subp(["ubuntu-drivers", "install", "--gpgpu", driver_arg])
    except subp.ProcessExecutionError as exc:
        if OLD_UBUNTU_DRIVERS_STDERR_NEEDLE in exc.stderr:
            LOG.warning("the available version of ubuntu-drivers is"
                        " too old to perform requested driver installation")
        elif "No drivers found for installation." in exc.stdout:
            LOG.warning("ubuntu-drivers found no drivers for installation")
        raise
Exemplo n.º 6
0
    def setUp(self):
        # We could mock out the db for this, but we ultimately want to make
        # sure that the debconf questions its getting exist.
        self.page = ubi_partman.Page(None)
        self.page.db = debconf.DebconfCommunicator('ubi-test', cloexec=True)
        self.addCleanup(self.page.db.shutdown)

        if 'UBIQUITY_TEST_INSTALLED' not in os.environ:
            self.mock_partman_tree()

        # Don't cache descriptions.
        self.page.description_cache = {}
Exemplo n.º 7
0
 def setUp(self):
     # We could mock out the db for this, but we ultimately want to make
     # sure that the debconf questions it's getting exist.
     self.page = ubi_console_setup.Page(None, ui=unittest.mock.Mock())
     self.page.db = debconf.DebconfCommunicator("ubi-test", cloexec=True)
     self.addCleanup(self.page.db.shutdown)