Update test scripts for IPv6 support
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 28 Jul 2010 17:59:05 +0000 (19:59 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 29 Jul 2010 00:12:54 +0000 (02:12 +0200)
test/list-services
test/set-address

index 952211d4c1e65b51a6e1f8a7a2b5f6c14a1579ac..bd962377f7d52be331e47123c2fbb63a9b36323a 100755 (executable)
@@ -6,7 +6,10 @@ def extract_values(values):
        val = "{"
        for key in values.keys():
                val += " " + key + "="
-               val += str(values[key])
+               if key in ["PrefixLength"]:
+                       val += "%s" % (int(values[key]))
+               else:
+                       val += str(values[key])
        val += " }"
        return val
 
@@ -33,7 +36,9 @@ for path in properties["Services"]:
        print "[ %s ]" % (path)
 
        for key in properties.keys():
-               if key in ["IPv4", "IPv4.Configuration", "Proxy", "Ethernet"]:
+               if key in ["IPv4", "IPv4.Configuration",
+                               "IPv6", "IPv6.Configuration",
+                                       "Proxy", "Ethernet"]:
                        val = extract_values(properties[key])
                elif key in ["Nameservers", "Nameservers.Configuration",
                                        "Domains", "Domains.Configuration"]:
index 529b63516433adcb017a941a61b3a1522d062676..4933c6016e3ee1eb181ac51bf418b2ef4df1ad63 100755 (executable)
@@ -4,7 +4,7 @@ import sys
 import dbus
 
 if (len(sys.argv) < 3):
-       print "Usage: %s <address> <netmask> <gateway>" % (sys.argv[0])
+       print "Usage: %s <address> <netmask | prefix length> <gateway> [version]" % (sys.argv[0])
        sys.exit(1)
 
 bus = dbus.SystemBus()
@@ -20,10 +20,26 @@ for path in properties["Services"]:
 
        properties = service.GetProperties()
 
-       print "Setting address %s for %s" % (sys.argv[1], path)
 
-       service.SetProperty("IPv4.Configuration",
-               { "Method": "manual", "Address": sys.argv[1],
-                       "Netmask": sys.argv[2], "Gateway": sys.argv[3]})
+
+       if (len(sys.argv) == 5 and sys.argv[4] == "ipv6"):
+               ipv = 6
+       else:
+               ipv = 4
+
+       print "Setting IPv%d address %s for %s" % (ipv, sys.argv[1], path)
+
+       if (ipv == 4):
+               service.SetProperty("IPv4.Configuration",
+                                       { "Method": "manual",
+                                               "Address": sys.argv[1],
+                                               "Netmask": sys.argv[2],
+                                                       "Gateway": sys.argv[3]})
+       else:
+               service.SetProperty("IPv6.Configuration",
+                                       { "Method": "manual",
+                                               "Address": sys.argv[1],
+                                               "PrefixLength": sys.argv[2],
+                                                       "Gateway": sys.argv[3]})
 
        print