def test_manual(self):
        '''NetworkInfo.to_xml() looks correct for type = MANUAL'''
        nic = NetworkInfo(dns_address="1.2.3.4")
        nic.type = NetworkInfo.MANUAL
        # initialize structure containing information about selected
        # network interface
        nic.nic_iface = {
            NetworkInfo.NIC_NAME_KEY: 'net0',
            NetworkInfo.NIC_DEV_KEY: 'e1000g0',
            NetworkInfo.NIC_LINK_KEY: 'net0'
        }
        xml = nic.to_xml()
        for svc in xml:
            if svc.get("name") == "network/physical":
                net_phys = svc
            elif svc.get("name") == "network/install":
                net_install = svc
            else:
                self.fail("Unexpected service found: %s" %
                          etree.tostring(svc, pretty_print=True))
        for instance in net_phys:
            if instance.get("name") == "nwam":
                self.assertEquals("false", instance.get("enabled"))
            elif instance.get("name") == "default":
                self.assertEquals("true", instance.get("enabled"))

        for prop_group in net_install.iterchildren().next():
            if prop_group.get("name") not in ("install_ipv4_interface",
                                              "install_ipv6_interface"):
                self.fail("Unexpected property group of network/install: "
                          "%s" % etree.tostring(prop_group, pretty_print=True))
 def test_manual(self):
     '''NetworkInfo.to_xml() looks correct for type = MANUAL'''
     nic = NetworkInfo(dns_address="1.2.3.4")
     nic.type = NetworkInfo.MANUAL
     # initialize structure containing information about selected
     # network interface
     nic.nic_iface = {NetworkInfo.NIC_NAME_KEY: 'net0',
                      NetworkInfo.NIC_DEV_KEY: 'e1000g0',
                      NetworkInfo.NIC_LINK_KEY: 'net0'}
     xml = nic.to_xml()
     for svc in xml:
         if svc.get("name") == "network/physical":
             net_phys = svc
         elif svc.get("name") == "network/install":
             net_install = svc
         else:
             self.fail("Unexpected service found: %s" %
                        etree.tostring(svc, pretty_print=True))
     for instance in net_phys:
         if instance.get("name") == "nwam":
             self.assertEquals("false", instance.get("enabled"))
         elif instance.get("name") == "default":
             self.assertEquals("true", instance.get("enabled"))
     
     for prop_group in net_install.iterchildren().next():
         if prop_group.get("name") not in ("install_ipv4_interface",
                                           "install_ipv6_interface"):
             self.fail("Unexpected property group of network/install: "
                       "%s" % etree.tostring(prop_group, pretty_print=True))
 def test_set_type_valid(self):
     '''NetworkInfo.type = <valid value> succeeds'''
     net = NetworkInfo()
     net.type = NetworkInfo.MANUAL
     self.assertEquals(net.type, NetworkInfo.MANUAL)
     net.type = NetworkInfo.AUTOMATIC
     self.assertEquals(net.type, NetworkInfo.AUTOMATIC)
     net.type = NetworkInfo.NONE
     self.assertEquals(net.type, NetworkInfo.NONE)
 def test_set_type_valid(self):
     '''NetworkInfo.type = <valid value> succeeds'''
     net = NetworkInfo()
     net.type = NetworkInfo.MANUAL
     self.assertEquals(net.type, NetworkInfo.MANUAL)
     net.type = NetworkInfo.AUTOMATIC
     self.assertEquals(net.type, NetworkInfo.AUTOMATIC)
     net.type = NetworkInfo.NONE
     self.assertEquals(net.type, NetworkInfo.NONE)
    def get_networks(self):
        '''Build a summary of the networks in the install_profile,
        returned as a list of strings

        '''
        network_summary = []

        # hostname belongs to 'identity' group
        if configure_group(SC_GROUP_IDENTITY):
            network_summary.append(_("  Computer name: %s") %
                                   self.sysconfig.system.hostname)

        if not configure_group(SC_GROUP_NETWORK):
            return network_summary

        nic = self.sysconfig.nic       
        if nic.type == NetworkInfo.AUTOMATIC:
            network_summary.append(_("  Network Configuration: Automatic"))
        elif nic.type == NetworkInfo.NONE:
            network_summary.append(_("  Network Configuration: None"))
        elif nic.type == NetworkInfo.FROMGZ:
            network_summary.append(_("  Network Configuration:"
                                     " Mandated from global zone"))
        elif nic.type == NetworkInfo.MANUAL:
            network_summary.append(_("  Manual Configuration: %s")
                                   % NetworkInfo.get_nic_desc(nic.nic_iface))
            network_summary.append(_("IP Address: %s") % nic.ip_address)
            network_summary.append(_("Netmask: %s") % nic.netmask)
            if nic.gateway:
                network_summary.append(_("Router: %s") % nic.gateway)
        return network_summary
Beispiel #6
0
    def get_networks(self):
        '''Build a summary of the networks in the install_profile,
        returned as a list of strings

        '''
        network_summary = []

        # hostname belongs to 'identity' group
        if configure_group(SC_GROUP_IDENTITY):
            network_summary.append(_("  Computer name: %s") %
                                   self.sysconfig.system.hostname)

        if not configure_group(SC_GROUP_NETWORK):
            return network_summary

        nic = self.sysconfig.nic
        if nic.type == NetworkInfo.AUTOMATIC:
            network_summary.append(_("  Network Configuration: Automatic"))
        elif nic.type == NetworkInfo.NONE:
            network_summary.append(_("  Network Configuration: None"))
        elif nic.type == NetworkInfo.FROMGZ:
            network_summary.append(_("  Network Configuration:"
                                     " Mandated from global zone"))
        elif nic.type == NetworkInfo.MANUAL:
            network_summary.append(_("  Manual Configuration: %s")
                                   % NetworkInfo.get_nic_desc(nic.nic_iface))
            network_summary.append(_("IP Address: %s") % nic.ip_address)
            network_summary.append(_("Netmask: %s") % nic.netmask)
            if nic.gateway:
                network_summary.append(_("Router: %s") % nic.gateway)
        return network_summary
    def _show(self):
        '''Create the editable fields for IP address, netmask, router,
        dns address and dns domain
        
        '''
        self.nic = solaris_install.sysconfig.profile.from_engine().nic
        if self.nic.type != NetworkInfo.MANUAL:
            raise SkipException

        nic_name = NetworkInfo.get_nic_name(self.nic.nic_iface)

        if self.nic.find_defaults:
            self.set_defaults(self.nic)

        self.main_win.set_header_text(NICConfigure.HEADER_TEXT % nic_name)

        max_y = self.win_size_y - 16
        max_x = self.win_size_x - 1
        y_loc = 1
        y_loc += self.center_win.add_paragraph(NICConfigure.PARAGRAPH,
                                               y_loc,
                                               max_y=max_y)

        # Adding the NIC name to the screen squishes everything a bit
        # This will be relieved when the DNS items move to a nameservice screen
        max_y = 2
        description_start = (NICConfigure.ITEM_OFFSET * 2 +
                             self.list_area.columns)
        y_loc += 1
        self.make_field(NICConfigure.NIC_NAME_LABEL,
                        NICConfigure.NIC_DESCRIPTION,
                        y_loc,
                        max_y,
                        max_x,
                        description_start,
                        nic_name,
                        selectable=False)

        y_loc += max_y
        self.ip_field = self.make_field(NICConfigure.IP_LABEL,
                                        NICConfigure.IP_DESCRIPTION, y_loc,
                                        max_y, max_x, description_start,
                                        self.nic.ip_address)

        y_loc += max_y
        self.netmask_field = self.make_field(NICConfigure.NETMASK_LABEL,
                                             NICConfigure.NETMASK_DESCRIPTION,
                                             y_loc, max_y, max_x,
                                             description_start,
                                             self.nic.netmask)

        y_loc += max_y
        self.gateway_field = self.make_field(NICConfigure.GATEWAY_LABEL,
                                             NICConfigure.GATEWAY_DESCRIPTION,
                                             y_loc, max_y, max_x,
                                             description_start,
                                             self.nic.gateway)
        self.main_win.do_update()
        self.center_win.activate_object()
 def _show(self):
     '''Create the editable fields for IP address, netmask, router,
     dns address and dns domain
     
     '''
     self.nic = solaris_install.sysconfig.profile.from_engine().nic
     if self.nic.type != NetworkInfo.MANUAL:
         raise SkipException
     
     nic_name = NetworkInfo.get_nic_name(self.nic.nic_iface)
     
     if self.nic.find_defaults:
         self.set_defaults(self.nic)
     
     self.main_win.set_header_text(NICConfigure.HEADER_TEXT % nic_name)
     
     max_y = self.win_size_y - 16
     max_x = self.win_size_x - 1
     y_loc = 1
     y_loc += self.center_win.add_paragraph(NICConfigure.PARAGRAPH, y_loc,
                                            max_y=max_y)
     
     # Adding the NIC name to the screen squishes everything a bit
     # This will be relieved when the DNS items move to a nameservice screen
     max_y = 2
     description_start = (NICConfigure.ITEM_OFFSET * 2 +
                          self.list_area.columns)
     y_loc += 1
     self.make_field(NICConfigure.NIC_NAME_LABEL,
                     NICConfigure.NIC_DESCRIPTION, y_loc, max_y, max_x,
                     description_start, nic_name, selectable=False)
     
     y_loc += max_y
     self.ip_field = self.make_field(NICConfigure.IP_LABEL,
                                     NICConfigure.IP_DESCRIPTION,
                                     y_loc, max_y, max_x,
                                     description_start,
                                     self.nic.ip_address)
     
     y_loc += max_y
     self.netmask_field = self.make_field(NICConfigure.NETMASK_LABEL,
                                          NICConfigure.NETMASK_DESCRIPTION,
                                          y_loc, max_y, max_x,
                                          description_start,
                                          self.nic.netmask)
     
     y_loc += max_y
     self.gateway_field = self.make_field(NICConfigure.GATEWAY_LABEL,
                                          NICConfigure.GATEWAY_DESCRIPTION,
                                          y_loc, max_y, max_x,
                                          description_start,
                                          self.nic.gateway)
     self.main_win.do_update()
     self.center_win.activate_object()
Beispiel #9
0
    def __init__(self, main_win, configure_network=False):
        global LOGGER
        if LOGGER is None:
            LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")

        super(NetworkTypeScreen, self).__init__(main_win)
        self.hostfield_offset = textwidth(NetworkTypeScreen.HOSTNAME_TEXT)
        self.menu_item_desc_max = (self.win_size_x -
                                   NetworkTypeScreen.ITEM_DESC_OFFSET)

        self.net_type_dict = {}
        self.sys_info = None
        self.automatic = None
        self.manual = None
        self.none_option = None
        self.hostname = None
        self.nic_info = NetworkInfo()

        # find_links() returns tuple containing
        #  * dictionary of configurable NICs
        #  * number of NICs mandated from global zone.
        #
        # Taking that information into account, initialize type
        # of network configuration:
        #  * FROMGZ - One or more link found, but all found links are
        #             controlled from global zone.
        #  * None - otherwise
        #
        # Set 'have_nic' flag to True if there is at least one configurable
        # link, otherwise set the flag to False.
        #
        self.ether_nics, self.fromgz_num = NetworkInfo.find_links()
        self.nic_info.type = NetworkInfo.NONE
        self.have_nic = True
        if len(self.ether_nics) == 0:
            self.have_nic = False
            if self.fromgz_num > 0:
                self.nic_info.type = NetworkInfo.FROMGZ

        self.configure_network = configure_network
    def __init__(self, main_win):
        global LOGGER
        if LOGGER is None:
            LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")
        
        super(NICSelect, self).__init__(main_win)
        self.list_area = WindowArea(1, 0, 0, NICSelect.LIST_OFFSET)

        # find_links() returns tuple containing
        #  * dictionary of configurable NICs
        #  * number of NICs mandated from global zone.
        self.ether_nics = NetworkInfo.find_links()[0]
        self.nic = None
    def __init__(self, main_win):
        global LOGGER
        if LOGGER is None:
            LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")

        super(NICSelect, self).__init__(main_win)
        self.list_area = WindowArea(1, 0, 0, NICSelect.LIST_OFFSET)

        # find_links() returns tuple containing
        #  * dictionary of configurable NICs
        #  * number of NICs mandated from global zone.
        self.ether_nics = NetworkInfo.find_links()[0]
        self.nic = None
    def __init__(self, main_win, configure_network=False):
        global LOGGER
        if LOGGER is None:
            LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")
        
        super(NetworkTypeScreen, self).__init__(main_win)
        self.hostfield_offset = textwidth(NetworkTypeScreen.HOSTNAME_TEXT)
        self.menu_item_desc_max = (self.win_size_x -
                                   NetworkTypeScreen.ITEM_DESC_OFFSET)
        
        self.net_type_dict = {}
        self.sys_info = None
        self.automatic = None
        self.manual = None
        self.none_option = None
        self.hostname = None
        self.nic_info = NetworkInfo()

        # find_links() returns tuple containing
        #  * dictionary of configurable NICs
        #  * number of NICs mandated from global zone.
        #
        # Taking that information into account, initialize type
        # of network configuration:
        #  * FROMGZ - One or more link found, but all found links are
        #             controlled from global zone.
        #  * None - otherwise
        #
        # Set 'have_nic' flag to True if there is at least one configurable
        # link, otherwise set the flag to False.
        #
        self.ether_nics, self.fromgz_num = NetworkInfo.find_links()
        self.nic_info.type = NetworkInfo.NONE
        self.have_nic = True
        if len(self.ether_nics) == 0:
            self.have_nic = False
            if self.fromgz_num > 0:
                self.nic_info.type = NetworkInfo.FROMGZ

        self.configure_network = configure_network
 def get_networks(self):
     '''Build a summary of the networks from the DOC data,
     returned as a list of strings
     
     '''
     network_summary = []
     network_summary.append(_("  Computer name: %s") %
                            self.sysconfig.system.hostname)
     nic = self.sysconfig.nic
     
     if nic.type == NetworkInfo.AUTOMATIC:
         network_summary.append(_("  Network Configuration: Automatic"))
     elif nic.type == NetworkInfo.NONE:
         network_summary.append(_("  Network Configuration: None"))
     elif nic.type == NetworkInfo.MANUAL:
         network_summary.append(_("  Manual Configuration: %s")
                                % NetworkInfo.get_nic_desc(nic.nic_iface))
         network_summary.append(_("    IP Address: %s") % nic.ip_address)
         network_summary.append(_("    Netmask: %s") % nic.netmask)
         if nic.gateway:
             network_summary.append(_("    Router: %s") % nic.gateway)
     return network_summary
Beispiel #14
0
    def get_networks(self):
        '''Build a summary of the networks from the DOC data,
        returned as a list of strings

        '''
        network_summary = []
        network_summary.append(_("  Computer name: %s") %
                               self.sysconfig.system.hostname)
        nic = self.sysconfig.nic

        if nic.type == NetworkInfo.AUTOMATIC:
            network_summary.append(_("  Network Configuration: Automatic"))
        elif nic.type == NetworkInfo.NONE:
            network_summary.append(_("  Network Configuration: None"))
        elif nic.type == NetworkInfo.MANUAL:
            network_summary.append(_("  Manual Configuration: %s")
                                   % NetworkInfo.get_nic_desc(nic.nic_iface))
            network_summary.append(_("    IP Address: %s") % nic.ip_address)
            network_summary.append(_("    Netmask: %s") % nic.netmask)
            if nic.gateway:
                network_summary.append(_("    Router: %s") % nic.gateway)
        return network_summary
    def _show(self):
        '''Create a list of NICs to choose from. If more than 15 NICs are
        found, create a scrolling region to put them in
        
        '''
        self.nic = solaris_install.sysconfig.profile.from_engine().nic
        if self.nic.type != NetworkInfo.MANUAL:
            raise SkipException
        if len(self.ether_nics) == 1:
            self.set_nic_in_profile(self.ether_nics[0])
            raise SkipException

        if self.nic.nic_iface is None:
            selected_nic_name = ""
        else:
            selected_nic_name = NetworkInfo.get_nic_name(self.nic.nic_iface)

        y_loc = 1
        y_loc += self.center_win.add_paragraph(NICSelect.PARAGRAPH, y_loc)

        selected_nic = 0

        y_loc += 1
        max_nics = min(NICSelect.MAX_NICS, self.center_win.area.lines - y_loc)
        if len(self.ether_nics) > max_nics:
            columns = self.win_size_x - NICSelect.LIST_OFFSET
            win_area = WindowArea(lines=max_nics,
                                  columns=columns,
                                  y_loc=y_loc,
                                  x_loc=NICSelect.LIST_OFFSET,
                                  scrollable_lines=len(self.ether_nics))
            self.scroll_region = ScrollWindow(win_area, window=self.center_win)
            self.list_region = self.scroll_region
            y_loc = 0
        else:
            self.scroll_region = None
            self.list_region = self.center_win

        for nic in self.ether_nics:
            self.list_area.y_loc = y_loc

            #
            # display list item in form of "NIC name (NIC device)" -
            # e.g. "net0 (bge0)"
            # If NIC device is not populated, display just NIC name.
            #
            list_item_text = NetworkInfo.get_nic_desc(nic)

            # list item width
            self.list_area.columns = len(list_item_text) + 1

            list_item = ListItem(self.list_area,
                                 window=self.list_region,
                                 text=list_item_text,
                                 data_obj=nic)
            if NetworkInfo.get_nic_name(nic) == selected_nic_name:
                selected_nic = list_item
            y_loc += 1

        self.main_win.do_update()
        if self.scroll_region:
            self.center_win.activate_object(self.scroll_region)
            self.scroll_region.activate_object_force(selected_nic,
                                                     force_to_top=True)
        else:
            self.center_win.activate_object(selected_nic)
 def set_nic_in_profile(self, selected_nic):
     '''Store selected NIC in the profile '''
     LOGGER.info("Selecting %s for manual configuration",
                 NetworkInfo.get_nic_desc(selected_nic))
     nic = solaris_install.sysconfig.profile.from_engine().nic
     nic.nic_iface = selected_nic
Beispiel #17
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
 def test_automatic(self):
     '''NetworkInfo.to_xml() looks correct for type = AUTOMATIC'''
     nic = NetworkInfo()
     nic.type = NetworkInfo.AUTOMATIC
     self._gen_to_xml(nic, SAMPLE_AUTOMATIC_NETWORK_XML)
 def test_set_type_invalid(self):
     '''NetworkInfo.type = <arbitrary value> fails'''
     net = NetworkInfo()
     self.assertRaises(ValueError, NetworkInfo.type.fset, net, "foo")
     self.assertRaises(ValueError, NetworkInfo.type.fset, net, [])
     self.assertRaises(ValueError, NetworkInfo.type.fset, net, 1)
 def test_automatic(self):
     '''NetworkInfo.to_xml() looks correct for type = AUTOMATIC'''
     nic = NetworkInfo()
     nic.type = NetworkInfo.AUTOMATIC
     self._gen_to_xml(nic, SAMPLE_AUTOMATIC_NETWORK_XML)
 def test_none(self):
     '''NetworkInfo.to_xml() looks correct for type = NONE'''
     nic = NetworkInfo()
     nic.type = NetworkInfo.NONE
     self._gen_to_xml(nic, SAMPLE_NONE_NETWORK_XML)
 def test_none(self):
     '''NetworkInfo.to_xml() looks correct for type = NONE'''
     nic = NetworkInfo()
     nic.type = NetworkInfo.NONE
     self._gen_to_xml(nic, SAMPLE_NONE_NETWORK_XML)
 def set_nic_in_profile(self, selected_nic):
     '''Store selected NIC in the profile '''
     LOGGER.info("Selecting %s for manual configuration",
                 NetworkInfo.get_nic_desc(selected_nic))
     nic = solaris_install.sysconfig.profile.from_engine().nic
     nic.nic_iface = selected_nic
    def _show(self):
        '''Create a list of NICs to choose from. If more than 15 NICs are
        found, create a scrolling region to put them in
        
        '''
        self.nic = solaris_install.sysconfig.profile.from_engine().nic
        if self.nic.type != NetworkInfo.MANUAL:
            raise SkipException
        if len(self.ether_nics) == 1:
            self.set_nic_in_profile(self.ether_nics[0])
            raise SkipException
        
        if self.nic.nic_iface is None:
            selected_nic_name = ""
        else:
            selected_nic_name = NetworkInfo.get_nic_name(self.nic.nic_iface)
        
        y_loc = 1
        y_loc += self.center_win.add_paragraph(NICSelect.PARAGRAPH, y_loc)
        
        selected_nic = 0
        
        y_loc += 1
        max_nics = min(NICSelect.MAX_NICS, self.center_win.area.lines - y_loc)
        if len(self.ether_nics) > max_nics:
            columns = self.win_size_x - NICSelect.LIST_OFFSET
            win_area = WindowArea(lines=max_nics, columns=columns,
                                  y_loc=y_loc, x_loc=NICSelect.LIST_OFFSET,
                                  scrollable_lines=len(self.ether_nics))
            self.scroll_region = ScrollWindow(win_area, window=self.center_win)
            self.list_region = self.scroll_region
            y_loc = 0
        else:
            self.scroll_region = None
            self.list_region = self.center_win
        
        for nic in self.ether_nics:
            self.list_area.y_loc = y_loc

            #
            # display list item in form of "NIC name (NIC device)" -
            # e.g. "net0 (bge0)"
            # If NIC device is not populated, display just NIC name.
            #
            list_item_text = NetworkInfo.get_nic_desc(nic)

            # list item width
            self.list_area.columns = len(list_item_text) + 1

            list_item = ListItem(self.list_area, window=self.list_region,
                                 text=list_item_text, data_obj=nic)
            if NetworkInfo.get_nic_name(nic) == selected_nic_name:
                selected_nic = list_item
            y_loc += 1
        
        self.main_win.do_update()
        if self.scroll_region:
            self.center_win.activate_object(self.scroll_region)
            self.scroll_region.activate_object_force(selected_nic,
                                                     force_to_top=True)
        else:
            self.center_win.activate_object(selected_nic)