Mailinglist Archive: yast-devel (57 mails)

< Previous Next >
[yast-devel] [PATCH] update Deleted and OriginalDevices in NetworkInterfaces.ycp/Write()
Hey everyone :)

I noticed that the global variables Deleted and OriginalDevices were
not updated in NetworkInterfaces.ycp/Write() causing changes to an
interface to be written over and over again. The attached patch fixes
the problem and updates the testcase NetworkInterface2 accordingly.

Cheers,
Justus
--
Justus Winter winter@xxxxxxxxxxxx

PRESENSE Technologies GmbH Sachsenstr. 5, D-20097 HH
USt-IdNr.: DE263765024
Geschäftsführer/Managing Directors AG Hamburg, HRB 107844
Till Dörges Jürgen Sander Axel Theilmann

diff -r 1814b26e32bf yast2/library/network/src/NetworkInterfaces.ycp
--- a/yast2/library/network/src/NetworkInterfaces.ycp Mon Aug 29 15:23:17
2011 +0200
+++ b/yast2/library/network/src/NetworkInterfaces.ycp Tue Aug 30 15:19:58
2011 +0200
@@ -747,6 +747,7 @@
});
}
});
+ Deleted = [];

/* Devices with chmod=0600 */
list<string> chmod = [];
@@ -829,6 +830,17 @@
y2debug("CHANGED");
chmod = add(chmod, file);
}
+
+ if (OriginalDevices == nil) {
+ OriginalDevices = $[];
+ }
+ if (OriginalDevices[typ]:nil == nil) {
+ OriginalDevices[typ] = $[];
+ }
+ if (OriginalDevices[typ, config]:nil == nil) {
+ OriginalDevices[typ, config] = $[];
+ }
+ OriginalDevices[typ, config] = Devices[typ, config]:$[];
});
});

@@ -842,10 +854,6 @@
SCR::Execute(.target.bash, "/bin/chmod 0600 " + file);
});

- // Deleted = [];
- // OriginalDevices = Devices;
- // Cannot do it because we have written only part of Devices.
- // This module should be rewritten to objects.
return true;
}

diff -r 1814b26e32bf
yast2/library/network/testsuite/tests/NetworkInterfaces2.out
--- a/yast2/library/network/testsuite/tests/NetworkInterfaces2.out Mon Aug
29 15:23:17 2011 +0200
+++ b/yast2/library/network/testsuite/tests/NetworkInterfaces2.out Tue Aug
30 15:19:58 2011 +0200
@@ -90,72 +90,6 @@
Return true
Dump all=$["arc":$["arc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"atm":$["atm5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ci":$["ci5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ctc":$["ctc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"dummy":$["dummy5":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4",
"NETMASK":"255.0.0.0", "PREFIXLEN":"8", "STARTMODE":"manual"]],
"escon":$["escon5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"eth":$["eth5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"],
"eth6":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4", "NETMASK":"255.255.255.255",
"PREFIXLEN":"32", "STARTMODE":"manual"], "eth7":$["STARTMODE":"manual"],
"eth8":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0", "PREFIXLEN":"8",
"STARTMODE":"manual"], "eth9":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0",
"PREFIXLEN":"8", "STARTMODE":"manual"], "mynet0":$["BOOTPROTO":"dhcp",
"INTERFACETYPE":"eth", "STARTMODE":"auto"]],
"fddi":$["fddi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"hippi":$["hippi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"hsi":$["hsi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ippp":$["ippp5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"iucv":$["iucv5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"lo":$["lo":$["BROADCAST":"127.255.255.255", "IPADDR":"127.0.0.1",
"NETMASK":"255.0.0.0", "NETWORK":"127.0.0.0", "PREFIXLEN":"8",
"STARTMODE":"auto"]], "myri":$["myri5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "ppp":$["ppp5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "tr":$["tr5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "vlan":$["eth0.3":$["BOOTPROTO":"dhcp",
"ETHERDEVICE":"eth0", "STARTMODE":"manual"], "myvlantoo":$["BOOTPROTO":"dhcp",
"ETHERDEVICE":"eth0", "STARTMODE":"manual", "VLAN_ID":"2"],
"virtlan4":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"],
"vlan3":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"]]]
Dump NetworkInterfaces::Write
-Write .network.value."arc5".BOOTPROTO "dhcp" true
-Write .network.value."arc5".STARTMODE "manual" true
-Write .network.value."atm5".BOOTPROTO "dhcp" true
-Write .network.value."atm5".STARTMODE "manual" true
-Write .network.value."ci5".BOOTPROTO "dhcp" true
-Write .network.value."ci5".STARTMODE "manual" true
-Write .network.value."ctc5".BOOTPROTO "dhcp" true
-Write .network.value."ctc5".STARTMODE "manual" true
-Write .network.value."dummy5".BOOTPROTO "static" true
-Write .network.value."dummy5".IPADDR "1.2.3.4/8" true
-Write .network.value."dummy5".PREFIXLEN "8" true
-Write .network.value."dummy5".STARTMODE "manual" true
-Write .network.value."escon5".BOOTPROTO "dhcp" true
-Write .network.value."escon5".STARTMODE "manual" true
-Write .network.value."eth5".BOOTPROTO "dhcp" true
-Write .network.value."eth5".STARTMODE "manual" true
-Write .network.value."eth6".BOOTPROTO "static" true
-Write .network.value."eth6".IPADDR "1.2.3.4/32" true
-Write .network.value."eth6".PREFIXLEN "32" true
-Write .network.value."eth6".STARTMODE "manual" true
-Write .network.value."eth7".STARTMODE "manual" true
-Write .network.value."eth8".IPADDR "1.2.3.4/8" true
-Write .network.value."eth8".PREFIXLEN "8" true
-Write .network.value."eth8".STARTMODE "manual" true
-Write .network.value."eth9".IPADDR "1.2.3.4/8" true
-Write .network.value."eth9".PREFIXLEN "8" true
-Write .network.value."eth9".STARTMODE "manual" true
-Write .network.value."mynet0".BOOTPROTO "dhcp" true
-Write .network.value."mynet0".INTERFACETYPE "eth" true
-Write .network.value."mynet0".STARTMODE "auto" true
-Write .network.value."fddi5".BOOTPROTO "dhcp" true
-Write .network.value."fddi5".STARTMODE "manual" true
-Write .network.value."hippi5".BOOTPROTO "dhcp" true
-Write .network.value."hippi5".STARTMODE "manual" true
-Write .network.value."hsi5".BOOTPROTO "dhcp" true
-Write .network.value."hsi5".STARTMODE "manual" true
-Write .network.value."ippp5".BOOTPROTO "dhcp" true
-Write .network.value."ippp5".STARTMODE "manual" true
-Write .network.value."iucv5".BOOTPROTO "dhcp" true
-Write .network.value."iucv5".STARTMODE "manual" true
-Write .network.value."lo".BROADCAST "127.255.255.255" true
-Write .network.value."lo".IPADDR "127.0.0.1/8" true
-Write .network.value."lo".NETWORK "127.0.0.0" true
-Write .network.value."lo".PREFIXLEN "8" true
-Write .network.value."lo".STARTMODE "auto" true
-Write .network.value."myri5".BOOTPROTO "dhcp" true
-Write .network.value."myri5".STARTMODE "manual" true
-Write .network.value."ppp5".BOOTPROTO "dhcp" true
-Write .network.value."ppp5".STARTMODE "manual" true
-Write .network.value."tr5".BOOTPROTO "dhcp" true
-Write .network.value."tr5".STARTMODE "manual" true
-Write .network.value."eth0.3".BOOTPROTO "dhcp" true
-Write .network.value."eth0.3".ETHERDEVICE "eth0" true
-Write .network.value."eth0.3".STARTMODE "manual" true
-Write .network.value."myvlantoo".BOOTPROTO "dhcp" true
-Write .network.value."myvlantoo".ETHERDEVICE "eth0" true
-Write .network.value."myvlantoo".STARTMODE "manual" true
-Write .network.value."myvlantoo".VLAN_ID "2" true
-Write .network.value."virtlan4".BOOTPROTO "dhcp" true
-Write .network.value."virtlan4".ETHERDEVICE "eth0" true
-Write .network.value."virtlan4".STARTMODE "manual" true
-Write .network.value."vlan3".BOOTPROTO "dhcp" true
-Write .network.value."vlan3".ETHERDEVICE "eth0" true
-Write .network.value."vlan3".STARTMODE "manual" true
-Write .network nil true
-Return true
Write .network.value."eth5".BOOTPROTO "dhcp" true
Write .network.value."eth5".STARTMODE "manual" true
Write .network.value."eth6".BOOTPROTO "static" true
@@ -182,7 +116,6 @@
Write .network.value."ippp5".STARTMODE "manual" true
Write .network nil true
Return true
-Write .network nil true
Return true
Write .network.value."atm5".BOOTPROTO "dhcp" true
Write .network.value."atm5".STARTMODE "manual" true
@@ -190,6 +123,48 @@
Write .network.value."tr5".STARTMODE "manual" true
Write .network nil true
Return true
+Write .network.value."arc5".BOOTPROTO "dhcp" true
+Write .network.value."arc5".STARTMODE "manual" true
+Write .network.value."ci5".BOOTPROTO "dhcp" true
+Write .network.value."ci5".STARTMODE "manual" true
+Write .network.value."ctc5".BOOTPROTO "dhcp" true
+Write .network.value."ctc5".STARTMODE "manual" true
+Write .network.value."dummy5".BOOTPROTO "static" true
+Write .network.value."dummy5".IPADDR "1.2.3.4/8" true
+Write .network.value."dummy5".PREFIXLEN "8" true
+Write .network.value."dummy5".STARTMODE "manual" true
+Write .network.value."escon5".BOOTPROTO "dhcp" true
+Write .network.value."escon5".STARTMODE "manual" true
+Write .network.value."fddi5".BOOTPROTO "dhcp" true
+Write .network.value."fddi5".STARTMODE "manual" true
+Write .network.value."hippi5".BOOTPROTO "dhcp" true
+Write .network.value."hippi5".STARTMODE "manual" true
+Write .network.value."hsi5".BOOTPROTO "dhcp" true
+Write .network.value."hsi5".STARTMODE "manual" true
+Write .network.value."iucv5".BOOTPROTO "dhcp" true
+Write .network.value."iucv5".STARTMODE "manual" true
+Write .network.value."lo".BROADCAST "127.255.255.255" true
+Write .network.value."lo".IPADDR "127.0.0.1/8" true
+Write .network.value."lo".NETWORK "127.0.0.0" true
+Write .network.value."lo".PREFIXLEN "8" true
+Write .network.value."lo".STARTMODE "auto" true
+Write .network.value."myri5".BOOTPROTO "dhcp" true
+Write .network.value."myri5".STARTMODE "manual" true
+Write .network.value."eth0.3".BOOTPROTO "dhcp" true
+Write .network.value."eth0.3".ETHERDEVICE "eth0" true
+Write .network.value."eth0.3".STARTMODE "manual" true
+Write .network.value."myvlantoo".BOOTPROTO "dhcp" true
+Write .network.value."myvlantoo".ETHERDEVICE "eth0" true
+Write .network.value."myvlantoo".STARTMODE "manual" true
+Write .network.value."myvlantoo".VLAN_ID "2" true
+Write .network.value."virtlan4".BOOTPROTO "dhcp" true
+Write .network.value."virtlan4".ETHERDEVICE "eth0" true
+Write .network.value."virtlan4".STARTMODE "manual" true
+Write .network.value."vlan3".BOOTPROTO "dhcp" true
+Write .network.value."vlan3".ETHERDEVICE "eth0" true
+Write .network.value."vlan3".STARTMODE "manual" true
+Write .network nil true
+Return true
Dump NetworkInterfaces::Export
Dump exported=$["arc":$["arc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"atm":$["atm5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ci":$["ci5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ctc":$["ctc5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"dummy":$["dummy5":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4",
"NETMASK":"255.0.0.0", "PREFIXLEN":"8", "STARTMODE":"manual"]],
"escon":$["escon5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"eth":$["eth5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"],
"eth6":$["BOOTPROTO":"static", "IPADDR":"1.2.3.4", "NETMASK":"255.255.255.255",
"PREFIXLEN":"32", "STARTMODE":"manual"], "eth7":$["STARTMODE":"manual"],
"eth8":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0", "PREFIXLEN":"8",
"STARTMODE":"manual"], "eth9":$["IPADDR":"1.2.3.4", "NETMASK":"255.0.0.0",
"PREFIXLEN":"8", "STARTMODE":"manual"], "mynet0":$["BOOTPROTO":"dhcp",
"INTERFACETYPE":"eth", "STARTMODE":"auto"]],
"fddi":$["fddi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"hippi":$["hippi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"hsi":$["hsi5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"ippp":$["ippp5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"iucv":$["iucv5":$["BOOTPROTO":"dhcp", "STARTMODE":"manual"]],
"lo":$["lo":$["BROADCAST":"127.255.255.255", "IPADDR":"127.0.0.1",
"NETMASK":"255.0.0.0", "NETWORK":"127.0.0.0", "PREFIXLEN":"8",
"STARTMODE":"auto"]], "myri":$["myri5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "ppp":$["ppp5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "tr":$["tr5":$["BOOTPROTO":"dhcp",
"STARTMODE":"manual"]], "vlan":$["eth0.3":$["BOOTPROTO":"dhcp",
"ETHERDEVICE":"eth0", "STARTMODE":"manual"], "myvlantoo":$["BOOTPROTO":"dhcp",
"ETHERDEVICE":"eth0", "STARTMODE":"manual", "VLAN_ID":"2"],
"virtlan4":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"],
"vlan3":$["BOOTPROTO":"dhcp", "ETHERDEVICE":"eth0", "STARTMODE":"manual"]]]
Dump NetworkInterfaces::Import
diff -r 1814b26e32bf
yast2/library/network/testsuite/tests/NetworkInterfaces2.ycp
--- a/yast2/library/network/testsuite/tests/NetworkInterfaces2.ycp Mon Aug
29 15:23:17 2011 +0200
+++ b/yast2/library/network/testsuite/tests/NetworkInterfaces2.ycp Tue Aug
30 15:19:58 2011 +0200
@@ -82,12 +82,12 @@
NetworkInterfaces::OriginalDevices = nil;

DUMP("NetworkInterfaces::Write");
-TEST(``(NetworkInterfaces::Write("")), [READ], nil);
TEST(``(NetworkInterfaces::Write("eth")), [READ], nil);
TEST(``(NetworkInterfaces::Write("ppp")), [READ], nil);
TEST(``(NetworkInterfaces::Write("ippp")), [READ], nil);
TEST(``(NetworkInterfaces::Write("trx")), [READ], nil);
TEST(``(NetworkInterfaces::Write("atm|tr")), [READ], nil);
+TEST(``(NetworkInterfaces::Write("")), [READ], nil);

map<string,map> exported = nil;

< Previous Next >
Follow Ups