# HG changeset patch
# Parent 8dc09b90e2ede347dddf8c192ee376e3fc7c91b5

diff -r 8dc09b90e2ed network/src/lan/YaPI/NETWORK.pm
--- a/network/src/lan/YaPI/NETWORK.pm	Tue Aug 30 17:06:48 2011 +0200
+++ b/network/src/lan/YaPI/NETWORK.pm	Tue Aug 30 17:07:26 2011 +0200
@@ -32,13 +32,12 @@
     foreach my $devnum (keys %{LanItems->Items}){
         LanItems->current($devnum);
         if (LanItems->IsItemConfigured()){
-            my %configuration = ();
             LanItems->SetItem();
-            if (LanItems->isCurrentDHCP()){
-                %configuration = ( 'bootproto' => LanItems->bootproto );
-            } elsif (LanItems->bootproto eq "static"){
-                %configuration = ( 'bootproto' => 'static' );
-
+            my %configuration = (
+                'startmode' => LanItems->startmode ne ''? LanItems->startmode: 'manual',
+                'bootproto' => LanItems->bootproto,
+            );
+            if (LanItems->bootproto eq "static"){
                 $configuration{'ipaddr'} = LanItems->ipaddr;
                 if (LanItems->prefix ne "") {
                      $configuration{'ipaddr'} .= "/" . LanItems->prefix
@@ -142,7 +141,7 @@
         NetworkInterfaces->Read();
         NetworkInterfaces->Add() unless NetworkInterfaces->Edit($dev);
         NetworkInterfaces->Name($dev);
-        my %config=("STARTMODE" => "auto",
+        my %config=("STARTMODE" => defined $ifc->{'startmode'}? $ifc->{'startmode'}: 'auto',
                     "BOOTPROTO" => defined $ifc->{'bootproto'}? $ifc->{'bootproto'}: 'static',
             );
         if (defined $ifc->{'ipaddr'}) {
diff -r 8dc09b90e2ed network/testsuite/tests/Network_YaPI.out
--- a/network/testsuite/tests/Network_YaPI.out	Tue Aug 30 17:06:48 2011 +0200
+++ b/network/testsuite/tests/Network_YaPI.out	Tue Aug 30 17:07:26 2011 +0200
@@ -13,24 +13,29 @@
 Read	.init.scripts.exists "SuSEfirewall2_init" false
 Read	.sysconfig.sysctl.IP_FORWARD nil
 Dir	.network.section: ["eth0", "eth1", "eth2", "eth3", "eth4"]
-Dir	.network.value."eth0": ["BOOTPROTO"]
+Dir	.network.value."eth0": ["BOOTPROTO", "STARTMODE"]
 Read	.network.value."eth0".BOOTPROTO "dhcp4"
-Dir	.network.value."eth1": ["BOOTPROTO", "IPADDR", "MTU"]
+Read	.network.value."eth0".STARTMODE "manual"
+Dir	.network.value."eth1": ["BOOTPROTO", "IPADDR", "MTU", "STARTMODE"]
 Read	.network.value."eth1".BOOTPROTO "static"
 Read	.network.value."eth1".IPADDR "1.2.3.4/24"
 Read	.network.value."eth1".MTU "1234"
-Dir	.network.value."eth2": ["BOOTPROTO", "IPADDR", "PREFIXLEN"]
+Read	.network.value."eth1".STARTMODE "auto"
+Dir	.network.value."eth2": ["BOOTPROTO", "IPADDR", "PREFIXLEN", "STARTMODE"]
 Read	.network.value."eth2".BOOTPROTO "static"
 Read	.network.value."eth2".IPADDR "1.2.3.5/24"
 Read	.network.value."eth2".PREFIXLEN ""
-Dir	.network.value."eth3": ["BOOTPROTO", "IPADDR", "PREFIXLEN"]
+Read	.network.value."eth2".STARTMODE "auto"
+Dir	.network.value."eth3": ["BOOTPROTO", "IPADDR", "PREFIXLEN", "STARTMODE"]
 Read	.network.value."eth3".BOOTPROTO "static"
 Read	.network.value."eth3".IPADDR "1.2.3.6"
 Read	.network.value."eth3".PREFIXLEN "24"
-Dir	.network.value."eth4": ["BOOTPROTO", "IPADDR", "NETMASK"]
+Read	.network.value."eth3".STARTMODE "auto"
+Dir	.network.value."eth4": ["BOOTPROTO", "IPADDR", "NETMASK", "STARTMODE"]
 Read	.network.value."eth4".BOOTPROTO "static"
 Read	.network.value."eth4".IPADDR "1.2.3.7"
 Read	.network.value."eth4".NETMASK "255.255.255.0"
+Read	.network.value."eth4".STARTMODE "auto"
 Read	.target.size "/etc/install.inf" 27
 Dir	.etc.install_inf: []
 Read	.target.string "/proc/cmdline" "laptop.suse.cz"
@@ -46,7 +51,12 @@
 Read	.target.lstat "/etc/sysconfig/network/ifcfg-tr-usb" nil
 Execute	.target.bash_output "hostname --fqdn" $["exit":0, "stdout":"laptop.suse.cz"]
 Execute	.target.bash_output "hostname --fqdn" $["exit":0, "stdout":"laptop.suse.cz"]
-Return	$["dns":$["nameservers":["208.67.222.222", "208.67.220.220"], "searches":["suse.cz", "suse.de"]], "hostname":$["dhcp_hostname":"1", "domain":"suse.cz", "name":"laptop"], "interfaces":$["eth0":$["bootproto":"dhcp4", "mtu":""], "eth1":$["bootproto":"static", "ipaddr":"1.2.3.4/24", "mtu":"1234"], "eth2":$["bootproto":"static", "ipaddr":"1.2.3.5/24", "mtu":""], "eth3":$["bootproto":"static", "ipaddr":"1.2.3.6/24", "mtu":""], "eth4":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":""]], "routes":$["default":$["via":"10.20.30.40"]]]
+Return	$["dns":$["nameservers":["208.67.222.222", "208.67.220.220"], "searches":["suse.cz", "suse.de"]], "hostname":$["dhcp_hostname":"1", "domain":"suse.cz", "name":"laptop"], "interfaces":$["eth0":$["bootproto":"dhcp4", "mtu":"", "startmode":"manual"], "eth1":$["bootproto":"static", "ipaddr":"1.2.3.4/24", "mtu":"1234", "startmode":"auto"], "eth2":$["bootproto":"static", "ipaddr":"1.2.3.5/24", "mtu":"", "startmode":"auto"], "eth3":$["bootproto":"static", "ipaddr":"1.2.3.6/24", "mtu":"", "startmode":"auto"], "eth4":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":"", "startmode":"auto"]], "routes":$["default":$["via":"10.20.30.40"]]]
+Return	$["error":"", "exit":"0"]
+Write	.network.value."eth0".BOOTPROTO "dhcp4" true
+Write	.network.value."eth0".STARTMODE "auto" true
+Write	.network nil true
+Read	.init.scripts.exists "network" false
 Return	$["error":"", "exit":"0"]
 Read	.target.size "/etc/sysconfig/network/routes" 27
 Read	.routes [$["destination":"default", "gateway":"10.20.30.40"]]
@@ -85,4 +95,4 @@
 Read	.target.lstat "/etc/sysconfig/network/ifcfg-tr-usb" nil
 Execute	.target.bash_output "hostname --fqdn" $["exit":0, "stdout":"laptop.suse.cz"]
 Execute	.target.bash_output "hostname --fqdn" $["exit":0, "stdout":"laptop.suse.cz"]
-Return	$["dns":$["nameservers":["208.67.222.222", "208.67.220.220"], "searches":["suse.cz", "suse.de"]], "hostname":$["dhcp_hostname":"1", "domain":"suse.cz", "name":"laptop"], "interfaces":$["eth0":$["bootproto":"dhcp4", "mtu":""], "eth1":$["bootproto":"static", "ipaddr":"1.2.3.4/24", "mtu":"1234"], "eth2":$["bootproto":"static", "ipaddr":"1.2.3.5/24", "mtu":""], "eth3":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":""], "eth4":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":""]], "routes":$["default":$["via":"10.20.30.40"]]]
+Return	$["dns":$["nameservers":["208.67.222.222", "208.67.220.220"], "searches":["suse.cz", "suse.de"]], "hostname":$["dhcp_hostname":"1", "domain":"suse.cz", "name":"laptop"], "interfaces":$["eth0":$["bootproto":"dhcp4", "mtu":"", "startmode":"auto"], "eth1":$["bootproto":"static", "ipaddr":"1.2.3.4/24", "mtu":"1234", "startmode":"auto"], "eth2":$["bootproto":"static", "ipaddr":"1.2.3.5/24", "mtu":"", "startmode":"auto"], "eth3":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":"", "startmode":"auto"], "eth4":$["bootproto":"static", "ipaddr":"1.2.3.7/24", "mtu":"", "startmode":"auto"]], "routes":$["default":$["via":"10.20.30.40"]]]
diff -r 8dc09b90e2ed network/testsuite/tests/Network_YaPI.ycp
--- a/network/testsuite/tests/Network_YaPI.ycp	Tue Aug 30 17:06:48 2011 +0200
+++ b/network/testsuite/tests/Network_YaPI.ycp	Tue Aug 30 17:07:26 2011 +0200
@@ -35,24 +35,29 @@
                         ],
 	  "value" : $[
 		"eth0" : $[
+		    "STARTMODE" : "manual",
 		    "BOOTPROTO" : "dhcp4"
 		  ],
 	        "eth1" : $[
+		    "STARTMODE" : "auto",
 		    "BOOTPROTO" : "static",
 		    "IPADDR"	: "1.2.3.4/24",
                     "MTU"	: "1234",
                   ],
 	        "eth2" : $[
+		    "STARTMODE" : "auto",
 		    "BOOTPROTO" : "static",
 		    "IPADDR"	: "1.2.3.5/24",
                     "PREFIXLEN"	: "",
                   ],
 	        "eth3" : $[
+		    "STARTMODE" : "auto",
 		    "BOOTPROTO" : "static",
 		    "IPADDR"	: "1.2.3.6",
                     "PREFIXLEN" : "24",
 		  ],
 	        "eth4" : $[
+		    "STARTMODE" : "auto",
 		    "BOOTPROTO" : "static",
 		    "IPADDR"	: "1.2.3.7",
                     "NETMASK"   : "255.255.255.0",
@@ -75,6 +80,9 @@
 
 TEST(``(YaPI::NETWORK::Write($[])), [$[], $[], $[]], nil);
 
+// test manipulation of the startmode
+TEST(``(YaPI::NETWORK::Write($["interface":$["eth0":$["bootproto":"dhcp4", "STARTMODE":"auto"]]])), [READ], nil);
+
 // test correct default route
 TEST(``(YaPI::NETWORK::Write($["route":$["default":$["via":"10.20.30.40"]]])), [READ], nil);
 
