new layout - make room for slice-space stuff
[vsys-scripts.git] / root-context / exec / connectswitch
diff --git a/root-context/exec/connectswitch b/root-context/exec/connectswitch
new file mode 100755 (executable)
index 0000000..b61e186
--- /dev/null
@@ -0,0 +1,29 @@
+#!/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\.]+$', of_server) is None:
+    print "Address '%s' is invalid; should look like 'tcp:10.0.5.6'" % of_server
+    exit(1)
+
+print "Requesting creation of data path %s."%dpname
+os.system("ovs-openflowd %s %s" % (dpname, of_server))