示例#1
0
def add_link_to_rspec(config_info, site_dict, link_ifaces, vn, rspec, shared_vlan_info):
    ''' add link resource to RSpec '''
    if 'use_stitching' in config_info['general']:
        use_stitching = config_info['general']['use_stitching']
    else:
        use_stitching = None
        
    link_dict = get_link_types(site_dict, vn.link_list, use_stitching) 

    
    if vn.topo_type == 'lan':
        # single multi-node LAN topology
        for item in vn.link_list:
            link_name = 'lan' + str(vn.link_list.index(item))
            link = pg.LAN(link_name)
            if isinstance(item, list):
                # multi-node LAN links, adding relevant interfaces to the same LAN
                if not shared_vlan_info:
                    adding_iface_to_lan(item, link, link_ifaces)
                else:
                    sharedvlan = shared_vlan_info.keys()[0]
                    adding_iface_to_lan(item, link, link_ifaces, shared_vlan=sharedvlan)
            rspec.addResource(link)            
    else:
        # Mixed Topology or Typical non-LAN topolgoy
        for item in vn.link_list:         
            if isinstance(item, list):
                # Multi-node LAN part
                link_name = 'lan' + str(vn.link_list.index(item))
                link = pg.LAN(link_name)
                # get LAN information from the configuration file, if it exists
                sharedvlan = None
                for key, value in shared_vlan_info.items():
                    if value in item:
                        sharedvlan = key
                        break
                adding_iface_to_lan(item, link, link_ifaces, shared_vlan=sharedvlan)
            else:  
                # Non-LAN Part
                if item.member in link_dict['egre']:
                    item.update_type('egre')
                    index = link_dict['egre'].index(item.member)
                    link_name = item.link_type + str(index)
                    link = pg.L2GRE(link_name)
                elif item.member in link_dict['lan']:
                    item.update_type('lan')
                    index = link_dict['lan'].index(item.member)
                    link_name = item.link_type + str(index)
                    link = pg.LAN(link_name)
                elif item.member in link_dict['stitched']:
                    item.update_type('stitched')
                    index = link_dict['stitched'].index(item.member)
                    link_name = item.link_type + str(index)
                    link = pg.StitchedLink(link_name)
                else:
                    pass
                link.addInterface(link_ifaces[item.id][0])
                link.addInterface(link_ifaces[item.id][1])
            rspec.addResource(link)      
    return rspec
示例#2
0
def startInstance(nb, diskImg, instType, index, r=None, link=None):
    if r is None:
        r = rspec.Request()
        link = rspec.LAN("lan")

    for i in range(nb):
        node = rspec.RawPC("node" + str(i + index + 1))
        node.disk_image = diskImg
        node.hardware_type = instType
        iface = node.addInterface("if" + str(index + i + 1))

        # Specify the component id and the IPv4 address
        iface.component_id = "eth" + str(i + index + 1)
        iface.addAddress(
            rspec.IPv4Address("192.168.1." + str(index + i + 1),
                              "255.255.255.0"))

        link.addInterface(iface)
        node.addService(
            rspec.Install(
                url=
                "https://github.com/neilgiri/hotstuff/archive/master.tar.gz",
                path="/users/giridhn"))
        node.addService(
            rspec.Execute(
                shell="bash",
                command=
                "sudo tar -C /users/giridhn -xvzf /users/giridhn/hotstuff-master.tar.gz ; sudo apt-get update ; sudo apt-get install --yes golang-go"
            ))

        r.addResource(node)

    return r, link
示例#3
0
def create_lan(nodes):
    lan = pg.LAN("lan")

    # create an interface for each node and add it to the lan
    for i, n in enumerate(nodes):
        iface = n.addInterface("if1")
        iface.component_id = "eth1"
        iface.addAddress(
            pg.IPv4Address("192.168.1.{}".format(i + 1), "255.255.255.0"))
        lan.addInterface(iface)

    return lan
示例#4
0
    def add_household(self, house):
        """Summary

        Args:
            house (TYPE): Description

        Returns:
            TYPE: Description
        """

        # Import optional libraries
        import geni.rspec.pg as PG
        import geni.rspec.igext as IGX

        speed = max(house.rate_up_kbps, house.rate_down_kbps)
        self.links.insert(self.house_count_local,
                          PG.LAN('lan%d' % self.house_count))
        self.links[self.house_count_local].bandwidth = int(speed)

        igvm = IGX.XenVM("house-%d" % house.unit_id)

        ip_netem = "10.0.%d.0" % self.house_count
        netem_str = "$(ip route get %s | head -n 1 | cut -d \  -f4)" % (
            ip_netem)
        user_netem = house.netem_template_up(netem_str)
        server_netem = house.netem_template_down(netem_str)

        self.router.addService(
            PG.Execute(shell="/bin/sh", command=server_netem))
        igvm.addService(PG.Execute(shell="/bin/sh", command=user_netem))
        self.households.insert(self.house_count_local, igvm)

        iface = igvm.addInterface("if-%d-1" % self.house_count)
        iface.addAddress(
            PG.IPv4Address("10.0.%d.1" % self.house_count, "255.255.255.0"))
        self.links[self.house_count_local].addInterface(iface)

        server_iface = self.router.addInterface("if-%d-2" % self.house_count)
        server_iface.addAddress(
            PG.IPv4Address("10.0.%d.2" % self.house_count, "255.255.255.0"))
        self.links[self.house_count_local].addInterface(server_iface)

        self.house_count_local += 1
        self.house_count += 1
示例#5
0
def cluster(N_NODES, AM, SLICE_NAME, NODE_NAME, XML_NAME, SOFTWARE, PUBLIC_IP):
    rspec = PG.Request()
    IFACE = "if%d"
    INSTALL = "install-%s"
    for i in range(0, N_NODES):
        if i == 0:
            vm = IGX.XenVM("master")
            vm.disk_image = "urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU14-64-STD"
            rspec.addResource(vm)
            vm.routable_control_ip = PUBLIC_IP
            if N_NODES > 1:
                vm_iface = vm.addInterface(IFACE % i)
                link = PG.LAN("lan0")
                link.addInterface(vm_iface)

        else:
            vm = IGX.XenVM(NODE_NAME % (i - 1))
            vm.disk_image = "urn:publicid:IDN+emulab.net+image+emulab-ops:UBUNTU14-64-STD"
            rspec.addResource(vm)
            vm_iface = vm.addInterface(IFACE % i)
            link.addInterface(vm_iface)

        # Prepare nodes with corresponding software and install files
        # Create scripts for each software
        #for i in SOFTWARE:  # /bin/bash
        #    vm.addService(PG.Install(url=software(i), path="/tmp"))
        #    vm.addService(PG.Execute(shell="/bin/bash", command="sudo sh /tmp/%s" % INSTALL % i + ".sh"))

        # Docker installation (for Trusty)
        vm.addService(PG.Install(url="", path="/tmp/docker"))
        vm.addService(
            PG.Execute(shell="/bin/bash",
                       command="bash /tmp/docker/docker_inst_trusty.sh"))

    if N_NODES > 1:
        rspec.addResource(link)

    # Deploy resources at GENI
    manifest = AM.createsliver(context, SLICE_NAME, rspec)
    geni.util.printlogininfo(manifest=manifest)

    # Create manifest in XML file
    rspec.writeXML(XML_NAME)
示例#6
0
def setup():
    node = rspec.RawPC("node")
    #img = "urn:publicid:IDN+apt.emulab.net+image+schedock-PG0:docker-ubuntu16:0"
    #node.disk_image = img
    node.hardware_type = 'm400'
    iface1 = node.addInterface("if1")

    # Specify the component id and the IPv4 address
    iface1.component_id = "eth1"
    iface1.addAddress(rspec.IPv4Address("192.168.1.1", "255.255.255.0"))
    link = rspec.LAN("lan")
    link.addInterface(iface1)

    r = rspec.Request()
    r.addResource(node)

    request = {}
    request['cl-utah'] = r
    m = cl.request(experiment_name='testing138',
                   requests=request,
                   expiration=960,
                   timeout=15,
                   cloudlab_user='******',
                   cloudlab_password='******',
                   cloudlab_project='Consensus',
                   cloudlab_cert_path='cloudlab.pem',
                   cloudlab_key_path='~/.ssh/id_ed25519.pub')

    # read info in manifests to introspect allocation
    print(m['cl-utah'].nodes)
    for node in m['cl-utah'].nodes:
        print("Node")
        print(node)
        print(node.component_id)
        for iface in node.interfaces:
            print("Interface")
            print(iface)
            print(node.hostipv4)
            print(iface.address_info)
            print(iface.sliver_id)
示例#7
0
def Node(name, public):
    if params.raw:
        return RSpec.RawPC(name)
    elif public:
        vm = PublicVM(name)
        vm.ram = params.mem
        return vm
    else:
        vm = geni.rspec.igext.XenVM(name)
        vm.ram = params.mem
        return vm


rspec = RSpec.Request()

lan = RSpec.LAN()
rspec.addResource(lan)

node = Node("namenode", True)
node.disk_image = IMAGE
iface = node.addInterface("if0")
lan.addInterface(iface)
rspec.addResource(node)

node = Node("resourcemanager", True)
node.disk_image = IMAGE
iface = node.addInterface("if0")
lan.addInterface(iface)
rspec.addResource(node)

for i in range(params.n):
示例#8
0
pc.defineParameter("s", "Data Space of Raw machines", portal.ParameterType.STRING, "30GB")
pc.defineParameter("p", "Path of BlockStorage", portal.ParameterType.STRING, "/block_store")
pc.defineParameter("d", "Data Image of Raw machines", portal.ParameterType.STRING, "")

# Retrieve the values the user specifies during instantiation
params = pc.bindParameters()

# Create a Request object to start building the RSpec
rspec = pg.Request()

# Check parameter validity
if params.n < 1 or params.n > 64:
    pc.reportError(portal.ParameterError( "You must choose from 1 to 64"))
    
# Create nodes and links
link = pg.LAN("lan")

for i in range (params.n):
    node = pg.RawPC("node-"+str(i))
    if params.s != '':
        bs = node.Blockstore("bs"+str(i), params.p)
        bs.size = params.s
    if params.d != '':
        bsimg = node.Blockstore("bsi"+str(i), "/reusable_data")
        bsimg.dataset = params.d
    node.hardware_type=params.t
    node.disk_image=params.i
    rspec.addResource(node)
    iface = node.addInterface("if-"+str(i))
    link.addInterface(iface)
    
示例#9
0
        "For more details, refer to " +\
        "\"http://docs.cloudlab.us/hardware.html#%28part._apt-cluster%29\"")

# Default the cluster size to 2 nodes.
context.defineParameter("size", "Cluster Size",
        portal.ParameterType.INTEGER, 2, [],
        "Specify the size of the cluster." +\
        "To check availability of nodes, visit " +\
        "\"https://www.cloudlab.us/cluster-graphs.php\"")

params = context.bindParameters()

request = rspec.Request()

# Create a local area network over a 10 Gbps.
lan = rspec.LAN()
lan.bandwidth = 10000000  # This is in kbps.

# Setup node names.
rc_aliases = []
for i in range(params.size):
    rc_aliases.append("sandstorm%02d" % (i + 1))

# Setup the cluster one node at a time.
for i in range(params.size):
    node = rspec.RawPC(rc_aliases[i])

    node.hardware_type = params.type
    node.disk_image = urn.Image(cloudlab.Utah, "emulab-ops:%s" % params.image)

    # Install and run the startup scripts.
示例#10
0
    vm.component_id = node.component_id
    vm.component_manager_id = node.component_manager_id

  # VZNode
  # Sorry about the stupidity about how to find OpenVZ hosts.  I should fix this.
  vznode = [node for node in ad.nodes if not node.exclusive and "emulab-xen" not in node.sliver_types and node.hardware_types.has_key("pcvm")][0]
  vzc = PG.VZContainer("host3")
  intf = vzc.addInterface("if0")
  intf.addAddress(PG.IPv4Address(IPS[2], NETMASK))
  r.addResource(vzc)
  intfs.append(intf)
  vzc.component_id = vznode.component_id
  vzc.component_manager_id = vznode.component_manager_id

  # Controller
  cvm = PG.XenVM("controller")
  cvm.routable_control_ip = True
  cvm.component_manager_id = vznode.component_manager_id
  cvm.addService(PG.Install(url="http://www.gpolab.bbn.com/experiment-support/OpenFlowHW/of-hw.tar.gz", path="/local"))
  cvm.addService(PG.Execute(shell="sh", command = "sudo /local/install-script.sh"))
  r.addResource(cvm)

  # Big LAN!
  lan = PG.LAN()
  for intf in intfs:
    lan.addInterface(intf)
  lan.connectSharedVlan("mesoscale-openflow")
  r.addResource(lan)

  r.write("%s.rspec" % (site.name))
示例#11
0
snifferNodes = params.snifferNodes.split(" ")

rspec = RSpec.Request()

tour = IG.Tour()
tour.Description(
    IG.Tour.TEXT,
    "Create an experiment emulating the Ammon/Entrypoint deployment, and do some SDN stuff via netlink, using the nlsdn application."
)
rspec.addTour(tour)

vhosts = {}
nodes = {}
links = {}

mgmtlan = RSpec.LAN('mgmt-lan')
if params.multiplex:
    mgmtlan.link_multiplexing = True
    # Need this cause LAN() sets the link type to lan, not sure why.
    mgmtlan.type = "vlan"
if params.bestEffort:
    mgmtlan.best_effort = True
mgmtlan.trivial_ok = params.trivialOk

for (k, v) in addrs.iteritems():
    sa = k.split('-')[1:]
    (src, dst) = (sa[0], sa[1])
    if len(sa) > 2:
        linkidx = int(sa[2])
        postfix = "-" + sa[2]
    else:
示例#12
0
import geni.portal as portal
import geni.rspec.pg as RSpec
import geni.rspec.igext as IG

rspec = RSpec.Request()

tour = IG.Tour()
tour.Description(IG.Tour.TEXT,
                 "Two PCs connected via a link with asymmetric shaping for each.")
tour.Instructions(IG.Tour.MARKDOWN,
                  "None")
rspec.addTour(tour)

pc = portal.Context()

link = RSpec.LAN("shaped-link")
rspec.addResource(link)

node1 = RSpec.RawPC("node-1")
rspec.addResource(node1)
iface1 = node1.addInterface("if1")
iface1.bandwidth = 50000
iface1.latency = 5
iface1.plr = 0.05
link.addInterface(iface1)

node2 = RSpec.RawPC("node-2")
rspec.addResource(node2)
iface2 = node2.addInterface("if2")
iface2.bandwidth = 20000
iface2.latency = 15
xenshared = []
ad = IG.UtahDDC.listresources(context)
for node in ad.nodes:
    if node.available and node.shared:
        if "emulab-xen" in node.sliver_types:
            xenshared.append(node)

r = PG.Request()

n1 = PG.XenVM("xen1", component_id=xenshared[0].component_id)
n1.disk_image = DISK_IMAGE

n2 = PG.XenVM("xen2", component_id=xenshared[1].component_id)
n2.disk_image = DISK_IMAGE

r.addResource(n1)
r.addResource(n2)

for lan in xrange(0, 45):
    i1 = n1.addInterface("if%d" % (lan))
    i2 = n2.addInterface("if%d" % (lan))
    i1.bandwidth = 10000
    i2.bandwidth = 10000
    lnk = PG.LAN("lan-%d" % (lan))
    lnk.addInterface(i1)
    lnk.addInterface(i2)
    r.addResource(lnk)

r.write("pwe-build.xml")
示例#14
0
                                ("mellanox4", "Switch 4"),
                                ("mellanox5", "Switch 5"),
                                ("mellanox6", "Switch 6"),
                                ("mellanox7", "Switch 7"),
                                ("mellanox8", "Switch 8"),
                                ("mellanox9", "Switch 9")],
                   advanced=False,
                   groupId=None)

params = pc.bindParameters()
if params.num_nodes < 1:
    pc.reportError(
        portal.ParameterError("You must choose a minimum of 1 node "))
pc.verifyParameters()

lan = pg.LAN("lan")
nodes = []

switch_node = pg.RawPC("switch")
iface = switch_node.addInterface(
    "if-switch", pg.IPv4Address("10.2.100.100", "255.255.255.0"))
lan.addInterface(iface)

switch_node.hardware_type = params.node_type
switch_node.disk_image = SWITCH_DISK_IMAGE
switch_node.Desire(params.switch, 1.0)
switch_node.addService(
    pg.Install("https://github.com/ccanel/etalon/archive/master.tar.gz",
               "/local/"))
switch_node.addService(
    pg.Execute("/bin/bash", "/local/etalon-master/bin/switch_install.sh"))
    'n4': {
        'bandwidth': 10000,
        'latency': 20,
        'plr': 0.0
    },
}

rspec = RSpec.Request()

tour = IG.Tour()
tour.Description(
    IG.Tour.TEXT,
    "Four PCs with individual shaping parameters on the same LAN.")
tour.Instructions(IG.Tour.MARKDOWN, "None")
rspec.addTour(tour)

pc = portal.Context()

lan = RSpec.LAN("shaped-lan")
rspec.addResource(lan)

for nid, sparms in nodeset.items():
    node = RSpec.RawPC(nid)
    rspec.addResource(node)
    iface = node.addInterface("if1")
    for parm, val in sparms.items():
        iface.__dict__[parm] = val
    lan.addInterface(iface)

pc.printRequestRSpec(rspec)
示例#16
0
  cmid = ad.nodes[0].component_manager_id

  r = PG.Request()
  ovs_intfs = []

  ovs = PG.XenVM("OVS")
  ovs.disk_image = "urn:publicid:IDN+utahddc.geniracks.net+image+emulab-ops:Ubuntu12-64-OVS"
  ovs.addService(PG.Execute(shell="sh", command = "sudo /local/install-script.sh"))
  ovs.addService(PG.Install(path="/local", url = "http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/of-ovs.tar.gz"))
  ovs.component_manager_id = cmid
  for idx in xrange(0,3):
    intf = ovs.addInterface("if%d" % (idx))
    intf.addAddress(PG.IPv4Address(OVS_IPS[idx], NETMASK))
    ovs_intfs.append(intf)
  r.addResource(ovs)

  for ct in xrange(0,3):
    vzc = PG.VZContainer("host%d" % (ct+1))
    vzc.component_manager_id = cmid
    intf = vzc.addInterface("if0")
    intf.addAddress(PG.IPv4Address(HOST_IPS[ct], NETMASK))
    r.addResource(vzc)
    link = PG.LAN()
    link.addInterface(intf)
    link.addInterface(ovs_intfs[ct])
    link.enableVlanTagging()
    r.addResource(link)

  r.write("ovs-%s.rspec" % (site.name))