Author: kmachalkova Date: Wed Nov 18 15:43:20 2009 New Revision: 59587 URL: http://svn.opensuse.org/viewcvs/yast?rev=59587&view=rev Log: Move getting/setting of network/dhcp vars to single place Modified: branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp branches/SuSE-Code-11-SP1-Branch/network/src/modules/Host.ycp branches/SuSE-Code-11-SP1-Branch/network/src/services/dns.ycp Modified: branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp?rev=59587&r1=59586&r2=59587&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/network/src/modules/DNS.ycp Wed Nov 18 15:43:20 2009 @@ -19,7 +19,6 @@ import "Host"; import "Hostname"; import "IP"; -import "NetworkConfig"; import "NetworkInterfaces"; import "Progress"; import "Service"; @@ -46,7 +45,8 @@ global list<string> nameservers = []; global list<string> searchlist = []; -global boolean dhcp_hostname = false; +global boolean dhcp_hostname = false; +global boolean write_hostname = false; global string resolv_conf_policy = ""; // fully qualified @@ -126,9 +126,10 @@ if(initialized == true) return true; - string tmpval = (string) SCR::Read(.sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME); - dhcp_hostname = ( tmpval == "yes"); - Host::Read(); + string tmp1 = (string) SCR::Read(.sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME); + dhcp_hostname = ( tmp1 == "yes"); + string tmp2 = (string) SCR::Read(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS); + write_hostname = ( tmp2 == "yes"); /* install.inf from linuxrc */ map install_inf = $[]; @@ -210,16 +211,18 @@ //are defined for each static IP separately in address dialog //FaTE #2202 - if (Host::WriteHostname()) { + //FIXME: move to Host:: + /*if (Host::WriteHostname()) { //Always add 127.0.0.2 entry to /etc/hosts, otherwise some //desktop apps may hang, not being able to resolve hostname (#304632) //empty list [] as third parameter does that Host::Update(oldhostname, fqhostname, []); } - Host::Write(); + Host::Write();*/ oldhostname = fqhostname; // #49634 SCR::Write(.sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME, dhcp_hostname ? "yes" : "no"); + SCR::Write(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS, write_hostname ? "yes" : "no"); SCR::Write(.sysconfig.network.dhcp, nil); y2milestone("Writing configuration"); @@ -310,6 +313,7 @@ domain = settings["domain"]:""; nameservers = (list<string>) eval(settings["nameservers"]:[]); searchlist = (list<string>) eval(settings["searchlist"]:[]); + dhcp_hostname = settings["dhcp_hostname"]:false; //if not defined, set to 'auto' resolv_conf_policy = settings["resolv_conf_policy"]:"auto"; modified = true; @@ -331,6 +335,7 @@ expdns["nameservers"] = eval(nameservers); if (size(searchlist) >0) expdns["searchlist"] = eval(searchlist); + expdns["dhcp_hostname"] = dhcp_hostname; //TODO: test if it really works with empty string expdns["resolv_conf_policy"] = resolv_conf_policy; return expdns; @@ -353,7 +358,7 @@ else if(size(hostname) > 0) /* Summary text */ summary = Summary::AddListItem(summary, sformat(_("Hostname: %1"), Hostname::MergeFQ(hostname, domain))); - if (!Host::WriteHostname()) + if ( !write_hostname ) summary = Summary::AddListItem(summary, _("Hostname will not be written to /etc/hosts")); Modified: branches/SuSE-Code-11-SP1-Branch/network/src/modules/Host.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/modules/Host.ycp?rev=59587&r1=59586&r2=59587&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/network/src/modules/Host.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/network/src/modules/Host.ycp Wed Nov 18 15:43:20 2009 @@ -33,11 +33,6 @@ global boolean modified = false; /** - * Should static hostname be written to /etc/hosts? - */ -boolean write_hostname = true; - -/** * All hosts read at the start */ map<string,any> hosts_init = $[]; @@ -54,17 +49,6 @@ boolean initialized = false; -global boolean WriteHostname() -{ - return write_hostname; -} - -global void SetWriteHostname( boolean w) -{ - write_hostname = w; - modified = true; -} - /** * Read hosts settings * @return true if success @@ -74,9 +58,6 @@ if(initialized == true) return true; - string tmpval = (string) SCR::Read(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS); - write_hostname = ( tmpval == "yes"); - /* read /etc/hosts */ if(SCR::Read(.target.size, hosts_file) > 0) { list<string> hostlist = SCR::Dir(.etc.hosts); @@ -108,9 +89,6 @@ return true; } - SCR::Write(.sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS, write_hostname ? "yes" : "no"); - SCR::Write(.sysconfig.network.dhcp, nil); - /* Check if there is anything to do */ if(hosts_init == hosts) { @@ -231,7 +209,8 @@ /* Add at least one hostname/ip */ // but do not overload localhost (#46715) - if (write_hostname) { + //FIXME: adapt this + /*if (write_hostname) { if (size(ips) < 1 && nick != "localhost") { y2milestone("Adding dummy 127.0.0.2 %1 entry", newhn); // TODO #42102 @@ -239,7 +218,7 @@ y2milestone("Hosts: %1", hosts); return true; } - } + }*/ /* Remove old hostname from hosts */ // list oldhnlist = []; Modified: branches/SuSE-Code-11-SP1-Branch/network/src/services/dns.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/network/src/services/dns.ycp?rev=59587&r1=59586&r2=59587&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/network/src/services/dns.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/network/src/services/dns.ycp Wed Nov 18 15:43:20 2009 @@ -64,14 +64,12 @@ * @return initial settings for this dialog in one map, from DNS:: */ define map InitSettings () { -// boolean write_hostname = true; map settings = $[ "HOSTNAME": DNS::hostname, "DOMAIN": DNS::domain, "DHCP_HOSTNAME": DNS::dhcp_hostname, - // set as true by default because there wasn't this option in previous version - "WRITE_HOSTNAME": Host::WriteHostname() + "WRITE_HOSTNAME": DNS::write_hostname ]; // the rest is not so straightforward, // because we have list variables but non-list widgets @@ -109,7 +107,7 @@ DNS::nameservers = NonEmpty (nameservers); DNS::searchlist = NonEmpty (searchlist); DNS::dhcp_hostname = settings["DHCP_HOSTNAME"]:false; - Host::SetWriteHostname( settings["WRITE_HOSTNAME"]:true ); + DNS::write_hostname( settings["WRITE_HOSTNAME"]:true ); /* update modified flag */ DNS::modified = true; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org