# HG changeset patch
# Parent f36a7d22eaf8c138fdc3920ee8f03a32ce61087d

diff -r f36a7d22eaf8 network/src/lan/YaPI/NETWORK.pm
--- a/network/src/lan/YaPI/NETWORK.pm	Tue Aug 30 16:17:50 2011 +0200
+++ b/network/src/lan/YaPI/NETWORK.pm	Tue Aug 30 16:36:16 2011 +0200
@@ -44,6 +44,12 @@
                 }
             }
             $configuration{'mtu'} = LanItems->mtu;
+            if (LanItems->vlan_id){
+                $configuration{'vlan_id'} = LanItems->vlan_id;
+            }
+            if (LanItems->vlan_etherdevice){
+                $configuration{'vlan_etherdevice'} = LanItems->vlan_etherdevice;
+            }
             $interfaces{LanItems->interfacename}=\%configuration;
         } elsif (LanItems->getCurrentItem()->{'hwinfo'}->{'type'} eq "eth") {
             my $device = LanItems->getCurrentItem()->{"hwinfo"}->{"dev_name"};
@@ -161,6 +167,12 @@
         if (defined $ifc->{'mtu'}) {
             $config{"MTU"} = $ifc->{'mtu'};
         }
+        if (defined $ifc->{'vlan_id'}) {
+            $config{"VLAN_ID"} = $ifc->{'vlan_id'};
+        }
+        if (defined $ifc->{'vlan_etherdevice'}) {
+            $config{"ETHERDEVICE"} = $ifc->{'vlan_etherdevice'};
+        }
         NetworkInterfaces->Current(\%config);
         NetworkInterfaces->Commit();
         NetworkInterfaces->Write("");
diff -r f36a7d22eaf8 network/testsuite/tests/Network_YaPI.out
--- a/network/testsuite/tests/Network_YaPI.out	Tue Aug 30 16:17:50 2011 +0200
+++ b/network/testsuite/tests/Network_YaPI.out	Tue Aug 30 16:36:16 2011 +0200
@@ -12,7 +12,7 @@
 Execute	.target.bash "rpm -q --whatprovides SuSEfirewall2" 0
 Read	.init.scripts.exists "SuSEfirewall2_init" false
 Read	.sysconfig.sysctl.IP_FORWARD nil
-Dir	.network.section: ["eth0", "eth1", "eth2", "eth3", "eth4"]
+Dir	.network.section: ["eth0", "eth1", "eth2", "eth3", "eth4", "eth5", "eth5.23"]
 Dir	.network.value."eth0": ["BOOTPROTO", "STARTMODE"]
 Read	.network.value."eth0".BOOTPROTO "dhcp4"
 Read	.network.value."eth0".STARTMODE "manual"
@@ -36,6 +36,15 @@
 Read	.network.value."eth4".IPADDR "1.2.3.7"
 Read	.network.value."eth4".NETMASK "255.255.255.0"
 Read	.network.value."eth4".STARTMODE "auto"
+Dir	.network.value."eth5": ["BOOTPROTO", "STARTMODE"]
+Read	.network.value."eth5".BOOTPROTO "static"
+Read	.network.value."eth5".STARTMODE "auto"
+Dir	.network.value."eth5.23": ["BOOTPROTO", "ETHERDEVICE", "IPADDR", "STARTMODE", "VLAN_ID"]
+Read	.network.value."eth5.23".BOOTPROTO "static"
+Read	.network.value."eth5.23".ETHERDEVICE "eth5"
+Read	.network.value."eth5.23".IPADDR "1.2.3.8/24"
+Read	.network.value."eth5.23".STARTMODE "auto"
+Read	.network.value."eth5.23".VLAN_ID "23"
 Read	.target.size "/etc/install.inf" 27
 Dir	.etc.install_inf: []
 Read	.target.string "/proc/cmdline" "laptop.suse.cz"
@@ -51,7 +60,7 @@
 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":"", "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	$["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"], "eth5":$["bootproto":"static", "ipaddr":"", "mtu":"", "startmode":"auto"], "eth5.23":$["bootproto":"static", "ipaddr":"1.2.3.8/24", "mtu":"", "startmode":"auto", "vlan_etherdevice":"eth5", "vlan_id":"23"]], "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
@@ -79,6 +88,14 @@
 Write	.network nil true
 Read	.init.scripts.exists "network" false
 Return	$["error":"", "exit":"0"]
+Write	.network.value."eth5.23".BOOTPROTO "static" true
+Write	.network.value."eth5.23".ETHERDEVICE "eth5" true
+Write	.network.value."eth5.23".IPADDR "1.2.3.8/24" true
+Write	.network.value."eth5.23".STARTMODE "auto" true
+Write	.network.value."eth5.23".VLAN_ID "42" 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"]]
 Read	.init.scripts.exists "SuSEfirewall2_init" false
@@ -95,4 +112,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":"", "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"]]]
+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"], "eth5":$["bootproto":"static", "ipaddr":"", "mtu":"", "startmode":"auto"], "eth5.23":$["bootproto":"static", "ipaddr":"1.2.3.8/24", "mtu":"", "startmode":"auto", "vlan_etherdevice":"eth5", "vlan_id":"42"]], "routes":$["default":$["via":"10.20.30.40"]]]
diff -r f36a7d22eaf8 network/testsuite/tests/Network_YaPI.ycp
--- a/network/testsuite/tests/Network_YaPI.ycp	Tue Aug 30 16:17:50 2011 +0200
+++ b/network/testsuite/tests/Network_YaPI.ycp	Tue Aug 30 16:36:16 2011 +0200
@@ -32,6 +32,8 @@
                         "eth2":$[],
                         "eth3":$[],
                         "eth4":$[],
+                        "eth5":$[],
+                        "eth5.23":$[],
                         ],
 	  "value" : $[
 		"eth0" : $[
@@ -62,6 +64,17 @@
 		    "IPADDR"	: "1.2.3.7",
                     "NETMASK"   : "255.255.255.0",
 		  ],
+	        "eth5" : $[
+		    "STARTMODE" : "auto",
+		    "BOOTPROTO" : "static",
+		  ],
+	        "eth5.23" : $[
+		    "STARTMODE"   : "auto",
+		    "BOOTPROTO"   : "static",
+		    "IPADDR"	  : "1.2.3.8/24",
+		    "VLAN_ID"     : "23",
+		    "ETHERDEVICE" : "eth5",
+		  ],
           ],
     ],
     "routes" : [ $["destination":"default", "gateway":"10.20.30.40"] ]
@@ -89,7 +102,12 @@
 // test incorrect default route (invalid gw IP)
 TEST(``(YaPI::NETWORK::Write($["route":$["default":$["via":"10.20.30"]]])), [READ], nil);
 
+// test setting the network prefix length for an interface that was previously configured via netmask
 TEST(``(YaPI::NETWORK::Write($["interface":$["eth3":$["bootproto":"static", "ipaddr":"1.2.3.7/24"]]])), [READ], nil);
+
+// test vlan_id change
+TEST(``(YaPI::NETWORK::Write($["interface":$["eth5.23":$["bootproto":"static", "ipaddr":"1.2.3.8/24", "vlan_etherdevice":"eth5", "vlan_id":"42"]]])), [READ], nil);
+
 TEST(``(YaPI::NETWORK::Read()), [READ, $[], EXEC], nil);
 
 }
