Esempio n. 1
0
    def iface_details(context):
        tui.update_help_line([' ', ' '])

        nic = conf[context]

        table = [("Name:", nic.name), ("Driver:", nic.driver),
                 ("MAC Address:", nic.hwaddr),
                 ("Link Status:", netutil.linkUp(context) and 'Up' or 'Down')]

        snackutil.TableDialog(tui.screen, "Interface Details", *table)
        tui.screen.popHelpLine()
        return True
Esempio n. 2
0
 def lentry(iface):
     key = iface
     tag = netutil.linkUp(iface) and '          ' or ' [no link]'
     text = "%s (%s)%s" % (iface, conf[iface].hwaddr, tag)
     return (text, key)
Esempio n. 3
0
def select_netif(text, conf, offer_existing=False, default=None):
    """ Display a screen that displays a choice of network interfaces to the
    user, with 'text' as the informative text as the data, and conf being the
    netutil.scanConfiguration() output to be used. 
    """

    netifs = conf.keys()
    netifs.sort(lambda l, r: int(l[3:]) - int(r[3:]))

    if default not in netifs:
        # find first link that is up
        default = None
        for iface in netifs:
            if netutil.linkUp(iface):
                default = iface
                break

    def lentry(iface):
        key = iface
        tag = netutil.linkUp(iface) and '          ' or ' [no link]'
        text = "%s (%s)%s" % (iface, conf[iface].hwaddr, tag)
        return (text, key)

    def iface_details(context):
        tui.update_help_line([' ', ' '])
        if context:
            nic = conf[context]

            table = [("Name:", nic.name), ("Driver:", nic.driver),
                     ("MAC Address:", nic.hwaddr),
                     ("PCI Details:", nic.pci_string)]
            if nic.smbioslabel != "":
                table.append(("BIOS Label:", nic.smbioslabel))

            snackutil.TableDialog(tui.screen, "Interface Details", *table)
        else:
            netifs_all = netutil.getNetifList(include_vlan=True)
            details = map(lambda x: (x, netutil.ipaddr(x)),
                          filter(netutil.interfaceUp, netifs_all))
            snackutil.TableDialog(tui.screen, "Networking Details", *details)
        tui.screen.popHelpLine()
        return True

    def update(listbox):
        old = listbox.current()
        for item in listbox.item2key.keys():
            if item:
                text, _ = lentry(item)
                listbox.replace(text, item)
        listbox.setCurrent(old)
        return True

    tui.update_help_line([None, "<F5> more info"])

    def_iface = None
    if offer_existing and netutil.networkingUp():
        netif_list = [("Use existing configuration", None)]
    else:
        netif_list = []
        if default:
            def_iface = lentry(default)
    netif_list += [lentry(x) for x in netifs]
    scroll, height = snackutil.scrollHeight(6, len(netif_list))
    rc, entry = snackutil.ListboxChoiceWindowEx(tui.screen,
                                                "Networking",
                                                text,
                                                netif_list, ['Ok', 'Back'],
                                                45,
                                                scroll,
                                                height,
                                                def_iface,
                                                help='selif:info',
                                                hotkeys={'F5': iface_details},
                                                timeout_ms=5000,
                                                timeout_cb=update)

    tui.screen.popHelpLine()

    if rc == 'back': return LEFT_BACKWARDS, None
    return RIGHT_FORWARDS, entry
Esempio n. 4
0
File: network.py Progetto: xtha/pxe
 def lentry(iface):
     key = iface
     tag = netutil.linkUp(iface) and '          ' or ' [no link]'
     text = "%s (%s)%s" % (iface, conf[iface].hwaddr, tag)
     return (text, key)
Esempio n. 5
0
File: network.py Progetto: xtha/pxe
def select_netif(text, conf, offer_existing = False, default = None):
    """ Display a screen that displays a choice of network interfaces to the
    user, with 'text' as the informative text as the data, and conf being the
    netutil.scanConfiguration() output to be used. 
    """

    netifs = conf.keys()
    netifs.sort(lambda l, r: int(l[3:]) - int(r[3:]))

    if default not in netifs:
        # find first link that is up
        default = None
        for iface in netifs:
            if netutil.linkUp(iface):
                default = iface
                break

    def lentry(iface):
        key = iface
        tag = netutil.linkUp(iface) and '          ' or ' [no link]'
        text = "%s (%s)%s" % (iface, conf[iface].hwaddr, tag)
        return (text, key)

    def iface_details(context):
        tui.update_help_line([' ', ' '])
        if context:
            nic = conf[context]

            table = [ ("Name:", nic.name),
                      ("Driver:", nic.driver),
                      ("MAC Address:", nic.hwaddr),
                      ("PCI Details:", nic.pci_string) ]
            if nic.smbioslabel != "":
                table.append(("BIOS Label:", nic.smbioslabel))

            snackutil.TableDialog(tui.screen, "Interface Details", *table)
        else:
            details = map(lambda x: (x, netutil.ipaddr(x)), filter(netutil.interfaceUp, netifs))

            snackutil.TableDialog(tui.screen, "Networking Details", *details)
        tui.screen.popHelpLine()
        return True

    def update(listbox):
        old = listbox.current()
        for item in listbox.item2key.keys():
            if item:
                text, _ = lentry(item)
                listbox.replace(text, item)
        listbox.setCurrent(old)
        return True

    tui.update_help_line([None, "<F5> more info"])

    def_iface = None
    if offer_existing and netutil.networkingUp():
        netif_list = [("Use existing configuration", None)]
    else:
        netif_list = []
        if default:
            def_iface = lentry(default)
    netif_list += [lentry(x) for x in netifs]
    scroll, height = snackutil.scrollHeight(6, len(netif_list))
    rc, entry = snackutil.ListboxChoiceWindowEx(tui.screen, "Networking", text, netif_list,
                                        ['Ok', 'Back'], 45, scroll, height, def_iface, help = 'selif:info',
                                        hotkey='F5', hotkey_cb=iface_details, timeout_ms=5000, timeout_cb=update)

    tui.screen.popHelpLine()

    if rc == 'back': return LEFT_BACKWARDS, None
    return RIGHT_FORWARDS, entry