Add dns by dhcp.

lvmraid
Mike Hiretsky 13 years ago
parent 9d0798189e
commit b29c10db8c

@ -1104,13 +1104,21 @@ class fillVars(object, glob_attr):
else:
return ""
def isDNSByDHCP(self):
"""If first interface get ip by DHCP dns must be DHCP"""
dhcps = self.Get('os_install_net_dhcp_set')
if dhcps:
if dhcps[0] == "on":
return True
return False
def get_os_install_net_dns(self):
"""Get current name servers"""
dnsIps = filter(ip.checkIp,
map(lambda x:x.strip().partition("nameserver")[2].strip(),
filter(lambda x:x.lstrip().startswith("nameserver"),
readLinesFile('/etc/resolv.conf'))))
return " ".join(dnsIps)
return "" if self.isDNSByDHCP() else " ".join(dnsIps)
def get_os_install_net_dns_search(self):
"""Get current name servers"""
@ -1118,7 +1126,7 @@ class fillVars(object, glob_attr):
map(lambda x:x.strip().partition("search")[2].strip(),
filter(lambda x:x.lstrip().startswith("search"),
readLinesFile('/etc/resolv.conf'))))
return dnsSearch
return "" if self.isDNSByDHCP() else dnsSearch
def get_os_install_net_conf(self):
"""Net setup (networkmanager or openrc)"""

@ -864,6 +864,12 @@ class cl_install(color_print, SignalInterrupt):
else:
musers = _("none")
dnsNoValue = _("none")
dhcps = self.clVars.Get('os_install_net_dhcp_set')
if dhcps:
if dhcps[0] == "on":
dnsNoValue = _("DHCP")
self.printSUCCESS(_("Installation") + " Calculate Linux")
printData = [
[(_("System"),True),
@ -883,7 +889,7 @@ class cl_install(color_print, SignalInterrupt):
(_("PROXY"),
clGet('os_install_proxy') or _("none"),True),
(_("NTP"),clGet('os_install_ntp') or _("none"),True),
(_("DNS"),clGet('os_install_net_dns') or _("none"),True)
(_("DNS"),clGet('os_install_net_dns') or dnsNoValue,True)
],
[(_("Hardware"),True),
(_("Machine hardware name"),

@ -228,8 +228,8 @@ class install_cmd(share_cmd):
" " + _("ip specifing error: '{ip}' "
"(example: '{example}')").format(\
ip=ipaddr,example="eth0:192.168.0.21/16"))
if values.dns:
if not re.match("^{0}(,{0})*$".format(iputils.IP_ADDR),values.dns):
if not values.dns is None:
if not re.match("(^{0}(,{0})*|)$".format(iputils.IP_ADDR),values.dns):
self.optobj.error(_("option %s:") %"--dns" +\
" " + _("dns specifing error: '%s'") %\
values.dns)
@ -319,7 +319,7 @@ class install_cmd(share_cmd):
def setNetworkParams(self,ipaddrs,routes,dns,setup,dhcps):
"""Set nework params"""
if dns:
if not dns is None:
self.logicObj.clVars.Set("os_install_net_dns",dns,True)
ipaddrs = map(lambda x:x.split(":"),ipaddrs or [])
routes = map(lambda x:x+[""]*(4-len(x)),

Loading…
Cancel
Save