diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-03-21 00:09:53 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-03-21 00:09:53 +0000 |
commit | c29f0955045cdd02965a14300ce5e99364db2d1b (patch) | |
tree | d84a948b5288d9b0b9bd28649f608b8df9f18ea0 /textw | |
parent | 720f69db5a6df4a3d6afe90ea228b5a90fe41333 (diff) | |
download | anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.tar.gz anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.tar.xz anaconda-c29f0955045cdd02965a14300ce5e99364db2d1b.zip |
merge taroon branch up until now. tagged as before-taroon-merge before and
will be tagged after-taroon-merge after. taroon at this point is tagged
taroon-merge-point for where to base merges from in the future
Diffstat (limited to 'textw')
-rw-r--r-- | textw/network_text.py | 437 | ||||
-rw-r--r-- | textw/partition_text.py | 32 | ||||
-rw-r--r-- | textw/zipl_text.py | 11 |
3 files changed, 309 insertions, 171 deletions
diff --git a/textw/network_text.py b/textw/network_text.py index b9305475a..1419fb806 100644 --- a/textw/network_text.py +++ b/textw/network_text.py @@ -1,7 +1,10 @@ # # network_text.py: text mode network configuration dialogs # -# Copyright 2000-2002 Red Hat, Inc. +# Jeremy Katz <katzj@redhat.com> +# Michael Fulbright <msf@redhat.com> +# +# Copyright 2000-2003 Red Hat, Inc. # # This software may be freely redistributed under the terms of the GNU # library public license. @@ -14,174 +17,149 @@ import iutil import os import isys +import string +from network import isPtpDev, anyUsingDHCP, sanityCheckIPString +from network import sanityCheckHostname from snack import * from constants_text import * from rhpl.translate import _ -class NetworkWindow: - def setsensitive (self): - if self.cb.selected (): + +def badIPDisplay(screen, the_ip): + ButtonChoiceWindow(screen, _("Invalid IP string"), + _("The entered IP '%s' is not a valid IP.") %(the_ip,), + buttons = [ _("OK") ]) + return + +class NetworkDeviceWindow: + def setsensitive(self): + if self.dhcpCb.selected (): sense = FLAGS_SET else: sense = FLAGS_RESET - for n in self.ip, self.nm, self.gw, self.ns, self.ns2, self.ns3: + for n in self.entries.values(): n.setFlags (FLAG_DISABLED, sense) - def calcNM (self): - ip = self.ip.value () - if ip and not self.nm.value (): + def calcNM(self): + ip = self.entries["ipaddr"].value() + if ip and not self.entries["netmask"].value (): try: mask = "255.255.255.0" except ValueError: return - self.nm.set (mask) - - def calcGW (self): - ip = self.ip.value () - nm = self.nm.value () - if ip and nm: - try: - (net, bcast) = isys.inet_calcNetBroad (ip, nm) - except ValueError: - return - - if not self.gw.value (): - gw = isys.inet_calcGateway (bcast) - self.gw.set (gw) - if not self.ns.value (): - ns = isys.inet_calcNS (net) - self.ns.set (ns) - + self.entries["netmask"].set (mask) + def runScreen(self, screen, network, dev): - - firstg = Grid (1, 3) - boot = dev.get ("bootproto") - onboot = dev.get('onboot') + boot = dev.get("bootproto") + onboot = dev.get("onboot") onbootIsOn = ((dev == network.available().values()[0] and not onboot) - or onboot == 'yes') - + or onboot == "yes") if not boot: boot = "dhcp" - firstg.setField (Label (_("Network Device: %s") % - (dev.info['DEVICE'],)), - 0, 0, padding = (0, 0, 0, 1), anchorLeft = 1) - self.cb = Checkbox (_("Use bootp/dhcp"), - isOn = (boot == "dhcp")) - firstg.setField (self.cb, 0, 1, anchorLeft = 1) - self.onboot = Checkbox(_("Activate on boot"), isOn = onbootIsOn) - firstg.setField (self.onboot, 0, 2, anchorLeft = 1) - - ask_ptp = None - if len(dev.info["DEVICE"]) >= 3 and dev.info["DEVICE"][:3] == "ctc": - ask_ptp = 1 - secondg = Grid (2, 7) - else: - secondg = Grid (2, 6) - - secondg.setField (Label (_("IP address:")), 0, 0, anchorLeft = 1) - secondg.setField (Label (_("Netmask:")), 0, 1, anchorLeft = 1) - secondg.setField (Label (_("Default gateway (IP):")), 0, 2, - anchorLeft = 1) - secondg.setField (Label (_("Primary nameserver:")), 0, 3, - anchorLeft = 1) - secondg.setField (Label (_("Secondary nameserver:")), 0, 4, - anchorLeft = 1) - secondg.setField (Label (_("Tertiary nameserver:")), 0, 5, - anchorLeft = 1) - if ask_ptp: - secondg.setField (Label (_("Point to Point (IP):")), 0, 6, - anchorLeft = 1) + + options = [(_("IP Address"), "ipaddr"), + (_("Netmask"), "netmask")] + if (isPtpDev(dev.info["DEVICE"])): + newopt = (_("Point to Point (IP)"), "remip") + options.append(newopt) + + thegrid = Grid(2, 3 + len(options)) + + thegrid.setField(Label (_("Network Device: %s") + %(dev.info['DEVICE'],)), + 0, 0, padding = (0, 0, 0, 1), anchorLeft = 1, + growx = 1) + + self.dhcpCb = Checkbox(_("Configure using DHCP"), + isOn = (boot == "dhcp")) + thegrid.setField(self.dhcpCb, 0, 1, anchorLeft = 1, growx = 1) - self.ip = Entry (16) - self.ip.set (dev.get ("ipaddr")) - self.nm = Entry (16) - self.nm.set (dev.get ("netmask")) - self.gw = Entry (16) - self.gw.set (network.gateway) - self.ns = Entry (16) - self.ns.set (network.primaryNS) - self.ns2 = Entry (16) - self.ns2.set (network.secondaryNS) - self.ns3 = Entry (16) - self.ns3.set (network.ternaryNS) - if ask_ptp: - self.ptp = Entry(16) - self.ptp.set (dev.get ("remip")) + self.onbootCb = Checkbox(_("Activate on boot"), isOn = onbootIsOn) + thegrid.setField(self.onbootCb, 0, 2, anchorLeft = 1, growx = 1, + padding = (0, 0, 0, 1)) - - self.cb.setCallback (self.setsensitive) - self.ip.setCallback (self.calcNM) - self.nm.setCallback (self.calcGW) - - secondg.setField (self.ip, 1, 0, (1, 0, 0, 0)) - secondg.setField (self.nm, 1, 1, (1, 0, 0, 0)) - secondg.setField (self.gw, 1, 2, (1, 0, 0, 0)) - secondg.setField (self.ns, 1, 3, (1, 0, 0, 0)) - secondg.setField (self.ns2, 1, 4, (1, 0, 0, 0)) - secondg.setField (self.ns3, 1, 5, (1, 0, 0, 0)) - if ask_ptp: - secondg.setField (self.ptp, 1, 6, (1, 0, 0, 0)) + row = 3 + self.entries = {} + for (name, opt) in options: + thegrid.setField(Label(name), 0, row, anchorLeft = 1) - bb = ButtonBar (screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) + entry = Entry (16) + entry.set(dev.get(opt)) + thegrid.setField(entry, 1, row, padding = (1, 0, 0, 0)) - toplevel = GridFormHelp (screen, _("Network Configuration for %s") % - (dev.info['DEVICE']), - "network", 1, 3) - toplevel.add (firstg, 0, 0, (0, 0, 0, 1), anchorLeft = 1) - toplevel.add (secondg, 0, 1, (0, 0, 0, 1)) - toplevel.add (bb, 0, 2, growx = 1) + self.entries[opt] = entry + + row = row + 1 + + self.dhcpCb.setCallback(self.setsensitive) + self.entries["ipaddr"].setCallback(self.calcNM) + + bb = ButtonBar(screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) - self.setsensitive () + toplevel = GridFormHelp(screen, _("Network Configuration for %s") % + (dev.info['DEVICE']), + "networkdev", 1, 3) + toplevel.add(thegrid, 0, 0, (0, 0, 0, 1), anchorLeft = 1) + toplevel.add(bb, 0, 2, growx = 1) + self.setsensitive() + while 1: - result = toplevel.run () - if self.onboot.selected() != 0: - dev.set (('onboot', 'yes')) + result = toplevel.run() + rc = bb.buttonPressed (result) + screen.popWindow() + + if rc == TEXT_BACK_CHECK: + return INSTALL_BACK + + if self.onbootCb.selected() != 0: + dev.set(("onboot", "yes")) else: - dev.unset ('onboot') - if self.cb.selected (): - dev.set (("bootproto", "dhcp")) - dev.unset ("ipaddr", "netmask", "network", "broadcast", "remip") + dev.unset("onboot") + + if self.dhcpCb.selected() != 0: + dev.set(("bootproto", "dhcp")) + dev.unset("ipaddr", "netmask", "network", "broadcast", "remip") else: + ip = self.entries["ipaddr"].value() + nm = self.entries["netmask"].value() try: - (net, bc) = isys.inet_calcNetBroad (self.ip.value (), - self.nm.value ()) + (net, bc) = isys.inet_calcNetBroad(ip, nm) except: - ButtonChoiceWindow(screen, _("Invalid information"), - _("You must enter valid IP information to continue"), - buttons = [ _("OK") ]) - continue + if self.onbootCb.selected() != 0: + ButtonChoiceWindow(screen, _("Invalid information"), + _("You must enter valid IP " + "information to continue"), + buttons = [ _("OK") ]) + continue + else: + net = "" + bc = "" - dev.set (("bootproto", "static")) - dev.set (("ipaddr", self.ip.value ()), ("netmask", - self.nm.value ()), - ("network", net), ("broadcast", bc)) - if ask_ptp: - dev.set (("remip", self.ptp.value())) - network.gateway = self.gw.value () - network.primaryNS = self.ns.value () - network.secondaryNS = self.ns2.value() - network.ternaryNS = self.ns3.value() + dev.set(("bootproto", "static")) + + for val in self.entries.keys(): + if self.entries[val].value(): + dev.set((val, self.entries[val].value())) + + if bc and net: + dev.set(("broadcast", bc), ("network", net)) - screen.popWindow() break - - rc = bb.buttonPressed (result) - if rc == TEXT_BACK_CHECK: - return INSTALL_BACK return INSTALL_OK + def __call__(self, screen, network, dir, intf): - devices = network.available () + devices = network.available() if not devices: return INSTALL_NOOP - list = devices.keys () - list.sort() + list = devices.keys() + list.sort() devLen = len(list) if dir == 1: currentDev = 0 @@ -200,33 +178,202 @@ class NetworkWindow: else: return INSTALL_OK -class HostnameWindow: +class NetworkGlobalWindow: + def getFirstGatewayGuess(self, devices): + list = devices.keys() + list.sort() + for dev in list: + thedev = devices[dev] + bootproto = thedev.get("bootproto") + if bootproto and bootproto == "dhcp": + continue + onboot = thedev.get("onboot") + if onboot and onboot == "no": + continue + bcast = thedev.get("broadcast") + if not bcast: + continue + return isys.inet_calcGateway(bcast) + return "" + def __call__(self, screen, network, dir, intf): - devices = network.available () + devices = network.available() if not devices: return INSTALL_NOOP - list = devices.keys () - list.sort() - dev = devices[list[0]] - if dev.get ("bootproto") == "dhcp": + # we don't let you set gateway/dns if you've got any interfaces + # using dhcp (for better or worse) + if anyUsingDHCP(devices): return INSTALL_NOOP + + thegrid = Grid(2, 4) + + thegrid.setField(Label(_("Gateway:")), 0, 0, anchorLeft = 1) + gwEntry = Entry(16) + # if it's set already, use that... otherwise, get the first + # non-dhcp and active device and use it to guess the gateway + if network.gateway: + gwEntry.set(network.gateway) + else: + gwEntry.set(self.getFirstGatewayGuess(devices)) + thegrid.setField(gwEntry, 1, 0, padding = (1, 0, 0, 0)) + + thegrid.setField(Label(_("Primary DNS:")), 0, 1, anchorLeft = 1) + ns1Entry = Entry(16) + ns1Entry.set(network.primaryNS) + thegrid.setField(ns1Entry, 1, 1, padding = (1, 0, 0, 0)) + + thegrid.setField(Label(_("Secondary DNS:")), 0, 2, anchorLeft = 1) + ns2Entry = Entry(16) + ns2Entry.set(network.secondaryNS) + thegrid.setField(ns2Entry, 1, 2, padding = (1, 0, 0, 0)) + + thegrid.setField(Label(_("Tertiary DNS:")), 0, 3, anchorLeft = 1) + ns3Entry = Entry(16) + ns3Entry.set(network.ternaryNS) + thegrid.setField(ns3Entry, 1, 3, padding = (1, 0, 0, 0)) + + bb = ButtonBar (screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) + + toplevel = GridFormHelp (screen, _("Miscellaneous Network Settings"), + "miscnetwork", 1, 3) + toplevel.add (thegrid, 0, 0, (0, 0, 0, 1), anchorLeft = 1) + toplevel.add (bb, 0, 2, growx = 1) + + while 1: + result = toplevel.run() + rc = bb.buttonPressed (result) + screen.popWindow() + + if rc == TEXT_BACK_CHECK: + return INSTALL_BACK + + val = gwEntry.value() + if val and sanityCheckIPString(val) is None: + badIPDisplay(screen, val) + continue + network.gateway = val + + val = ns1Entry.value() + if val and sanityCheckIPString(val) is None: + badIPDisplay(screen, val) + continue + network.primaryNS = val + + val = ns2Entry.value() + if val and sanityCheckIPString(val) is None: + badIPDisplay(screen, val) + continue + network.secondaryNS = val + + val = ns3Entry.value() + if val and sanityCheckIPString(val) is None: + badIPDisplay(screen, val) + continue + network.ternaryNS = val + break + + return INSTALL_OK - entry = Entry (24) +class HostnameWindow: + def hostTypeCb(self, (radio, hostEntry)): + if radio.getSelection() != "manual": + sense = FLAGS_SET + else: + sense = FLAGS_RESET + + hostEntry.setFlags(FLAG_DISABLED, sense) + + def __call__(self, screen, network, dir, intf): + devices = network.available () + if not devices: + return INSTALL_NOOP + + # figure out if the hostname is currently manually set + if anyUsingDHCP(devices): + if (network.hostname != "localhost.localdomain" and + network.overrideDHCPhostname): + manual = 1 + else: + manual = 0 + else: + manual = 1 + + thegrid = Grid(2, 2) + radio = RadioGroup() + autoCb = radio.add(_("automatically via DHCP"), "dhcp", + not manual) + thegrid.setField(autoCb, 0, 0, growx = 1, anchorLeft = 1) + + manualCb = radio.add(_("manually"), "manual", manual) + thegrid.setField(manualCb, 0, 1, anchorLeft = 1) + hostEntry = Entry(24) if network.hostname != "localhost.localdomain": - entry.set (network.hostname) + hostEntry.set(network.hostname) + thegrid.setField(hostEntry, 1, 1, padding = (1, 0, 0, 0), + anchorLeft = 1) - rc, values = EntryWindow(screen, _("Hostname Configuration"), - _("The hostname is the name of your computer. If your " - "computer is attached to a network, this may be " - "assigned by your network administrator."), - [(_("Hostname"), entry)], buttons = [ TEXT_OK_BUTTON, TEXT_BACK_BUTTON], - help = "hostname") + # disable the dhcp if we don't have any dhcp + if anyUsingDHCP(devices): + autoCb.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) + else: + autoCb.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) - if rc == TEXT_BACK_CHECK: - return INSTALL_BACK + self.hostTypeCb((radio, hostEntry)) + + autoCb.setCallback(self.hostTypeCb, (radio, hostEntry)) + manualCb.setCallback(self.hostTypeCb, (radio, hostEntry)) + + toplevel = GridFormHelp(screen, _("Hostname Configuration"), + "hostname", 1, 4) + text = TextboxReflowed(55, + _("If your system is part of a larger network " + "where hostnames are assigned by DHCP, " + "select automatically via DHCP. Otherwise, " + "select manually and enter in a hostname for " + "your system. If you do not, your system " + "will be known as 'localhost.'")) + toplevel.add(text, 0, 0, (0, 0, 0, 1)) + + bb = ButtonBar(screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) + toplevel.add(thegrid, 0, 1, padding = (0, 0, 0, 1)) + toplevel.add(bb, 0, 2, growx = 1) + + while 1: + result = toplevel.run() + rc = bb.buttonPressed(result) + screen.popWindow() + + if rc == TEXT_BACK_CHECK: + return INSTALL_BACK - network.hostname = entry.value () + if radio.getSelection != "manual": + network.overrideDHCPhostname = 0 + network.hostname = "localhost.localdomain" + else: + hname = string.strip(hostEntry.value()) + if len(hname) == 0: + ButtonChoiceWindow(_("Invalid Hostname"), + _("You have not specified a hostname."), + buttons = [ _("OK") ]) + continue + neterrors = sanityCheckHostname(hname) + if neterrors is not None: + ButtonChoiceWindow(_("Invalid Hostname"), + _("The hostname \"%s\" is not valid " + "for the following reason:\n\n%s") + %(hname, neterrors), + buttons = [ _("OK") ]) + continue + + network.overrideDHCPhostname = 1 + network.hostname = hname + break return INSTALL_OK + + + + + diff --git a/textw/partition_text.py b/textw/partition_text.py index a0e70bd8e..a963ac9c2 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -1074,22 +1074,13 @@ class PartitionWindow: if type == "RAID": self.editRaidRequest(request) elif type == "NEW": - if iutil.getArch() == "s390": - self.intf.messageWindow(_("Error"), - _("You must go back and use fdasd to initialize this partition")) - else: - self.editPartitionRequest(request, isNew = 1) + self.editPartitionRequest(request, isNew = 1) else: self.editPartitionRequest(request) def deleteCb(self): partition = self.lb.current() - if iutil.getArch() == "s390" and type(partition) != type("RAID"): - self.intf.messageWindow(_("Error"), - _("DASD partitions can only be deleted with fdasd")) - return - if doDeletePartitionByRequest(self.intf, self.partitions, partition): self.refresh() @@ -1127,20 +1118,13 @@ class PartitionWindow: col_label_align=[CENTER, CENTER,CENTER,CENTER,CENTER,CENTER]) self.g.add(self.lb, 0, 1) - if iutil.getArch() == "s390": - self.bb = ButtonBar (screen, ((_("Edit"), "edit", "F3"), - (_("Delete"), "delete", "F4"), - (_("RAID"), "raid", "F11"), - TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) - screen.pushHelpLine( _(" F1-Help F3-Edit F4-Delete F5-Reset F12-OK ")) - else: - self.bb = ButtonBar (screen, ((_("New"), "new", "F2"), - (_("Edit"), "edit", "F3"), - (_("Delete"), "delete", "F4"), - (_("RAID"), "raid", "F11"), - TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) - - screen.pushHelpLine( _(" F1-Help F2-New F3-Edit F4-Delete F5-Reset F12-OK ")) + self.bb = ButtonBar (screen, ((_("New"), "new", "F2"), + (_("Edit"), "edit", "F3"), + (_("Delete"), "delete", "F4"), + (_("RAID"), "raid", "F11"), + TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) + + screen.pushHelpLine( _(" F1-Help F2-New F3-Edit F4-Delete F5-Reset F12-OK ")) self.g.add(self.bb, 0, 2, (0, 1, 0, 0)) self.g.addHotKey("F5") diff --git a/textw/zipl_text.py b/textw/zipl_text.py index 69a85f7f8..7503c5cf4 100644 --- a/textw/zipl_text.py +++ b/textw/zipl_text.py @@ -12,6 +12,8 @@ # import iutil +import isys +import string from snack import * from constants_text import * from rhpl.translate import _ @@ -25,12 +27,16 @@ class ZiplWindow: "chandev parameters which your machine or your " "setup may require.")) + kernelparms = "" kernelentry = Entry(48, scroll = 1, returnExit = 1) chandeventry1 = Entry(48, scroll = 1, returnExit = 1) chandeventry2 = Entry(48, scroll = 1, returnExit = 1) if bl.args and bl.args.get(): - kernelentry.set(bl.args.get()) + kernelparms = bl.args.get() + if isys.getDasdPorts(): + kernelparms = kernelparms + " dasd=" + isys.getDasdPorts() + kernelentry.set(kernelparms) if bl.args and bl.args.chandevget(): cdevs = bl.args.chandevget() @@ -51,14 +57,15 @@ class ZiplWindow: sg.setField(Label(_("Kernel Parameters") + ": "), 0, 0, anchorLeft=1) sg.setField(kernelentry, 1, 0, anchorLeft=1) grid.add(sg, 0, 1, padding = (0, 1, 0, 1)) + sg = Grid(2, 1) sg.setField(Label(_("Chandev line ") + "1: "), 0, 0, anchorLeft=1) sg.setField(chandeventry1, 1, 0, anchorLeft=1) + grid.add(sg, 0, 2, padding = (0, 1, 0, 1)) sg = Grid(2, 1) sg.setField(Label(_("Chandev line ") + "2: "), 0, 0, anchorLeft=1) sg.setField(chandeventry2, 1, 0, anchorLeft=1) grid.add(sg, 0, 3, padding = (0, 1, 0, 1)) grid.add(buttons, 0, 4, growx = 1) - sg = Grid(2, 1) result = grid.runOnce () button = buttons.buttonPressed(result) |