Example #1
0
# This limitation does (of course) NOT hold for links between switches.
#
# Dynamic adding and removing of nodes also does not work when using the
# UserSwitch.

import time

from src.mininet.topo import Topo
from src.mininet.node import OVSSwitch

from src.maxinet.Frontend import maxinet_main
from src.maxinet.tools import Tools

# create topology
topo = Topo()
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addSwitch("s1", dpid=Tools.makeDPID(1))
topo.addLink("h1", "s1")
topo.addLink("h2", "s1")

# start cluster
cluster = maxinet_main.Cluster(minWorkers=2, maxWorkers=2)

# start experiment with OVSSwitch on cluster
exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

print "waiting 5 seconds for routing algorithms on the controller to converge"
time.sleep(5)
Example #2
0
def get_attribute(node, attribute):
    print(node.nn + "." + attribute)
    ok = False
    try:
        print("\t->" + str(node._get(attribute)))
        ok = True
    except Exception as e:
        print("\tFAILED")
        traceback.print_exc()
    if ok:
        print("\tOKAY")
    print


topo = Topo()
topo.addHost("h1", cls=CPULimitedHost, ip="10.0.0.251")
topo.addHost("h2", cls=CPULimitedHost, ip="10.0.0.252")
topo.addSwitch("s1")
topo.addLink("h1", "s1")
topo.addLink("h2", "s1")

cluster = maxinet_main.Cluster()
exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

h1 = exp.get_node("h1")
h2 = exp.get_node("h2")
s1 = exp.get_node("s1")

print(
    "#######################################################################")
Example #3
0
#!/usr/bin/env python2
""" An example showing all available methods and attributes of the NodeWrapper for Docker hosts.
"""

from src.maxinet.Frontend import maxinet_main
from src.maxinet.Frontend.libvirt import LibvirtHost
from src.mininet.topo import Topo
from src.mininet.node import OVSSwitch

topo = Topo()
vm1 = topo.addHost("vm1",
                   cls=LibvirtHost,
                   ip="10.0.0.251",
                   disk_image="/srv/images/ubuntu16.04.qcow2")

cluster = maxinet_main.Cluster()
exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

try:
    node_wrapper = exp.get_node("vm1")

    print("Testing methods:")
    print("=================")
    print("updateCpuLimit():")
    print("\t" +
          str(node_wrapper.updateCpuLimit(10000, 10000, 1, {
              0: "1",
              1: "0"
          })))  # cpu_quota, cpu_period, cpu_shares, cores
Example #4
0
#!/usr/bin/env python2
""" An example showing all available methods and attributes of the NodeWrapper for Docker hosts.
"""

from src.maxinet.Frontend import maxinet_main
from src.maxinet.Frontend.container import Docker
from src.mininet.topo import Topo
from src.mininet.node import OVSSwitch

topo = Topo()
d1 = topo.addHost("d1", cls=Docker, ip="10.0.0.251", dimage="ubuntu:trusty")

cluster = maxinet_main.Cluster()
exp = maxinet_main.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

try:
    node_wrapper = exp.get_node("d1")

    print("Testing methods:")
    print("=================")
    print("updateCpuLimit():")
    print("\t" + str(node_wrapper.updateCpuLimit(
        10000, 10000, 1, "0-1")))  # cpu_quota, cpu_period, cpu_shares, cores

    print("updateMemoryLimit():")
    print("\t" + str(node_wrapper.updateMemoryLimit(300000)))

    print("cgroupGet():")
    print("\t" + str(node_wrapper.cgroupGet('cpus', resource='cpuset')))