Support scripts for openvswitch
authorSapan Bhatia <gwsapan@gmail.com>
Wed, 19 Jan 2011 21:44:53 +0000 (16:44 -0500)
committerSapan Bhatia <gwsapan@gmail.com>
Wed, 19 Jan 2011 21:44:53 +0000 (16:44 -0500)
exec/connectswitch [new file with mode: 0755]
exec/makeswitch [new file with mode: 0755]
exec/showswitch [new file with mode: 0755]
exec/vif_up

diff --git a/exec/connectswitch b/exec/connectswitch
new file mode 100755 (executable)
index 0000000..fb15ee3
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import sys
+import pwd
+import re
+import socket
+import struct
+import os
+import string
+
+vsys_config_dir = "/etc/planetlab/vsys-attributes"
+
+if len(sys.argv) != 2: sys.exit(1)
+
+slicename=sys.argv[1]
+sliceid = pwd.getpwnam(slicename).pw_uid
+dpname = "dp-%d"%sliceid
+
+### Read args from stdin
+arglines = map(string.strip, sys.stdin.readlines())
+if len(arglines) != 1: sys.exit(1)
+of_server = arglines[0]
+
+if re.match(r'^(tcp|udp):[\d\.]+$', vif) is None: exit(1)
+
+print "Requesting creation of data path %s."%dpname
+os.system("ovs-openflowd dp0 tcp:192.168.1.2")
diff --git a/exec/makeswitch b/exec/makeswitch
new file mode 100755 (executable)
index 0000000..2412291
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import sys
+import pwd
+import re
+import socket
+import struct
+import os
+import string
+
+vsys_config_dir = "/etc/planetlab/vsys-attributes"
+
+if len(sys.argv) != 2: sys.exit(1)
+
+slicename=sys.argv[1]
+sliceid = pwd.getpwnam(slicename).pw_uid
+
+dpname = "dp-%d"%sliceid
+
+print "Requesting creation of data path %s."%dpname
+os.system("ovs-dpctl add-dp %s"%dpname)
diff --git a/exec/showswitch b/exec/showswitch
new file mode 100755 (executable)
index 0000000..35e86c2
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import sys
+import pwd
+import re
+import socket
+import struct
+import os
+import string
+
+vsys_config_dir = "/etc/planetlab/vsys-attributes"
+
+if len(sys.argv) != 2: sys.exit(1)
+
+slicename=sys.argv[1]
+sliceid = pwd.getpwnam(slicename).pw_uid
+
+dpname = "dp-%d"%sliceid
+
+os.system("ovs-dpctl show %s"%dpname)
index 0f905c6..885f1b2 100755 (executable)
@@ -102,6 +102,7 @@ if vmask<mask:
 opt_txqueuelen = None
 opt_rp_filter = None
 opt_snat = None
+opt_ovs_dp = None
 
 
 for optionline in options:
@@ -127,17 +128,17 @@ for optionline in options:
             print >>sys.stderr, "txqueuelen value %s out of range 1-10000" % (val)
             sys.exit(1)
         opt_txqueuelen = intval
-
     elif opt=="snat":
        intval = int(val)
        if val=="1":
          opt_snat = True
+    elif opt=="vswitch":
+       opt_ovs_dp = val
     else:
         print >>sys.stderr, "Unknown option: \"%s\"" % (opt)
         sys.exit(1)
 
 
-        
 ### Configure interface
 
 if opt_txqueuelen is None:
@@ -173,4 +174,7 @@ if opt_rp_filter is not None:
     rp_cmd = "/sbin/sysctl net.ipv4.conf.%s.rp_filter=%s" % (vif, opt_rp_filter)
     os.system(rp_cmd)
 
-
+# OVS datapath
+if opt_ovs_dp is not None:
+    cmd_ovs_addif = "ovs-dpctl add-if %s %s"%(opt_ovs_dp,vif)
+    os.system(cmd_ovs_addif)