Author: mvidner
Date: Thu Aug 11 16:35:56 2011
New Revision: 65312
URL: http://svn.opensuse.org/viewcvs/yast?rev=65312&view=rev
Log:
ProposeInterfaces: Reindented; removed the commented out code.
Modified:
branches/SuSE-Code-11-SP2-Branch/network/src/modules/Lan.ycp
Modified: branches/SuSE-Code-11-SP2-Branch/network/src/modules/Lan.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/network/src/modules/Lan.ycp?rev=65312&r1=65311&r2=65312&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/network/src/modules/Lan.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/network/src/modules/Lan.ycp Thu Aug 11 16:35:56 2011
@@ -870,299 +870,154 @@
* @return true if something was proposed
*/
global define boolean ProposeInterfaces () {
-
y2milestone("Hardware=%1", LanItems::Hardware);
-// y2milestone("InstallInf=%1", InstallInf);
y2milestone("NetworkConfig::Config=%1", NetworkConfig::Config);
y2milestone("NetworkConfig::DHCP=%1", NetworkConfig::DHCP);
- // test if we have any virtualization installed
- if (virt_net_proposal)
- {
- y2milestone("Virtualization [xen|kvm|qemu] detected - will propose virtualization network");
- // in case of virtualization use special proposal
- // collect all interfaces that will be skipped from bridged proposal
- list<string> skipped = [];
- foreach(integer current, any config, LanItems::Items, {
- string ifcfg = LanItems::Items[current, "ifcfg"]:"";
- if (NetworkInterfaces::GetType(ifcfg)=="br"){
- NetworkInterfaces::Edit(ifcfg);
- y2milestone("Bridge %1 with ports (%2) found", ifcfg, NetworkInterfaces::Current["BRIDGE_PORTS"]:"");
- skipped=add(skipped, ifcfg);
- foreach(string port, (list<string>) splitstring(NetworkInterfaces::Current["BRIDGE_PORTS"]:"", " "), {
- skipped=add(skipped, port);
- });
- }
- if (NetworkInterfaces::GetType(ifcfg)=="bond"){
- NetworkInterfaces::Edit(ifcfg);
- foreach(string i, (list<string>)splitstring("0,1,2,3,4,5,6,7,8,9", ","), {
- string slave = NetworkInterfaces::Current[sformat("BONDING_SLAVE%1", i)]:"";
- y2milestone("For interface %1 found slave %2", ifcfg, slave);
- if(size(slave)>0) skipped=add(skipped, slave);
- });
- }
- if (NetworkInterfaces::GetValue(ifcfg, "STARTMODE")=="nfsroot"){
- y2milestone("Skipped %1 interface from bridge slaves because of nfsroot.", ifcfg);
- skipped=add(skipped, ifcfg);
+ // test if we have any virtualization installed
+ if (virt_net_proposal) {
+ y2milestone("Virtualization [xen|kvm|qemu] detected - will propose virtualization network");
+ // in case of virtualization use special proposal
+ // collect all interfaces that will be skipped from bridged proposal
+ list<string> skipped = [];
+ foreach(integer current, any config, LanItems::Items, {
+ string ifcfg = LanItems::Items[current, "ifcfg"]:"";
+ if (NetworkInterfaces::GetType(ifcfg)=="br"){
+ NetworkInterfaces::Edit(ifcfg);
+ y2milestone("Bridge %1 with ports (%2) found", ifcfg, NetworkInterfaces::Current["BRIDGE_PORTS"]:"");
+ skipped=add(skipped, ifcfg);
+ foreach(string port, (list<string>) splitstring(NetworkInterfaces::Current["BRIDGE_PORTS"]:"", " "), {
+ skipped=add(skipped, port);
+ });
+ }
+ if (NetworkInterfaces::GetType(ifcfg)=="bond"){
+ NetworkInterfaces::Edit(ifcfg);
+ foreach(string i, (list<string>)splitstring("0,1,2,3,4,5,6,7,8,9", ","), {
+ string slave = NetworkInterfaces::Current[sformat("BONDING_SLAVE%1", i)]:"";
+ y2milestone("For interface %1 found slave %2", ifcfg, slave);
+ if(size(slave)>0) skipped=add(skipped, slave);
+ });
+ }
+ if (NetworkInterfaces::GetValue(ifcfg, "STARTMODE")=="nfsroot"){
+ y2milestone("Skipped %1 interface from bridge slaves because of nfsroot.", ifcfg);
+ skipped=add(skipped, ifcfg);
+ }
+ });
+ y2milestone("Skipped interfaces : %1", skipped);
+
+ // first configure all connected unconfigured devices with dhcp (with default parameters)
+ foreach (integer number, any lanitem, LanItems::Items, {
+ if (hasAnyValue(((map)lanitem)["hwinfo", "dev_name"]:"")) {
+ LanItems::current = number;
+ boolean link = LanItems::getCurrentItem()["hwinfo", "link"]:false == true;
+ if (!link) y2warning("item number %1 has link:false detected", number);
+ if (!LanItems::IsItemConfigured() && link && !contains(skipped, LanItems::getCurrentItem()["hwinfo", "dev_name"]:"")){
+ y2milestone("Nothing already configured - start proposing");
+ LanItems::ProposeItem();
+ }
+ }
+ });
+
+ // then each configuration (except bridges) move to the bridge
+ // and add old device name into bridge_ports
+ foreach(integer current, any config, LanItems::Items, {
+ string ifcfg = LanItems::Items[current, "ifcfg"]:"";
+ if (contains(skipped, ifcfg)){
+ y2milestone("Skipping interface %1", ifcfg);
+ continue;
+ }
+ else if (size(ifcfg)>0){
+ NetworkInterfaces::Edit(ifcfg);
+ map old_config = NetworkInterfaces::Current;
+ y2debug("Old Config %1\n%2", ifcfg, old_config);
+ string new_ifcfg = sformat("br%1", NetworkInterfaces::GetFreeDevice("br"));
+ y2milestone("old configuration %1, bridge %2", ifcfg, new_ifcfg);
+ NetworkInterfaces::Name = new_ifcfg;
+ // from bridge interface remove all bonding-related stuff
+ foreach(string key, any value, NetworkInterfaces::Current, {
+ if (issubstring(key, "BONDING")){
+ NetworkInterfaces::Current[key]=nil;
+ }
+ });
+ NetworkInterfaces::Current["BRIDGE"]="yes";
+ NetworkInterfaces::Current["BRIDGE_PORTS"]=ifcfg;
+ NetworkInterfaces::Current["BRIDGE_STP"]="off";
+ NetworkInterfaces::Current["BRIDGE_FORWARDDELAY"]="0";
+ // hardcode startmode (bnc#450670), it can't be ifplugd!
+ NetworkInterfaces::Current["STARTMODE"]="onboot";
+ // remove description - will be replaced by new (real) one
+ NetworkInterfaces::Current=remove(NetworkInterfaces::Current, "NAME");
+ if( NetworkInterfaces::Commit() ){
+ NetworkInterfaces::Add();
+ NetworkInterfaces::Edit(ifcfg);
+ old_config["BOOTPROTO"]="static";
+ old_config["IPADDR"]="0.0.0.0/32";
+ // remove all aliases (bnc#590167)
+ foreach (string a, any v, (map )NetworkInterfaces::Current["_aliases"]:$[], {
+ if (v != nil) { NetworkInterfaces::DeleteAlias (NetworkInterfaces::Name, a); }
+ });
+ old_config["_aliases"]=$[];
+ y2milestone("Old Config with apllied changes %1\n%2", ifcfg, old_config);
+ NetworkInterfaces::Current = old_config;
+ NetworkInterfaces::Commit();
+
+ LanItems::Items[current, "ifcfg"] = new_ifcfg;
+ LanItems::modified=true;
+ LanItems::force_restart=true;
+ y2internal("List %1", NetworkInterfaces::List(""));
+ // re-read configuration to see new items in UI
+ LanItems::Read();
+ }
+ }
+ else y2warning("empty ifcfg");
+ });
}
- });
- y2milestone("Skipped interfaces : %1", skipped);
+ else {
- // first configure all connected unconfigured devices with dhcp (with default parameters)
- foreach (integer number, any lanitem, LanItems::Items, {
- if (hasAnyValue(((map)lanitem)["hwinfo", "dev_name"]:"")) {
- LanItems::current = number;
- boolean link = LanItems::getCurrentItem()["hwinfo", "link"]:false == true;
- if (!link) y2warning("item number %1 has link:false detected", number);
- if (!LanItems::IsItemConfigured() && link && !contains(skipped, LanItems::getCurrentItem()["hwinfo", "dev_name"]:"")){
- y2milestone("Nothing already configured - start proposing");
- LanItems::ProposeItem();
- }
- }
- });
-
- // then each configuration (except bridges) move to the bridge
- // and add old device name into bridge_ports
- foreach(integer current, any config, LanItems::Items, {
- string ifcfg = LanItems::Items[current, "ifcfg"]:"";
- if (contains(skipped, ifcfg)){
- y2milestone("Skipping interface %1", ifcfg);
- continue;
- } else
- if (size(ifcfg)>0){
- NetworkInterfaces::Edit(ifcfg);
- map old_config = NetworkInterfaces::Current;
- y2debug("Old Config %1\n%2", ifcfg, old_config);
- string new_ifcfg = sformat("br%1", NetworkInterfaces::GetFreeDevice("br"));
- y2milestone("old configuration %1, bridge %2", ifcfg, new_ifcfg);
- NetworkInterfaces::Name = new_ifcfg;
- // from bridge interface remove all bonding-related stuff
- foreach(string key, any value, NetworkInterfaces::Current, {
- if (issubstring(key, "BONDING")){
- NetworkInterfaces::Current[key]=nil;
- }
- });
- NetworkInterfaces::Current["BRIDGE"]="yes";
- NetworkInterfaces::Current["BRIDGE_PORTS"]=ifcfg;
- NetworkInterfaces::Current["BRIDGE_STP"]="off";
- NetworkInterfaces::Current["BRIDGE_FORWARDDELAY"]="0";
- // hardcode startmode (bnc#450670), it can't be ifplugd!
- NetworkInterfaces::Current["STARTMODE"]="onboot";
- // remove description - will be replaced by new (real) one
- NetworkInterfaces::Current=remove(NetworkInterfaces::Current, "NAME");
- if( NetworkInterfaces::Commit() ){
- NetworkInterfaces::Add();
- NetworkInterfaces::Edit(ifcfg);
- old_config["BOOTPROTO"]="static";
- old_config["IPADDR"]="0.0.0.0/32";
- // remove all aliases (bnc#590167)
- foreach (string a, any v, (map )NetworkInterfaces::Current["_aliases"]:$[], {
- if (v != nil) { NetworkInterfaces::DeleteAlias (NetworkInterfaces::Name, a); }
- });
- old_config["_aliases"]=$[];
- y2milestone("Old Config with apllied changes %1\n%2", ifcfg, old_config);
- NetworkInterfaces::Current = old_config;
- NetworkInterfaces::Commit();
-
- LanItems::Items[current, "ifcfg"] = new_ifcfg;
- LanItems::modified=true;
- LanItems::force_restart=true;
- y2internal("List %1", NetworkInterfaces::List(""));
- // re-read configuration to see new items in UI
- LanItems::Read();
- }
- } else y2warning("empty ifcfg");
- });
- } else {
-
- if (! LanItems::nm_proposal_valid)
- {
- NetworkService::SetManaged (UseNetworkManager ());
- LanItems::nm_proposal_valid = true;
- }
+ if (! LanItems::nm_proposal_valid) {
+ NetworkService::SetManaged (UseNetworkManager ());
+ LanItems::nm_proposal_valid = true;
+ }
- if (NetworkService::IsManaged ())
- {
- ProposeNMInterfaces ();
-
- LanItems::modified = true; // #144139 workaround
- y2milestone ("NM proposal");
- return true;
- }
+ if (NetworkService::IsManaged ()) {
+ ProposeNMInterfaces ();
+ LanItems::modified = true; // #144139 workaround
+ y2milestone ("NM proposal");
+ return true;
+ }
- }
+ }
/* Something is already configured -> do nothing */
boolean configured=false;
foreach (integer number, any lanitem, LanItems::Items, {
- LanItems::current = number;
- if (LanItems::IsItemConfigured()){
- y2milestone("Something already configured: don't propose.");
- configured = true;
- break;
- }
- });
+ LanItems::current = number;
+ if (LanItems::IsItemConfigured()){
+ y2milestone("Something already configured: don't propose.");
+ configured = true;
+ break;
+ }
+ });
if (configured) return false;
foreach (integer number, any lanitem, LanItems::Items, {
- if (hasAnyValue(((map)lanitem)["hwinfo", "dev_name"]:"")) {
- LanItems::current = number;
- boolean link = LanItems::getCurrentItem()["hwinfo", "link"]:false;
- if (LanItems::getCurrentItem()["hwinfo", "type"]:"" == "wlan")
- y2warning("Will not propose wlan interfaces");
- else{
- if (!link) y2warning("item number %1 has link:false detected", number);
- else if (!LanItems::IsItemConfigured() && link){
- y2milestone("Nothing already configured - start proposing");
- LanItems::ProposeItem();
- break;
- }
- }
- }
- });
-
-
-
-
-// Add();
-
-// map tosel = nil;
-
- /* Some HW found -> use it for proposal */
-// if(size(LanItems::Hardware) > 0) {
-// if (Arch::s390()){
-// tosel = FindMatchingDevice( $["device":sformat("%1-id-%2",InstallInf["module"]:"", InstallInf["hwaddr"]:"")] );
-// }
-// else
-// tosel = LanItems::FindMatchingDevice($[]);
-
-// }
-
-
-// y2debug("Hardware=%1", LanItems::Hardware);
-// y2milestone ("Selected HW w/o install.inf patches: %1", tosel);
-
-/*
- // do not select a card without a driver, #29296
- if (tosel != nil)
- {
- // L3 N#81533
- // Autoyast takes network config from install.inf, has
- // problem with hardware that has a choice of drivers:
- // Module A is used even though install.inf says module B.
- // It is because we selected the _hardware_ and then took
- // the first module.
- // Future: select hardware+driver together
- // CODE 9 fix: for the selected hardware, patch in the driver
-
- // We cannot simply _create_ tosel from install.inf data because
- // SelectHW relies on the detected info (eg. busid) from hwinfo
- // which is not in install.inf
-
-
- if (InstallInf["module"]:"" != "")
- {
- y2milestone ("Using driver module from install.inf");
- tosel["module"] = InstallInf["module"]:"";
- }
- // L3 bug: 75720
- // Setup module options available from /etc/install.inf
- string _options = InstallModuleOptions(tosel["module"]:"");
- if (_options != "" && _options!=nil) {
- y2milestone ("Using driver options from install.inf");
- tosel["options"] = _options;
- }
-
- y2milestone ("Selected HW with install.inf patches: %1", tosel);
- SelectHWMap(tosel);
- // set layer2 status from /etc/install.inf
- qeth_layer2 = (InstallInf["QETH_LAYER2_SUPPORT"]:"0"=="1")?true:false;
- qeth_macaddress = InstallInf["LLADDR"]:"";
- }
- // Nothing detected -> use InstallInf
-
- else if(size(InstallInf) > 0) {
-
- if(!haskey(InstallInf, "module")) {
- y2milestone("No hardware, no install.inf module -> no proposal.");
- return false;
- }
-
- // FIXME: MOD Module["module"] = InstallInf["module"]:"";
- // FIXME: MOD Module["options"] = InstallInf["options"]:"";
-
- NetworkModules::Alias = InstallInf["module"]:"";
- NetworkModules::Options = InstallInf["options"]:"";
-
-
- type = InstallInf["type"]:"eth";
- device = NetworkInterfaces::GetFreeDevice(type);
- }
-
- else {
- y2milestone("No hardware, no install.inf -> no proposal.");
- return false;
- }
-*/
-
-// here we know the hardware and could fill the interface defaults for it,
-// like for wifi usercontrol and for eth|wifi ifplugd.
-// This is proposal. also need to do it with
-// - add from ui: detected and undetected
-// - autoyast
-// LanItems::SetDefaultsForHW ();
-
- // #145041
-// ethtool_options = InstallInf["ethtool_options"]:"";
-
- // #176804
-/*
- if (NetworkStorage::isDiskOnNetwork ( NetworkStorage::getDevice("/") ))
- {
- LanItems::startmode = "nfsroot";
- y2milestone ("startmode nfsroot");
- }
-*/
-// ipaddr = InstallInf["ipaddr"]:"";
-// bootproto = InstallInf["bootproto"]:"static";
-// y2debug("ipaddr,bootproto=%1,%2", LanItems::ipaddr, LanItems::bootproto);
-// if(LanItems::bootproto == "static" && LanItems::ipaddr != "" && LanItems::ipaddr != nil) {
-
-// y2milestone("static proposal");
-
- /* propose address setup from /etc/install.inf */
-// netmask = InstallInf["netmask"]:"";
-// if(LanItems::netmask == nil || LanItems::netmask == "")
-// LanItems::netmask = "255.255.255.0";
-// }
-// else {
- /* Propose static config in case of DSL hardware is found */
-// list pppoe = (list) SCR::Read(.probe.pppoe);
- // FIXME: testing pppoe = [ $["a" : "b"] ];
-// map pppoedev = pppoe[0]:$[];
-// y2milestone ("pppoe=%1", pppoe);
-// if(pppoe != nil && size(pppoe) > 0) {
-// y2milestone("DSL proposal");
-// LanItems::ipaddr = "";
-// LanItems::bootproto = "static";
-// }
-// else {
- // Open Enterprise Server does not like DHCP (#50524).
- // In that case, we cannot propose.
-// if (ProductFeatures::GetBooleanFeature ("network", "force_static_ip"))
-// {
-// y2milestone ("Static config forced but no info available -> no proposal.");
-// return false;
-// }
-// y2milestone("DHCP proposal");
-// LanItems::ipaddr = "";
-// LanItems::bootproto = "dhcp";
-// }
-// }
-
-// LanItems::Commit();
+ if (hasAnyValue(((map)lanitem)["hwinfo", "dev_name"]:"")) {
+ LanItems::current = number;
+ boolean link = LanItems::getCurrentItem()["hwinfo", "link"]:false;
+ if (LanItems::getCurrentItem()["hwinfo", "type"]:"" == "wlan")
+ y2warning("Will not propose wlan interfaces");
+ else{
+ if (!link) y2warning("item number %1 has link:false detected", number);
+ else if (!LanItems::IsItemConfigured() && link){
+ y2milestone("Nothing already configured - start proposing");
+ LanItems::ProposeItem();
+ break;
+ }
+ }
+ }
+ });
y2milestone("NetworkConfig::Config=%1", NetworkConfig::Config);
y2milestone("NetworkConfig::DHCP=%1", NetworkConfig::DHCP);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org