Joey Boggs
2011-Jul-18 17:19 UTC
[Ovirt-devel] [PATCH node] fix ipv6 support in dns/ntp callbacks
Signed-off-by: Joey Boggs <jboggs at redhat.com> --- scripts/ovirt-config-setup.py | 42 +++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/ovirt-config-setup.py b/scripts/ovirt-config-setup.py index d55ea36..753c80d 100755 --- a/scripts/ovirt-config-setup.py +++ b/scripts/ovirt-config-setup.py @@ -231,7 +231,8 @@ class NodeConfigScreen(): warn = 0 if not self.dns_host1.value() is None and not self.dns_host1.value() == "": if not is_valid_ipv4(self.dns_host1.value()): - warn = 1 + if not is_valid_ipv6(self.dns_host1.value()): + warn = 1 if warn == 1: self.screen.setColor("BUTTON", "black", "red") self.screen.setColor("ACTBUTTON", "blue", "white") @@ -244,7 +245,8 @@ class NodeConfigScreen(): warn = 0 if not self.dns_host2.value() is None and not self.dns_host2.value() == "": if not is_valid_ipv4(self.dns_host2.value()): - warn = 1 + if not is_valid_ipv6(self.dns_host1.value()): + warn = 1 if warn == 1: self.screen.setColor("BUTTON", "black", "red") self.screen.setColor("ACTBUTTON", "blue", "white") @@ -253,6 +255,34 @@ class NodeConfigScreen(): self.reset_screen_colors() return + def ntp_host1_callback(self): + warn = 0 + if not self.ntp_host1.value() is None and not self.ntp_host1.value() == "": + if not is_valid_ipv4(self.ntp_host1.value()): + if not is_valid_ipv6(self.ntp_host1.value()): + warn = 1 + if warn == 1: + self.screen.setColor("BUTTON", "black", "red") + self.screen.setColor("ACTBUTTON", "blue", "white") + ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address", buttons = ['Ok']) + self.ntp_host1.set("") + self.reset_screen_colors() + return + + def ntp_host2_callback(self): + warn = 0 + if not self.ntp_host2.value() is None and not self.ntp_host2.value() == "": + if not is_valid_ipv4(self.ntp_host2.value()): + if not is_valid_ipv6(self.ntp_host1.value()): + warn = 1 + if warn == 1: + self.screen.setColor("BUTTON", "black", "red") + self.screen.setColor("ACTBUTTON", "blue", "white") + ButtonChoiceWindow(self.screen, "Network", "Invalid IP Address", buttons = ['Ok']) + self.ntp_host2.set("") + self.reset_screen_colors() + return + def ipv4_ip_callback(self): warn = 0 if not self.ipv4_netdevip.value() is None and not self.ipv4_netdevip.value() == "": @@ -708,16 +738,16 @@ class NodeConfigScreen(): dns_grid.setField(Label("DNS Server 2: "), 0, 1, anchorLeft = 1) dns_grid.setField(self.dns_host1, 1, 0, anchorLeft = 1) dns_grid.setField(self.dns_host2, 1, 1, anchorLeft = 1) - self.dns_host1.setCallback(self.valid_fqdn_or_ipv4) - self.dns_host2.setCallback(self.valid_fqdn_or_ipv4) grid.setField(Label(" "), 0, 4) grid.setField(dns_grid, 0, 6, anchorLeft =1) grid.setField(Label(" "), 0, 7) ntp_grid = Grid(2,2) self.ntp_host1 = Entry(25) - self.ntp_host1.setCallback(self.valid_fqdn_or_ipv4) + self.ntp_host1.setCallback(self.ntp_host1_callback) + self.ntp_host2 = Entry(25) - self.ntp_host2.setCallback(self.valid_fqdn_or_ipv4) + self.ntp_host2.setCallback(self.ntp_host2_callback) + self.current_ntp_host1 = augtool_get("/files/etc/ntp.conf/server[1]") if self.current_ntp_host1: self.ntp_host1.set(self.current_ntp_host1) -- 1.7.5.4