def bindVlans(rspec, pc, cid, start, end): for vlan in xrange(start, end + 1): intf = pc.addInterface("if%d" % (vlan)) intf.component_id = cid lnk = PG.Link() lnk.addInterface(intf) lnk.connectSharedVlan("pwe-segment-%d" % (vlan)) rspec.addResource(lnk) intf = pc.addInterface("meso:%s" % (cid)) intf.component_id = cid lnk = PG.Link() lnk.addInterface(intf) lnk.connectSharedVlan("mesoscale-openflow") rspec.addResource(lnk)
def nodes_rspec(context, number): interfaces = [i for i in xrange(number)] r = PG.Request() nodeA = PG.Node("A", "emulab-xen") nodeA.exclusive = False nodeA_host_intf_list = [] for i in interfaces: nodeA_host_intf = nodeA.addInterface("if_AH{0}".format(i)) nodeA_host_intf.addAddress(PG.IPv4Address("192.165.{0}.1".format(i+1), "255.255.255.0")) nodeA_host_intf_list.append(nodeA_host_intf) r.addResource(nodeA) nodeB = PG.Node("B", "emulab-xen") nodeB.exclusive = False nodeB_host_intf_list = [] for i in interfaces: nodeB_host_intf = nodeB.addInterface("if_BH{0}".format(i)) nodeB_host_intf.addAddress(PG.IPv4Address("192.168.{0}.1".format(i+1), "255.255.255.0")) nodeB_host_intf_list.append(nodeB_host_intf) r.addResource(nodeB) for i in interfaces: link = PG.Link("link{0}".format(interfaces[i])) link.addInterface(nodeA_host_intf_list[i]) link.addInterface(nodeB_host_intf_list[i]) link.bandwidth = 20000 r.addResource(link) name = "test-{0}.rspec".format(number) r.writeXML(name)
def two_nodes_rspec(context, slicename, location1, location2, ip1, ip2, port1, port2, bandwidth, location, number): ''' Create an RSpec for a simple two-node link''' interfaces = [i for i in xrange(number)] r = PG.Request() l1 = getResources(location1, context) l2 = getResources(location2, context) ip1List = [] if "," in ip1: ip1List = ip1.split(",") else: ip1List.append(ip1) ip2List = [] if "," in ip2: ip2List = ip2.split(",") else: ip2List.append(ip2) stub = PG.Node("ig-%s" % (location1), "emulab-xen") stub.component_manager_id = l1.nodes[0].component_manager_id # stub.addService(PG.Install(url="http://www.gpolab.bbn.com/~jbs/dingbot.tar.gz", path="/opt")) stub.addService(PG.Execute(shell="sh", command="sudo yum install iperf -y")) stub.exclusive = False stub_intf_list = [] for i in interfaces: stub_intf = stub.addInterface("if{0}".format(i)) stub_intf.addAddress(PG.IPv4Address(ip1List[i], "255.255.255.0")) stub_intf_list.append(stub_intf) r.addResource(stub) real = PG.Node("ig-%s" % (location2), "emulab-xen") real.component_manager_id = l2.nodes[0].component_manager_id real.addService(PG.Execute(shell="sh", command="sudo yum install iperf -y")) real.exclusive = False real_intf_list = [] for i in interfaces: real_intf = real.addInterface("if{0}".format(i)) real_intf.addAddress(PG.IPv4Address(ip2List[i], "255.255.255.0")) real_intf_list.append(real_intf) r.addResource(real) for i in interfaces: link = PG.Link("link{0}".format(interfaces[i])) link.addInterface(stub_intf_list[i]) link.addInterface(real_intf_list[i]) link.bandwidth = bandwidth r.addResource(link) name = location + "test-{0}-{1}-{2}.rspec".format(location1, location2, number) r.writeXML(name) return name
def two_nodes_rspec_simple(context, slicename, location1, location2, ip1, ip2, port1, port2, bandwidth, location, number): ''' Create an RSpec for a simple two-node link''' interfaces = [i for i in xrange(number)] r = PG.Request() nodeA = PG.Node("A", "emulab-xen") nodeA.exclusive = False nodeA_host_intf_list = [] for i in interfaces: nodeA_host_intf = nodeA.addInterface("if_AH{0}".format(i)) nodeA_host_intf.addAddress( PG.IPv4Address("192.165.{0}.1".format(i + 1), "255.255.255.0")) nodeA_host_intf_list.append(nodeA_host_intf) r.addResource(nodeA) nodeB = PG.Node("B", "emulab-xen") nodeB.exclusive = False nodeB_host_intf_list = [] for i in interfaces: nodeB_host_intf = nodeB.addInterface("if_BH{0}".format(i)) nodeB_host_intf.addAddress( PG.IPv4Address("192.168.{0}.1".format(i + 1), "255.255.255.0")) nodeB_host_intf_list.append(nodeB_host_intf) r.addResource(nodeB) for i in interfaces: link = PG.Link("link{0}".format(interfaces[i])) link.addInterface(nodeA_host_intf_list[i]) link.addInterface(nodeB_host_intf_list[i]) link.bandwidth = 20000 r.addResource(link) name = location + "test-{0}-{1}-{2}.rspec".format(location1, location2, number) r.writeXML(name) return name
def two_nodes_rspec(context, location1, location2, number): ''' Create an RSpec for a simple two-node link''' interfaces = [i for i in xrange(number)] r = PG.Request() stub = PG.Node("ig-%s" % (location1), "emulab-xen") stub.component_manager_id = "urn:publicid:IDN+instageni.wisc.edu+authority+cm" stub.addService(PG.Execute(shell="sh", command="sudo yum install iperf -y")) stub.exclusive = False stub_intf_list = [] for i in interfaces: stub_intf = stub.addInterface("if{0}".format(i)) stub_intf.addAddress(PG.IPv4Address("192.168.1.{0}".format(i+1), "255.255.255.0")) stub_intf_list.append(stub_intf) r.addResource(stub) real = PG.Node("ig-%s" % (location2), "emulab-xen") real.component_manager_id = "urn:publicid:IDN+instageni.rnet.missouri.edu+authority+cm" real.addService(PG.Execute(shell="sh", command="sudo yum install iperf -y")) real.exclusive = False real_intf_list = [] for i in interfaces: real_intf = real.addInterface("if{0}".format(i)) real_intf.addAddress(PG.IPv4Address("192.168.2.{0}".format(i+1), "255.255.255.0")) real_intf_list.append(real_intf) r.addResource(real) for i in interfaces: link = PG.Link("link{0}".format(interfaces[i])) link.addInterface(stub_intf_list[i]) link.addInterface(real_intf_list[i]) link.bandwidth = 20000 r.addResource(link) name = "test-{0}-{1}-{2}.rspec".format(location1, location2, number) r.writeXML(name)
# Copyright (c) 2016 Barnstormer Softworks, Ltd. # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import geni.rspec.pg as PG DISK_IMAGE = "urn:publicid:IDN+instageni.gpolab.bbn.com+image+emulab-ops:UBUNTU12-64-STD" ndata = [("bbn-ig-ps103-a", "10.42.103.111"), ("bbn-ig-ps103-b", "10.42.103.112")] r = PG.Request() for (name, ip) in ndata: vm = PG.XenVM(name) vm.disk_image = DISK_IMAGE vm.addService(PG.Install(url="http://www.gpolab.bbn.com/~jbs/dingbot-jbs.tar.gz", path="/opt")) vm.addService(PG.Install(url="http://www.gpolab.bbn.com/~jbs/dingbot.tar.gz", path="/opt")) vm.addService(PG.Execute(shell="/bin/bash", command="sudo /opt/dingbot/dingbot /opt/dingbot/dingbot-jbs.json %s" % (vm.name))) intf = vm.addInterface("if0") intf.addAddress(PG.IPv4Address(ip, "255.255.255.0")) lnk = PG.Link() lnk.addInterface(intf) lnk.connectSharedVlan("mesoscale-openflow") r.addResource(vm) r.addResource(lnk) r.write("ps103.xml")
def nodes_rspec(context, number): interfaces = [i for i in xrange(number)] r = PG.Request() nodeA = PG.Node("A", "emulab-xen") nodeA.addService( PG.Install( url= "http://pages.cs.wisc.edu/~rkrish/GENI/ospf-script-{0}intf.tar.gz". format(2 * number), path="/local")) nodeA.addService( PG.Execute(shell="sh", command="/local/ospf-script-{0}intf.sh".format(2 * number))) nodeA.exclusive = False nodeA_host_intf_list = [] nodeA_router_intf_list = [] for i in interfaces: nodeA_host_intf = nodeA.addInterface("if_AH{0}".format(i)) nodeA_host_intf.addAddress( PG.IPv4Address("192.165.{0}.1".format(i + 1), "255.255.255.0")) nodeA_host_intf_list.append(nodeA_host_intf) nodeA_router_intf = nodeA.addInterface("if_AR{0}".format(i)) nodeA_router_intf.addAddress( PG.IPv4Address("192.166.{0}.1".format(i + 1), "255.255.255.0")) nodeA_router_intf_list.append(nodeA_router_intf) r.addResource(nodeA) nodeB = PG.Node("B", "emulab-xen") nodeB.addService( PG.Install( url= "http://pages.cs.wisc.edu/~rkrish/GENI/ospf-script-{0}intf.tar.gz". format(2 * number), path="/local")) nodeB.addService( PG.Execute(shell="sh", command="/local/ospf-script-{0}intf.sh".format(2 * number))) nodeB.exclusive = False nodeB_host_intf_list = [] nodeB_router_intf_list = [] for i in interfaces: nodeB_router_intf = nodeB.addInterface("if_BR{0}".format(i)) nodeB_router_intf.addAddress( PG.IPv4Address("192.167.{0}.1".format(i + 1), "255.255.255.0")) nodeB_router_intf_list.append(nodeB_router_intf) nodeB_host_intf = nodeB.addInterface("if_BH{0}".format(i)) nodeB_host_intf.addAddress( PG.IPv4Address("192.168.{0}.1".format(i + 1), "255.255.255.0")) nodeB_host_intf_list.append(nodeB_host_intf) r.addResource(nodeB) router_intf_A_list = [] router_intf_B_list = [] host_intf_A_list = [] host_intf_B_list = [] for i in interfaces: router = PG.Node("Router{0}".format(i + 1), "emulab-xen") router.addService( PG.Install( url= "http://pages.cs.wisc.edu/~rkrish/GENI/ospf-script-2intf.tar.gz", path="/local")) router.addService( PG.Execute(shell="sh", command="/local/ospf-script-2intf.sh".format(number))) router.exclusive = False router_intf_A = router.addInterface("if_RA{0}".format(i)) router_intf_A.addAddress( PG.IPv4Address("192.166.{0}.2".format(i + 1), "255.255.255.0")) router_intf_A_list.append(router_intf_A) router_intf_B = router.addInterface("if_RB{0}".format(i)) router_intf_B.addAddress( PG.IPv4Address("192.167.{0}.2".format(i + 1), "255.255.255.0")) router_intf_B_list.append(router_intf_B) r.addResource(router) hostHA = PG.Node("H{0}".format(2 * i + 1), "emulab-xen") hostHA.addService( PG.Execute(shell="sh", command="sudo yum install iperf -y")) hostHA.exclusive = False host_intf_A = hostHA.addInterface("if_HA{0}".format(i)) host_intf_A.addAddress( PG.IPv4Address("192.165.{0}.2".format(i + 1), "255.255.255.0")) host_intf_A_list.append(host_intf_A) r.addResource(hostHA) hostHB = PG.Node("H{0}".format(2 * i + 2), "emulab-xen") hostHB.addService( PG.Execute(shell="sh", command="sudo yum install iperf -y")) hostHB.exclusive = False host_intf_B = hostHB.addInterface("if_HB{0}".format(i)) host_intf_B.addAddress( PG.IPv4Address("192.168.{0}.2".format(i + 1), "255.255.255.0")) host_intf_B_list.append(host_intf_B) r.addResource(hostHB) for i in interfaces: linkHA = PG.Link("linkHA{0}".format(interfaces[i])) linkHA.addInterface(host_intf_A_list[i]) linkHA.addInterface(nodeA_host_intf_list[i]) linkHA.bandwidth = 20000 r.addResource(linkHA) linkHB = PG.Link("linkHB{0}".format(interfaces[i])) linkHB.addInterface(host_intf_B_list[i]) linkHB.addInterface(nodeB_host_intf_list[i]) linkHB.bandwidth = 20000 r.addResource(linkHB) linkRA = PG.Link("linkRA{0}".format(interfaces[i])) linkRA.addInterface(router_intf_A_list[i]) linkRA.addInterface(nodeA_router_intf_list[i]) linkRA.bandwidth = 20000 r.addResource(linkRA) linkRB = PG.Link("linkRB{0}".format(interfaces[i])) linkRB.addInterface(router_intf_B_list[i]) linkRB.addInterface(nodeB_router_intf_list[i]) linkRB.bandwidth = 20000 r.addResource(linkRB) name = "Performance-{0}.rspec".format(number) r.writeXML(name)
pc = portal.Context() request = rspec.Request() pc.defineParameter("param1", "dsc1", portal.ParameterType.INTEGER, 1) pc.defineParameter("param2", "dsc2", portal.ParameterType.STRING, "value2") params = pc.bindParameters() ele2 = ET.Element("xmlstuff") ET.SubElement(ele2, "evenmorexml") node1 = IG.XenVM("node1") iface1 = node1.addInterface("if1") # Add user data to node1 in a single line node1.UserData(emulab.UserDataSet({"data1": ele2, "data2": "val2"})) link = rspec.Link("link") link.addInterface(iface1) # Add user data to link over several lines linkdata = emulab.UserDataSet() linkdata.addData("linkdata1", "val1") linkdata.addData("linkdata2", "val2") link.UserData(linkdata) request.addResource(node1) request.addResource(link) pc.verifyParameters() pc.printRequestRSpec(request)
if disableTestbedRootKeys: vhost.installRootKeys(False, False) vhost.exclusive = True if params.hostType: vhost.hardware_type = params.hostType if params.hostImage: vhost.disk_image = params.hostImage iface = vnode.addInterface("ifM") iface.addAddress( IPv4Address("%s.%s" % (mgmtprefix, mgmtmap[num]), prefixlen=mgmtbits)) mgmtlan.addInterface(iface) linkname = "link-%s-%s%s" % (src, dst, postfix) revlinkname = "link-%s-%s%s" % (dst, src, postfix) if not linkname in links and not revlinkname in links: links[linkname] = link = RSpec.Link(linkname) if params.linkSpeed > 0: link.bandwidth = int(params.linkSpeed) if params.linkLatency > 0: link.latency = int(params.linkLatency) if params.multiplex: link.link_multiplexing = True link.type = "vlan" if params.bestEffort: link.best_effort = True mgmtlan.trivial_ok = params.trivialOk # AS Prefix Assignment if nodemap[src] == 1 and nodemap[dst] == 1: # AS1 Prefix addInter(src, dst, prefix6, prefix4, postfix)
node.addService(RSpec.Install( DOWNLOAD, "/tmp" )) node.addService(RSpec.Execute(shell="/bin/sh", command="sudo sh /tmp/download.sh")) node.addService(RSpec.Execute(shell="/bin/sh", command="sh /tmp/hadoopOnGeni/install.sh")) iface = node.addInterface( "if0" ) lan.addInterface( iface ) rspec.addResource( node ) iface = node.addInterface() fsnode = rspec.RemoteBlockstore("fsnode", "/mydata") # This URN is displayed in the web interfaace for your dataset. fsnode.dataset = "urn:publicid:IDN+utah.cloudlab.us:basemod-pg0+stdataset+arab_test" # Now we add the link between the node and the special node fslink = RSpec.Link("fslink") fslink.addInterface(iface) fslink.addInterface(fsnode.interface) # Special attributes for this link that we must use. fslink.best_effort = True fslink.vlan_tagging = True rspec.addResource( node ) #data node #slave node for i in range( params.n ): node = RSpec.RawPC( "datanode" + str( i )) #node.hardware_type = "c8220" node.disk_image = IMAGE
#!/usr/bin/env python import geni.rspec.pg as rspec import geni.rspec.igext as ig import geni.portal as portal pc = portal.Context() rspec = pc.makeRequestRSpec() tour = ig.Tour() tour.Description(ig.Tour.TEXT, "Test description") tour.Instructions(ig.Tour.TEXT, "Text instructions") node1 = rspec.XenVM("src") node2 = rspec.XenVM("dst") link1 = rspec.Link("thelink", members=[node1, node2]) tour.addStep(ig.Tour.Step(node1, "This is the first node")) tour.steps.append(ig.Tour.Step(node2, "This is the second node")) tour.steps.append(ig.Tour.Step(link1, "This is the link")) rspec.addTour(tour) pc.printRequestRSpec()