summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-09-06 19:51:30 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-09-06 19:51:30 +0000
commit3095a8aa47ebfc01ed68583ad281555a0fc1cdd1 (patch)
tree36f7a8bf7b74531310a37bcc0238bb9f7b577f6b
parent29fb5585a9404ed478814f019c0dbc57339b5ce6 (diff)
downloadanaconda-3095a8aa47ebfc01ed68583ad281555a0fc1cdd1.tar.gz
anaconda-3095a8aa47ebfc01ed68583ad281555a0fc1cdd1.tar.xz
anaconda-3095a8aa47ebfc01ed68583ad281555a0fc1cdd1.zip
* isys/isys.py (inet_convertPrefixToNetmask): Take IPv4 CIDR prefix
and convert to dotted-quad netmask notation. * iw/network_gui.py (NetworkWindow.editDevices): Allow user to enter CIDR prefix or dotted-quad netmask for IPv4 settings, validate the IPv4 and IPv6 prefix and make sure they fall within the required range, if user enters IPv4 CIDR prefix then convert to dotted-quad netmask for the sysconfig ifcfg-ethX file. * iw/network_gui.py (NetworkWindow.editDevices): Call get_text() to get the value of the ipv6prefix box rather than using an instance of a gtk.Entry() object. * iw/network_gui.py (NetworkWindow.getScreen): Set hostname, gateway, and DNS entry boxes to be 41 characters wide.
-rw-r--r--ChangeLog20
-rw-r--r--isys/isys.py7
-rw-r--r--iw/network_gui.py37
3 files changed, 55 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index b4fdafdd9..0de017741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2006-09-06 David Cantrell <dcantrell@redhat.com>
+ * isys/isys.py (inet_convertPrefixToNetmask): Take IPv4 CIDR prefix
+ and convert to dotted-quad netmask notation.
+
+ * iw/network_gui.py (NetworkWindow.editDevices): Allow user to enter
+ CIDR prefix or dotted-quad netmask for IPv4 settings, validate the
+ IPv4 and IPv6 prefix and make sure they fall within the required
+ range, if user enters IPv4 CIDR prefix then convert to dotted-quad
+ netmask for the sysconfig ifcfg-ethX file.
+
+ * iw/network_gui.py (NetworkWindow.editDevices): Call get_text() to
+ get the value of the ipv6prefix box rather than using an instance of
+ a gtk.Entry() object.
+
+ * iw/network_gui.py (NetworkWindow.getScreen): Set hostname, gateway,
+ and DNS entry boxes to be 41 characters wide.
+
+2006-09-06 David Cantrell <dcantrell@redhat.com>
+
* isys/isys.py: Remove inet_aton() and inet_ntoa(). Replaced calls
to these functions with inet_pton() and inet_ntop().
@@ -12,7 +30,7 @@
* iw/network_gui.py (createIPV4Repr): Added to handle IPv6 write
outs to the tree store.
- * iw/network_gui.py (NetworkWindow.editDevice): Add IPv6 info to
+ * iw/network_gui.py (NetworkWindow.editDevices): Add IPv6 info to
the tree store.
* iw/network_gui.py (NetworkWindow.setupDevices): Initialize tree
diff --git a/isys/isys.py b/isys/isys.py
index da51abd4d..7133a6074 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -444,6 +444,13 @@ def inet_convertNetmaskToPrefix (netmask):
return prefix
+# Converts IPv4 CIDR prefix to a dotted-quad netmask
+def inet_convertPrefixToNetmask (prefix):
+ (m,) = struct.unpack('I',socket.inet_pton(socket.AF_INET,'255.255.255.255'))
+ tmp = m >> (32 - int(prefix))
+ ret = socket.inet_ntop(socket.AF_INET, struct.pack('i', tmp))
+ return ret
+
def getopt(*args):
warnings.warn("isys.getopt is deprecated. Use optparse instead.",
DeprecationWarning, stacklevel=2)
diff --git a/iw/network_gui.py b/iw/network_gui.py
index bbf4aec96..e5381ce56 100644
--- a/iw/network_gui.py
+++ b/iw/network_gui.py
@@ -440,14 +440,35 @@ class NetworkWindow(InstallWindow):
valsgood = 1
tmpvals = {}
for t in entrys.keys():
- if t == "ipaddr" or t == "netmask" or t == "remip" or t == "ipv6addr":
+ val = entrys[t].get_text()
+
+ if t == "ipaddr" or t == "netmask" or \
+ t == "remip" or t == "ipv6addr":
+
+ if t == "netmask" and val.find('.') == -1:
+ if int(val) > 32 or int(val) < 0:
+ self.intf.messageWindow(_("Invalid Prefix"),
+ _("IPv4 prefix must be "
+ "between 0 and 32."))
+ valsgood = 0
+ break
+ else:
+ val = isys.inet_convertPrefixToNetmask(val)
+
try:
- network.sanityCheckIPString(entrys[t].get_text())
- tmpvals[t] = entrys[t].get_text()
+ network.sanityCheckIPString(val)
+ tmpvals[t] = val
except network.IPMissing, msg:
self.handleIPMissing(t)
valsgood = 0
break
+ elif t == 'ipv6prefix':
+ if int(val) > 128 or int(val) < 0:
+ self.intf.messageWindow(_("Invalid Prefix"),
+ _("IPv6 prefix must be "
+ "between 0 and 128."))
+ valsgood = 0
+ break
if valsgood == 0:
continue
@@ -470,7 +491,8 @@ class NetworkWindow(InstallWindow):
if tmpvals.has_key(t):
if t == 'ipv6addr':
if entrys['ipv6prefix'] is not None:
- q = "%s/%s" % (tmpvals[t],entrys['ipv6prefix'],)
+ p = entrys['ipv6prefix'].get_text()
+ q = "%s/%s" % (tmpvals[t], p,)
else:
q = "%s" % (tmpvals[t],)
@@ -691,8 +713,9 @@ class NetworkWindow(InstallWindow):
self.hostnameManual = gtk.RadioButton(group=self.hostnameUseDHCP, label=_("_manually"))
tmphbox.pack_start(self.hostnameManual, False, False)
self.hostnameEntry = gtk.Entry()
+ self.hostnameEntry.set_width_chars(41)
tmphbox.pack_start(self.hostnameEntry, False, False)
- tmphbox.pack_start(gtk.Label(_('(ex. "host.domain.com")')), False, False)
+ tmphbox.pack_start(gtk.Label(_('(e.g., host.domain.com)')), False, False)
self.hostnameManual.connect("toggled", self.hostnameManualCB, None)
hostbox.pack_start(tmphbox, False, False)
@@ -708,10 +731,7 @@ class NetworkWindow(InstallWindow):
self.setHostOptionsSensitivity()
- #
- # this is the iptable used for DNS, et. al
self.ipTable = gtk.Table(len(global_options), 2)
-# self.ipTable.set_row_spacing(0, 5)
options = {}
for i in range(len(global_options)):
label = gtk.Label("%s:" %(global_option_labels[i],))
@@ -720,6 +740,7 @@ class NetworkWindow(InstallWindow):
self.ipTable.attach(label, 0, 1, i, i+1, gtk.FILL, 0)
align = gtk.Alignment(0, 0.5)
options[i] = gtk.Entry()
+ options[i].set_width_chars(41)
align.add(options[i])
label.set_mnemonic_widget(options[i])