aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <v.maffione@gmail.com>2017-02-07 12:23:45 +0100
committerVincenzo Maffione <v.maffione@gmail.com>2017-02-07 12:26:32 +0100
commit450508c61660875d2c2725ff4e4eb49656de8750 (patch)
tree90f587d342302848143352be302670b0214b3ae9
parent54a12620aadfac69f528cdcce37592b4e35e12cf (diff)
downloadrumba-450508c61660875d2c2725ff4e4eb49656de8750.tar.gz
rumba-450508c61660875d2c2725ff4e4eb49656de8750.zip
move jFedTestbed in its own class
-rw-r--r--example.py6
-rw-r--r--jfed_support.py134
-rwxr-xr-xrhumba.py17
-rw-r--r--rhumba_jfed.py149
4 files changed, 153 insertions, 153 deletions
diff --git a/example.py b/example.py
index 6013173..4d0f9de 100644
--- a/example.py
+++ b/example.py
@@ -3,6 +3,8 @@
# An example script using rhumba.py
from rhumba import *
+import rhumba_emulab as emulab
+import rhumba_jfed as jfed
import rhumba_ouroboros as our
import rhumba_rlite as rl
import rhumba_irati as irati
@@ -22,12 +24,12 @@ b = Node("b",
difs = [e1, n1],
dif_registrations = {n1 : [e1]})
-tb = jFedTestbed(exp_name = "letest",
+tb = jfed.jFedTestbed(exp_name = "letest",
username = "sander",
cert_file = "cert.pem",
jfed_jar = "jfed_cli/experimenter-cli.jar")
-exp = IRATIExperiment(tb, nodes = [a, b])
+exp = irati.IRATIExperiment(tb, nodes = [a, b])
print(exp)
diff --git a/jfed_support.py b/jfed_support.py
deleted file mode 100644
index c98277d..0000000
--- a/jfed_support.py
+++ /dev/null
@@ -1,134 +0,0 @@
-#
-# jFed support for Rhumba
-#
-# Sander Vrijders <sander.vrijders@intec.ugent.be>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301 USA
-
-import subprocess
-import xml.dom.minidom as xml
-
-def create_rspec(testbed, nodes, links):
- testbed.rspec = testbed.exp_name + ".rspec"
-
- impl = xml.getDOMImplementation()
- doc = impl.createDocument(None, "rspec", None)
-
- top_el = doc.documentElement
- top_el.setAttribute("xmlns", "http://www.geni.net/resources/rspec/3")
- top_el.setAttribute("type", "request")
- top_el.setAttribute("xmlns:emulab", "http://www.protogeni.net/resources/" +
- "rspec/ext/emulab/1")
- top_el.setAttribute("xmlns:jfedBonfire", "http://jfed.iminds.be/rspec/" +
- "ext/jfed-bonfire/1")
- top_el.setAttribute("xmlns:delay", "http://www.protogeni.net/resources/" +
- "rspec/ext/delay/1")
- top_el.setAttribute("xmlns:jfed-command", "http://jfed.iminds.be/" +
- "rspec/ext/jfed-command/1")
- top_el.setAttribute("xmlns:client", "http://www.protogeni.net/resources/" +
- "rspec/ext/client/1")
- top_el.setAttribute("xmlns:jfed-ssh-keys", "http://jfed.iminds.be/rspec" +
- "/ext/jfed-ssh-keys/1")
- top_el.setAttribute("xmlns:jfed", "http://jfed.iminds.be/rspec/ext/jfed/1")
- top_el.setAttribute("xmlns:sharedvlan", "http://www.protogeni.net/" +
- "resources/rspec/ext/shared-vlan/1")
- top_el.setAttribute("xmlns:xsi", "http://www.w3.org/2001/" +
- "XMLSchema-instance")
- top_el.setAttribute("xsi:schemaLocation", "http://www.geni.net/" +
- "resources/rspec/3 http://www.geni.net/" +
- "resources/rspec/3/request.xsd")
-
- for node in nodes:
- el = doc.createElement("node")
- top_el.appendChild(el)
- el.setAttribute("client_id", node.name)
- el.setAttribute("exclusive", "true")
- el.setAttribute("component_manager_id", testbed.authority)
-
- el2 = doc.createElement("sliver_type")
- el.appendChild(el2)
- el2.setAttribute("name", "raw-pc")
-
- node.ifs = 0
- for link in links:
- if link.node_a == node or link.node_b == node:
- el3 = doc.createElement("interface")
- if link.node_a == node:
- link_id = link.int_a.id = node.name + ":if" + str(node.ifs)
- if link.node_b == node:
- link_id = link.int_b.id = node.name + ":if" + str(node.ifs)
-
- el3.setAttribute("client_id", link_id)
- node.ifs += 1
- el.appendChild(el3)
-
- for link in links:
- el = doc.createElement("link")
- top_el.appendChild(el)
- el.setAttribute("client_id", link.name)
-
- el2 = doc.createElement("component_manager_id")
- el2.setAttribute("name", testbed.authority)
- el.appendChild(el2)
-
- el3 = doc.createElement("interface_ref")
- el3.setAttribute("client_id", link.int_a.id)
- el.appendChild(el3)
-
- el4 = doc.createElement("interface_ref")
- el4.setAttribute("client_id", link.int_b.id)
- el.appendChild(el4)
-
- file = open(testbed.rspec, "w")
- file.write(doc.toprettyxml())
- file.close()
-
-def create_experiment(testbed, nodes, links):
- create_rspec(testbed, nodes, links)
- testbed.manifest = testbed.exp_name + ".rrspec"
-
- for node in nodes:
- auth_name_r = testbed.auth_name.replace(".", "-")
- node.full_name = node.name + "." + testbed.exp_name + "." + \
- testbed.proj_name + "." + auth_name_r + \
- "." + testbed.auth_name
-
- subprocess.call(["java", "-jar", testbed.jfed_jar, "create", "-S", \
- testbed.proj_name, "--rspec", \
- testbed.rspec, "-s", \
- testbed.exp_name, "-p", testbed.cert_file, "-k", \
- "usercert,userkeys,shareduserallkeys", "--create-slice",\
- "--manifest", testbed.manifest,
- "-P", testbed.password, \
- "-e", testbed.exp_hours])
-
- rspec = xml.parse(testbed.manifest)
- xml_nodes = rspec.getElementsByTagName("node")
-
- for xml_node in xml_nodes:
- n_name = xml_node.getAttribute("client_id")
- intfs = xml_node.getElementsByTagName("interface")
- for link in links:
- if link.node_a.name == n_name:
- interface = link.int_a
- if link.node_b.name == n_name:
- interface = link.int_b
- for intf in intfs:
- comp_id = intf.getAttribute("component_id")
- comp_arr = comp_id.split(":")
- interface.name = comp_arr[-1]
- xml_ip = intf.getElementsByTagName("ip")
- interface.ip = xml_ip[0].getAttribute("address")
diff --git a/rhumba.py b/rhumba.py
index c338bf8..00f67ba 100755
--- a/rhumba.py
+++ b/rhumba.py
@@ -19,9 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
-import jfed_support as js
import abc
-import getpass
# Represents generic testbed info
#
@@ -42,21 +40,6 @@ class Testbed:
raise Exception('create_experiment() not implemented')
-class jFedTestbed:
- def __init__(self, exp_name, username, cert_file, jfed_jar, exp_hours = "2",
- proj_name = "ARCFIRE", authority = "wall2.ilabt.iminds.be"):
- passwd = getpass.getpass(prompt = "Password for certificate file: ")
- Testbed.__init__(self, exp_name, username, passwd, proj_name)
- self.authority = "urn:publicid:IDN+" + authority + "+authority+cm"
- self.auth_name = authority
- self.cert_file = cert_file
- self.jfed_jar = jfed_jar
- self.exp_hours = exp_hours
-
- def create_experiment(self, nodes, links):
- js.create_experiment(self, nodes, links)
-
-
# Fake testbed, useful for testing
class FakeTestbed:
def __init__(self, exp_name, username, proj_name = "ARCFIRE",
diff --git a/rhumba_jfed.py b/rhumba_jfed.py
new file mode 100644
index 0000000..67012fa
--- /dev/null
+++ b/rhumba_jfed.py
@@ -0,0 +1,149 @@
+#
+# jFed support for Rhumba
+#
+# Sander Vrijders <sander.vrijders@intec.ugent.be>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+
+import rhumba
+import subprocess
+import getpass
+import xml.dom.minidom as xml
+
+
+class jFedTestbed(rhumba.Testbed):
+ def __init__(self, exp_name, username, cert_file, jfed_jar, exp_hours = "2",
+ proj_name = "ARCFIRE", authority = "wall2.ilabt.iminds.be"):
+ passwd = getpass.getpass(prompt = "Password for certificate file: ")
+ rhumba.Testbed.__init__(self, exp_name, username, passwd, proj_name)
+ self.authority = "urn:publicid:IDN+" + authority + "+authority+cm"
+ self.auth_name = authority
+ self.cert_file = cert_file
+ self.jfed_jar = jfed_jar
+ self.exp_hours = exp_hours
+
+ def create_rspec(self, nodes, links):
+ self.rspec = self.exp_name + ".rspec"
+
+ impl = xml.getDOMImplementation()
+ doc = impl.createDocument(None, "rspec", None)
+
+ top_el = doc.documentElement
+ top_el.setAttribute("xmlns", "http://www.geni.net/resources/rspec/3")
+ top_el.setAttribute("type", "request")
+ top_el.setAttribute("xmlns:emulab", "http://www.protogeni.net/resources/" +
+ "rspec/ext/emulab/1")
+ top_el.setAttribute("xmlns:jfedBonfire", "http://jfed.iminds.be/rspec/" +
+ "ext/jfed-bonfire/1")
+ top_el.setAttribute("xmlns:delay", "http://www.protogeni.net/resources/" +
+ "rspec/ext/delay/1")
+ top_el.setAttribute("xmlns:jfed-command", "http://jfed.iminds.be/" +
+ "rspec/ext/jfed-command/1")
+ top_el.setAttribute("xmlns:client", "http://www.protogeni.net/resources/" +
+ "rspec/ext/client/1")
+ top_el.setAttribute("xmlns:jfed-ssh-keys", "http://jfed.iminds.be/rspec" +
+ "/ext/jfed-ssh-keys/1")
+ top_el.setAttribute("xmlns:jfed", "http://jfed.iminds.be/rspec/ext/jfed/1")
+ top_el.setAttribute("xmlns:sharedvlan", "http://www.protogeni.net/" +
+ "resources/rspec/ext/shared-vlan/1")
+ top_el.setAttribute("xmlns:xsi", "http://www.w3.org/2001/" +
+ "XMLSchema-instance")
+ top_el.setAttribute("xsi:schemaLocation", "http://www.geni.net/" +
+ "resources/rspec/3 http://www.geni.net/" +
+ "resources/rspec/3/request.xsd")
+
+ for node in nodes:
+ el = doc.createElement("node")
+ top_el.appendChild(el)
+ el.setAttribute("client_id", node.name)
+ el.setAttribute("exclusive", "true")
+ el.setAttribute("component_manager_id", self.authority)
+
+ el2 = doc.createElement("sliver_type")
+ el.appendChild(el2)
+ el2.setAttribute("name", "raw-pc")
+
+ node.ifs = 0
+ for link in links:
+ if link.node_a == node or link.node_b == node:
+ el3 = doc.createElement("interface")
+ if link.node_a == node:
+ link_id = link.int_a.id = node.name + ":if" + str(node.ifs)
+ if link.node_b == node:
+ link_id = link.int_b.id = node.name + ":if" + str(node.ifs)
+
+ el3.setAttribute("client_id", link_id)
+ node.ifs += 1
+ el.appendChild(el3)
+
+ for link in links:
+ el = doc.createElement("link")
+ top_el.appendChild(el)
+ el.setAttribute("client_id", link.name)
+
+ el2 = doc.createElement("component_manager_id")
+ el2.setAttribute("name", self.authority)
+ el.appendChild(el2)
+
+ el3 = doc.createElement("interface_ref")
+ el3.setAttribute("client_id", link.int_a.id)
+ el.appendChild(el3)
+
+ el4 = doc.createElement("interface_ref")
+ el4.setAttribute("client_id", link.int_b.id)
+ el.appendChild(el4)
+
+ file = open(self.rspec, "w")
+ file.write(doc.toprettyxml())
+ file.close()
+
+ def create_experiment(self, nodes, links):
+ self.create_rspec(nodes, links)
+ self.manifest = self.exp_name + ".rrspec"
+
+ for node in nodes:
+ auth_name_r = self.auth_name.replace(".", "-")
+ node.full_name = node.name + "." + self.exp_name + "." + \
+ self.proj_name + "." + auth_name_r + \
+ "." + self.auth_name
+
+ subprocess.call(["java", "-jar", self.jfed_jar, "create", "-S", \
+ self.proj_name, "--rspec", \
+ self.rspec, "-s", \
+ self.exp_name, "-p", self.cert_file, "-k", \
+ "usercert,userkeys,shareduserallkeys", "--create-slice",\
+ "--manifest", self.manifest,
+ "-P", self.password, \
+ "-e", self.exp_hours])
+
+ rspec = xml.parse(self.manifest)
+ xml_nodes = rspec.getElementsByTagName("node")
+
+ for xml_node in xml_nodes:
+ n_name = xml_node.getAttribute("client_id")
+ intfs = xml_node.getElementsByTagName("interface")
+ for link in links:
+ if link.node_a.name == n_name:
+ interface = link.int_a
+ if link.node_b.name == n_name:
+ interface = link.int_b
+ for intf in intfs:
+ comp_id = intf.getAttribute("component_id")
+ comp_arr = comp_id.split(":")
+ interface.name = comp_arr[-1]
+ xml_ip = intf.getElementsByTagName("ip")
+ interface.ip = xml_ip[0].getAttribute("address")
+