Ejemplo n.º 1
0
 def test_to_xml(self):
     '''Compare the SystemInfo.to_xml() output with a baseline (see above).
     Only concerned with structure, so propvals are ignored.
     
     '''
     sys = SystemInfo(tz_timezone='Europe/Prague')
     xml = sys.to_xml()
     xml_root = etree.fromstring("<root/>")
     xml_root.extend(xml)
     xml_str = etree.tostring(xml_root, pretty_print=True)
     xml_lines = xml_str.splitlines()
     compare_with = SAMPLE_SYSINFO_XML.splitlines()
     for xml_line, compare_with_line in zip(xml_lines, compare_with):
         if "<propval" in compare_with_line:
             continue
         self.assertEqual(xml_line, compare_with_line)
 def test_to_xml(self):
     '''Compare the SystemInfo.to_xml() output with a baseline (see above).
     Only concerned with structure, so propvals are ignored.
     
     '''
     sys = SystemInfo(tz_timezone='Europe/Prague')
     xml = sys.to_xml()
     xml_root = etree.fromstring("<root/>")
     xml_root.extend(xml)
     xml_str = etree.tostring(xml_root, pretty_print=True)
     xml_lines = xml_str.splitlines()
     compare_with = SAMPLE_SYSINFO_XML.splitlines()
     for xml_line, compare_with_line in zip(xml_lines, compare_with):
         if "<propval" in compare_with_line:
             continue
         self.assertEqual(xml_line, compare_with_line)
 def test_determine_kbd_layout(self):
     '''Test that determine_kbd_layout returns under normal conditions'''
     # Due to its nature, and under the hope that an RFE comes along that
     # simplifies SystemInfo.determine_keyboard_layout(), only the
     # common case is checked for now.
     
     kbd = SystemInfo.determine_keyboard_layout('/dev/kbd',
                              '/usr/share/lib/keytables/type_6/kbd_layouts')
     self.assertTrue(kbd)
Ejemplo n.º 4
0
    def test_determine_kbd_layout(self):
        '''Test that determine_kbd_layout returns under normal conditions'''
        # Due to its nature, and under the hope that an RFE comes along that
        # simplifies SystemInfo.determine_keyboard_layout(), only the
        # common case is checked for now.

        kbd = SystemInfo.determine_keyboard_layout(
            '/dev/kbd', '/usr/share/lib/keytables/type_6/kbd_layouts')
        self.assertTrue(kbd)
Ejemplo n.º 5
0
    def _show(self):
        '''Create an EditField for entering hostname, and list items
        for each of the network types
        
        '''
        sc_profile = solaris_install.sysconfig.profile.from_engine()

        if sc_profile.system is None:
            sc_profile.system = SystemInfo()
        self.sys_info = sc_profile.system
        if sc_profile.nic is None:
            sc_profile.nic = self.nic_info

        y_loc = 1

        y_loc += self.center_win.add_paragraph(NetworkTypeScreen.PARAGRAPH,
                                               y_loc)

        y_loc += 1
        self.center_win.add_text(NetworkTypeScreen.HOSTNAME_TEXT, y_loc)

        max_cols = self.win_size_x - self.hostfield_offset
        cols = min(max_cols, NetworkTypeScreen.HOSTNAME_SCREEN_LEN)
        scrollable_columns = SystemInfo.MAX_HOSTNAME_LEN + 1
        hostname_area = WindowArea(1,
                                   cols,
                                   y_loc,
                                   self.hostfield_offset,
                                   scrollable_columns=scrollable_columns)
        self.hostname = EditField(hostname_area,
                                  window=self.center_win,
                                  text=self.sys_info.hostname,
                                  validate=hostname_is_valid,
                                  error_win=self.main_win.error_line)
        self.hostname.item_key = None

        # Display network configuration part of screen only if applicable.
        if self.configure_network:
            y_loc += 3

            # If there are no configurable links, there is no point to let
            # user select type of network configuration.
            if not self.have_nic:
                # Inform user that no network interfaces were found
                # on the system.
                # If this is the case of non-global zone with all links
                # mandated from global zone, be more specific.
                if self.nic_info.type == NetworkInfo.FROMGZ:
                    self.center_win.add_paragraph(
                        NetworkTypeScreen.ALL_NICS_FROMGZ, y_loc, 1)
                else:
                    self.center_win.add_paragraph(
                        NetworkTypeScreen.NO_NICS_FOUND, y_loc, 1)

                self.main_win.do_update()
                activate = self.net_type_dict.get(self.nic_info.type,
                                                  self.hostname)
                self.center_win.activate_object(activate)
                return

        self.main_win.do_update()
        activate = self.net_type_dict.get(self.nic_info.type, self.hostname)
        self.center_win.activate_object(activate)
Ejemplo n.º 6
0
    def _show(self):
        '''Create the list of time zones'''
        LOGGER.debug("self.screen %s", self.screen)

        sc_profile = solaris_install.sysconfig.profile.from_engine()

        if sc_profile.system is None:
            sc_profile.system = SystemInfo()
        self.sys_info = sc_profile.system

        self.cur_country = self.sys_info.tz_country
        self.cur_continent = self.sys_info.tz_region

        if self.cur_continent == SystemInfo.UTC and self.screen != "regions":
            raise SkipException

        self.center_win.border_size = TimeZone.BORDER_WIDTH

        if self.screen == TimeZone.LOCATIONS:
            self.cur_timezone_parent = self.cur_continent
        elif self.screen == TimeZone.TIMEZONE:
            self.cur_timezone_parent = self.cur_country

        LOGGER.debug("cur_continent %s, cur_country %s", self.cur_continent,
                     self.cur_country)

        y_loc = 1

        y_loc += self.center_win.add_paragraph(self.intro, y_loc)

        y_loc += 1
        menu_item_max_width = self.win_size_x - TimeZone.SCROLL_SIZE
        self.center_win.add_text(self.title, y_loc, TimeZone.SCROLL_SIZE)
        y_loc += 1
        self.center_win.window.hline(y_loc, 3, curses.ACS_HLINE, 40)

        y_loc += 1

        tz_list = self.get_timezones(self.cur_continent, self.cur_country)

        area = WindowArea(x_loc=0,
                          y_loc=y_loc,
                          scrollable_lines=len(tz_list) + 1)
        area.lines = self.win_size_y - (y_loc + 1)
        area.columns = self.win_size_x
        LOGGER.debug("area.lines=%s, area.columns=%s", area.lines,
                     area.columns)
        self.scroll_region = ScrollWindow(area,
                                          enable_spelldict=True,
                                          window=self.center_win)

        utc = 0
        if self.screen == TimeZone.REGIONS:
            utc_area = WindowArea(1,
                                  len(TimeZone.UTC_TEXT) + 1, 0,
                                  TimeZone.SCROLL_SIZE)
            utc_item = ListItem(utc_area,
                                window=self.scroll_region,
                                text=TimeZone.UTC_TEXT,
                                data_obj=SystemInfo.UTC)
            self.scroll_region.spell_dict[TimeZone.UTC_TEXT] = utc
            utc = 1

        # add the entries to the screen
        for idx, timezone in enumerate(tz_list):
            # add this timezone to the scroll_region's spelling dict
            self.scroll_region.spell_dict[timezone.lower()] = idx + utc

            LOGGER.log(LOG_LEVEL_INPUT, "tz idx = %i name= %s", idx,
                       tz_list[idx])
            hilite = min(menu_item_max_width, len(timezone) + 1)
            win_area = WindowArea(1, hilite, idx + utc, TimeZone.SCROLL_SIZE)
            list_item = ListItem(win_area,
                                 window=self.scroll_region,
                                 text=timezone,
                                 data_obj=timezone)
            y_loc += 1

        self.main_win.do_update()
        self.center_win.activate_object(self.scroll_region)
        LOGGER.debug("self.cur_timezone_idx=%s", self.cur_timezone_idx)
        self.scroll_region.activate_object_force(self.cur_timezone_idx,
                                                 force_to_top=True)
Ejemplo n.º 7
0
    def perform_installation(self):
        '''method which actually does the installation.'''
        # establish the timer that will update the screen messaging
        timer = glib.timeout_add(INSTALLATION_TIMEOUT,
                                 self._update_screen_message)

        eng = InstallEngine.get_instance()
        errsvc.clear_error_list()
        eng.execute_checkpoints(start_from=TRANSFER_PREP,
                                pause_before=VARSHARE_DATASET)

        # Setup progress handling
        self.setup_progress_handling()

        self.logger.info("Setting up software to install/uninstall")

        # 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/gui-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)

        eng.doc.volatile.insert_children(pkg_rm_node)

        # Setup system configuration data
        profile = from_engine()
        gui_profile = eng.data_object_cache.volatile.get_first_child(
            name="GUI Install", class_type=InstallProfile)
        if gui_profile is None:
            SystemExit('Internal Error, GUI Install DOC not found')

        profile.system = SystemInfo(hostname=gui_profile.hostname,
                                    tz_region=gui_profile.continent,
                                    tz_country=gui_profile.country,
                                    tz_timezone=gui_profile.timezone,
                                    locale=gui_profile.default_locale)
        profile.nic = NetworkInfo(net_type="automatic")

        # Setup user configuration data
        root = UserInfo(login_name="root",
                        is_role=True,
                        password=gui_profile.userpassword,
                        expire="0")
        user = UserInfo(gid=10,
                        shell="/usr/bin/bash",
                        login_name=gui_profile.loginname,
                        real_name=gui_profile.username,
                        password=gui_profile.userpassword,
                        roles="root",
                        profiles="System Administrator",
                        sudoers="ALL=(ALL) ALL")
        profile.users = UserInfoContainer(user, root)
        self.logger.debug('from_engine returned %s', profile)

        gui_profile.set_log(DEFAULT_LOG_LOCATION, LOG_LOCATION_FINAL)

        # Run the registered checkpoints
        errsvc.clear_error_list()
        eng.execute_checkpoints(callback=self.install_callback)
        self.logger.info("Install Started")

        return False