当前位置: 首页>>代码示例>>Python>>正文


Python ExperimentController.register_condition方法代码示例

本文整理汇总了Python中nepi.execution.ec.ExperimentController.register_condition方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentController.register_condition方法的具体用法?Python ExperimentController.register_condition怎么用?Python ExperimentController.register_condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nepi.execution.ec.ExperimentController的用法示例。


在下文中一共展示了ExperimentController.register_condition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ccnpeek

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    def test_ccnpeek(self):
        ec = ExperimentController(exp_id = "test-linux-ccnpeek")
        
        node = ec.register_resource("linux::Node")
        ec.set(node, "hostname", self.fedora_host)
        ec.set(node, "username", self.fedora_user)
        ec.set(node, "identity", self.fedora_identity)
        #ec.set(node, "cleanProcesses", True)
        #ec.set(node, "cleanExperiment", True)

        ccnd = ec.register_resource("linux::CCND")
        ec.register_connection(ccnd, node)

        peek = ec.register_resource("linux::CCNPeek")
        ec.set(peek, "contentName", "ccnx:/chunk0")
        ec.register_connection(peek, ccnd)

        poke = ec.register_resource("linux::CCNPoke")
        ec.set(poke, "contentName", "ccnx:/chunk0")
        ec.set(poke, "content", "DATA")
        ec.register_connection(poke, ccnd)

        ec.register_condition(peek, ResourceAction.START, poke,
            ResourceState.STARTED)
 
        ec.deploy()

        ec.wait_finished(peek)

        stdout = ec.trace(peek, "stdout")
        print stdout
        expected = "DATA"
        self.assertTrue(stdout.find(expected) > -1)

        ec.shutdown()
开发者ID:phiros,项目名称:nepi,代码行数:37,代码来源:ccnpeek.py

示例2: test_stop_with_condition

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    def test_stop_with_condition(self):
        from nepi.execution.resource import ResourceFactory
        
        ResourceFactory.register_type(Application)
        ResourceFactory.register_type(Node)
        ResourceFactory.register_type(Interface)

        ec = ExperimentController()

        node = ec.register_resource("Node")

        app1 = ec.register_resource("Application")
        ec.register_connection(app1, node)

        app2 = ec.register_resource("Application")
        ec.register_connection(app2, node)

        ec.register_condition(app2, ResourceAction.START, app1, 
                ResourceState.STOPPED)

        ec.deploy()

        ec.wait_finished([app1, app2])
        
        rmapp1 = ec.get_resource(app1)
        rmapp2 = ec.get_resource(app2)

        self.assertTrue(rmapp2.start_time > rmapp1.stop_time)
        
        ec.shutdown()
开发者ID:phiros,项目名称:nepi,代码行数:32,代码来源:resource.py

示例3: t_condition

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    def t_condition(self, host, user, depends):

        ec = ExperimentController(exp_id="test-condition")
        
        node = ec.register_resource("linux::Node")
        ec.set(node, "hostname", host)
        ec.set(node, "username", user)
        ec.set(node, "cleanExperiment", True)
        ec.set(node, "cleanProcesses", True)

        server = ec.register_resource("linux::Application")
        cmd = "echo 'HOLA' | nc -l 3333"
        ec.set(server, "command", cmd)
        ec.set(server, "depends", depends)
        ec.register_connection(server, node)

        client = ec.register_resource("linux::Application")
        cmd = "nc 127.0.0.1 3333"
        ec.set(client, "command", cmd)
        ec.register_connection(client, node)

        ec.register_condition(client, ResourceAction.START, server, ResourceState.STARTED)

        apps = [client, server]
        
        ec.deploy()

        ec.wait_finished(apps)

        self.assertTrue(ec.state(node) == ResourceState.STARTED)
        self.assertTrue(ec.state(server) == ResourceState.STOPPED)
        self.assertTrue(ec.state(client) == ResourceState.STOPPED)

        stdout = ec.trace(client, "stdout")
        self.assertTrue(stdout.strip() == "HOLA")

        ec.shutdown()
开发者ID:phiros,项目名称:nepi,代码行数:39,代码来源:application.py

示例4: t_cross_ping

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    def t_cross_ping(self, host, user = None, identity = None):
        ec = ExperimentController(exp_id = "test-linux-ns3-tap-fd")
        
        node = ec.register_resource("linux::Node")
        if host == "localhost":
            ec.set(node, "hostname", "localhost")
        else:
            ec.set(node, "hostname", host)
            ec.set(node, "username", user)
            ec.set(node, "identity", identity)
        
        ec.set(node, "cleanProcesses", True)
        ec.set(node, "cleanExperiment", True)

        simu = ec.register_resource("linux::ns3::Simulation")
        ec.set(simu, "simulatorImplementationType", "ns3::RealtimeSimulatorImpl")
        ec.set(simu, "checksumEnabled", True)
        ec.set(simu, "verbose", True)
        #ec.set(simu, "buildMode", "debug")
        #ec.set(simu, "nsLog", "FdNetDevice")
        ec.register_connection(simu, node)

        nsnode1 = add_ns3_node(ec, simu)
        dev1 = add_point2point_device(ec, nsnode1, "10.0.0.1", "30")

        nsnode2 = add_ns3_node(ec, simu)
        dev2 = add_point2point_device(ec, nsnode2, "10.0.0.2", "30")
        
        # Add routes on the NS3 side
        r1 = ec.register_resource("ns3::Route")
        ec.set(r1, "network", "10.0.1.0")
        ec.set(r1, "prefix", "30")
        ec.set(r1, "nexthop", "10.0.0.1")
        ec.register_connection(r1, nsnode2)

        # Create channel
        chan = ec.register_resource("ns3::PointToPointChannel")
        ec.set(chan, "Delay", "0s")
        ec.register_connection(chan, dev1)
        ec.register_connection(chan, dev2)

        fddev = add_fd_device(ec, nsnode1, "10.0.1.2", "30")
        ec.enable_trace(fddev, "pcap")
        ec.enable_trace(fddev, "promiscPcap")
        ec.enable_trace(fddev, "ascii")

        tap = add_tap_device(ec, node, "10.0.1.1", "30")

        crosslink = ec.register_resource("linux::ns3::TapFdLink")
        ec.register_connection(crosslink, tap)
        ec.register_connection(crosslink, fddev)

        # Add routes on the localhost side
        r2 = ec.register_resource("linux::Route")
        ec.set(r2, "network", "10.0.0.0")
        ec.set(r2, "prefix", "30")
        ec.set(r2, "nexthop", "10.0.1.2")
        ec.register_connection(r2, tap)

        app = ec.register_resource("linux::Application")
        ec.set(app, "command", "ping -c3 10.0.0.1")
        ec.register_connection(app, node)

        ec.register_condition(app, ResourceAction.START, simu, 
                ResourceState.STARTED, time="5s")

        ec.deploy()

        ec.wait_finished([app])

        stdout = ec.trace(app, "stdout")
        expected = "3 packets transmitted, 3 received, 0% packet loss"
        self.assertTrue(stdout.find(expected) > -1)

        ## Releasing to force ns3 to flush the traces
        ec.release()
        pcap = ec.trace(fddev, "pcap")

        self.assertTrue(len(pcap) > 4000)
        ec.shutdown()
开发者ID:phiros,项目名称:nepi,代码行数:82,代码来源:cross_ns3_linux_ping.py

示例5: add_ccnd

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
ccnd1 = add_ccnd(ec, peers)
ec.register_connection(ccnd1, node1)

# Register content producer application (ccnseqwriter)
## Push the file into the repository
local_path_to_content = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
            "..", "big_buck_bunny_240p_mpeg4_lq.ts")

content_name = "ccnx:/test/FILE"

pub = add_publish(ec, local_path_to_content, content_name)
ec.register_connection(pub, node1)

# The movie can only be published after ccnd is running
ec.register_condition(pub, ResourceAction.START, 
        ccnd1, ResourceState.STARTED)

# Register Linux host
node2 = add_node(ec, hostname2, username, ssh_key)

# Register CCN setup for Linux host
peers = [hostname1]
ccnd2 = add_ccnd(ec, peers)
ec.register_connection(ccnd2, node2)
 
# Register consumer application (ccncat)
ccncat = add_ccncat(ec, content_name)
ec.register_connection(ccncat, node2)

# The file can only be retrieved after ccnd is running
ec.register_condition(ccncat, ResourceAction.START, 
开发者ID:phiros,项目名称:nepi,代码行数:34,代码来源:ccn_transfer_using_linuxapp.py

示例6: open

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
app1 = ec.register_resource("LinuxApplication")
file = "../big_file.geo"
ec.set(app1, "sources", file)
command = "scp $SRC/big_file.geo %s" % destination 
ec.set(app1, "command", command)
ec.register_connection(app1, node1)

app2 = ec.register_resource("LinuxApplication")
ec.set(app, "sudo", sudo)
ec.set(app, "depends", "ifstat")
command = "ifstat -b eth0 > ifstat.txt"
command = "iperf ..." 
ec.set(app2, "command", command)
ec.register_connection(app2, node1)

ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED)


# Deploy
ec.deploy()

ec.wait_finished([app1, app2])

trace_file = "examples/planetlab/ifstat.txt"
trace = ec.trace(app2, "ifstat.txt")
f = open(trace_file, "w")
f.write(trace)
f.close()

ec.shutdown()
开发者ID:ruben11291,项目名称:master-thesis,代码行数:32,代码来源:geo_cloud.py

示例7: OMFVLCWrongCaseWithNonCriticalDep

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
class OMFVLCWrongCaseWithNonCriticalDep(unittest.TestCase):

    id = 3000

    def setUp(self):
        self.ec = ExperimentController(exp_id = str(OMFVLCWrongCaseWithNonCriticalDep.id))
        OMFVLCWrongCaseWithNonCriticalDep.id += 1

        self.node1 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node1, 'hostname', 'wlab12')
        self.ec.set(self.node1, 'xmppUser', "nepi")
        self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
        self.ec.set(self.node1, 'xmppPort', "5222")
        self.ec.set(self.node1, 'xmppPassword', "1234")
        
        self.iface1 = self.ec.register_resource("omf::WifiInterface")
        self.ec.set(self.iface1, 'name', "wlan0")
        self.ec.set(self.iface1, 'mode', "adhoc")
        self.ec.set(self.iface1, 'hw_mode', "g")
        self.ec.set(self.iface1, 'essid', "vlcexp")
        self.ec.set(self.iface1, 'ip', "10.0.0.12/24")

        self.app1 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app1, 'appid', 'Kill#1')
        self.ec.set(self.app1, 'command', "/usr/bin/test -1")
        self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")

        self.ec.register_connection(self.app1, self.node1)
        self.ec.register_connection(self.node1, self.iface1)

    def test_deploy_with_app_nc_and_critical_wrong(self):
        self.node2 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node2, 'hostname', 'wlab49')
        self.ec.set(self.node2, 'xmppUser', "nepi")
        self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
        self.ec.set(self.node2, 'xmppPort', "5222")
        self.ec.set(self.node2, 'xmppPassword', "1234")

        self.iface2 = self.ec.register_resource("omf::WifiInterface")
        self.ec.set(self.iface2, 'name', "wlan0")
        self.ec.set(self.iface2, 'mode', "adhoc")
        self.ec.set(self.iface2, 'hw_mode', "g")
        self.ec.set(self.iface2, 'essid', "vlcexp")
        self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
        
        self.channel = self.ec.register_resource("omf::Channel")
        self.ec.set(self.channel, 'channel', "6")

        self.app2 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app2, "critical", False)
        self.ec.set(self.app2, 'appid', 'Kill#32')

        self.app3 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app3, 'appid', 'Kill#33')

        self.ec.register_connection(self.iface1, self.channel)
        self.ec.register_connection(self.node2, self.iface2)
        self.ec.register_connection(self.iface2, self.channel)
        self.ec.register_connection(self.app2, self.node2)
        self.ec.register_connection(self.app3, self.node2)

        self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "5s")
        self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "5s")
        self.ec.register_condition([self.app1, self.app2, self.app3], ResourceAction.STOP, self.app1, ResourceState.STARTED , "15s")

        self.ec.deploy()

        self.ec.wait_finished([self.app1, self.app2, self.app3])

        self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
        self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.FAILED)

        self.ec.shutdown()

        self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
        self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.RELEASED)

    def test_deploy_with_app_nc_and_critical_right(self):
        self.node2 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node2, 'hostname', 'wlab49')
        self.ec.set(self.node2, 'xmppUser', "nepi")
        self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
        self.ec.set(self.node2, 'xmppPort', "5222")
        self.ec.set(self.node2, 'xmppPassword', "1234")

        self.iface2 = self.ec.register_resource("omf::WifiInterface")
        self.ec.set(self.iface2, 'name', "wlan0")
        self.ec.set(self.iface2, 'mode', "adhoc")
        self.ec.set(self.iface2, 'hw_mode', "g")
        self.ec.set(self.iface2, 'essid', "vlcexp")
        self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
        
        self.channel = self.ec.register_resource("omf::Channel")
        self.ec.set(self.channel, 'channel', "6")
#.........这里部分代码省略.........
开发者ID:phiros,项目名称:nepi,代码行数:103,代码来源:omf6_vlc_wrong_non_critical.py

示例8: add_node

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    # border node 2
    bnode2 = add_node(ec, host6, pl_user, pl_ssh_key)
    ccndb2 = add_ccnd(ec, bnode2)
    ccnrb2 = add_ccnr(ec, ccndb2)
    ccnds[host6] = ccndb2
    app = add_stream(ec, ccndb2, content_name)
 
    # connect border nodes
    add_fib_entry(ec, ccndb1, host1)
    add_fib_entry(ec, ccnds[host1], host5)

    add_fib_entry(ec, ccndb2, host3)
    add_fib_entry(ec, ccnds[host3], host6)

    # Put down l5 10s after transfer started
    ec.register_condition(l5u, ResourceAction.STOP, 
            app, ResourceState.STARTED, time = "10s")
    ec.register_condition(l5d, ResourceAction.STOP, 
            app, ResourceState.STARTED, time = "10s")

    # Register a collector to automatically collect traces
    collector = add_collector(ec, "stderr")
    for ccnd in ccnds.values():
        ec.register_connection(collector, ccnd)

    # deploy all ResourceManagers
    ec.deploy()

    # Wait until ccncat has started retrieving the content
    ec.wait_started([app])

    rvideo_path = ec.trace(app, "stdout", attr = TraceAttr.PATH)
开发者ID:phiros,项目名称:nepi,代码行数:34,代码来源:ccncat_extended_ring_topo.py

示例9:

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
ec.set(chan, 'channel', "6")

# Create and Configure the Application
app1 = ec.register_resource("omf::Application")
ec.set(app1, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.27,port=1234,mux=ts}'")

app2 = ec.register_resource("omf::Application")
ec.set(app2, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.27:1234")


# Connection
ec.register_connection(iface1, node1)
ec.register_connection(iface2, node2)
ec.register_connection(iface1, chan)
ec.register_connection(iface2, chan)
ec.register_connection(app1, node1)
ec.register_connection(app2, node2)

ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "4s")
ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "30s")


# Deploy
ec.deploy()

ec.wait_finished([app1,app2])

# Stop Experiment
ec.shutdown()

开发者ID:phiros,项目名称:nepi,代码行数:31,代码来源:nepi_omf6_nitos_vlc.py

示例10:

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
## Add a OMFApplication to count the number of bytes in the transmitted video
app3 = ec.register_resource("omf::Application")
## Send the transmitted video to a file.
ec.set(app3, "command", "ls -lah /root/video.ts")
ec.register_connection(app3, node2)

app4 = ec.register_resource("omf::Application")
ec.set(app4, "command", "/usr/bin/killall vlc_app")
ec.register_connection(app4, node1)

app5 = ec.register_resource("omf::Application")
ec.set(app5, "command", "/usr/bin/killall vlc_app")
ec.register_connection(app5, node2)

## start app2 5s after app1
ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "5s")
# start app3 after app2 stopped
ec.register_condition(app3, ResourceAction.START, app2, ResourceState.STOPPED , "5s")
# start the kill of vlc processes after they stopped
ec.register_condition(app4, ResourceAction.START, app1, ResourceState.STOPPED , "5s")
ec.register_condition(app5, ResourceAction.START, app2, ResourceState.STOPPED , "5s")

## We need to explicitly STOP all applications
## stop app1 65s after it started
ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "65s")
## stop app2 5 seconds after app2
ec.register_condition(app2, ResourceAction.STOP, app1, ResourceState.STOPPED , "5s")
# stop app3 after 5s
ec.register_condition(app3, ResourceAction.STOP, app3, ResourceState.STOPPED , "5s")
# stop app4 
ec.register_condition(app4, ResourceAction.STOP, app4, ResourceState.STARTED , "5s")
开发者ID:phiros,项目名称:nepi,代码行数:33,代码来源:iminds_omf6_vlc.py

示例11: OMFEachTestCase

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
class OMFEachTestCase(unittest.TestCase):
    def setUp(self):
        self.ec = ExperimentController(exp_id = "99999")

        self.node1 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node1, 'hostname', 'wlab12')
        self.ec.set(self.node1, 'xmppUser', "nepi")
        self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
        self.ec.set(self.node1, 'xmppPort', "5222")
        self.ec.set(self.node1, 'xmppPassword', "1234")
        
        self.iface1 = self.ec.register_resource("omf::WifiInterface")
        self.ec.set(self.iface1, 'name', "wlan0")
        self.ec.set(self.iface1, 'mode', "adhoc")
        self.ec.set(self.iface1, 'hw_mode', "g")
        self.ec.set(self.iface1, 'essid', "vlcexp")
        self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
        
        self.channel = self.ec.register_resource("omf::Channel")
        self.ec.set(self.channel, 'channel', "6")
        self.ec.set(self.channel, 'xmppUser', "nepi")
        self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
        self.ec.set(self.channel, 'xmppPort', "5222")
        self.ec.set(self.channel, 'xmppPassword', "1234")
        
        self.app1 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app1, 'appid', 'Vlc#1')
        self.ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
        self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")

        self.app2 = self.ec.register_resource("omf::Application")

        self.app3 = self.ec.register_resource("omf::Application")

        self.app4 = self.ec.register_resource("omf::Application")

        self.app5 = self.ec.register_resource("omf::Application")

        self.ec.register_connection(self.app1, self.node1)
        self.ec.register_connection(self.app2, self.node1)
        self.ec.register_connection(self.app3, self.node1)
        self.ec.register_connection(self.app4, self.node1)
        self.ec.register_connection(self.app5, self.node1)
        self.ec.register_connection(self.node1, self.iface1)
        self.ec.register_connection(self.iface1, self.channel)

        self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "3s")
        self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "2s")
        self.ec.register_condition(self.app4, ResourceAction.START, self.app3, ResourceState.STARTED , "3s")
        self.ec.register_condition(self.app5, ResourceAction.START, [self.app3, self.app2], ResourceState.STARTED , "2s")
        self.ec.register_condition(self.app5, ResourceAction.START, self.app1, ResourceState.STARTED , "25s")

        self.ec.register_condition([self.app1, self.app2, self.app3,self.app4, self.app5], ResourceAction.STOP, self.app5, ResourceState.STARTED , "1s")

    def tearDown(self):
        self.ec.shutdown()

    def test_creation_and_configuration_node(self):
        self.assertEquals(self.ec.get(self.node1, 'hostname'), 'wlab12')
        self.assertEquals(self.ec.get(self.node1, 'xmppUser'), 'nepi')
        self.assertEquals(self.ec.get(self.node1, 'xmppServer'), 'xmpp-plexus.onelab.eu')
        self.assertEquals(self.ec.get(self.node1, 'xmppPort'), '5222')
        self.assertEquals(self.ec.get(self.node1, 'xmppPassword'), '1234')
        self.assertEquals(self.ec.get(self.node1, 'version'), '6')


    def test_creation_and_configuration_interface(self):
        self.assertEquals(self.ec.get(self.iface1, 'name'), 'wlan0')
        self.assertEquals(self.ec.get(self.iface1, 'mode'), 'adhoc')
        self.assertEquals(self.ec.get(self.iface1, 'hw_mode'), 'g')
        self.assertEquals(self.ec.get(self.iface1, 'essid'), 'vlcexp')
        self.assertEquals(self.ec.get(self.iface1, 'ip'), '10.0.0.17/24')
        self.assertEquals(self.ec.get(self.iface1, 'version'), '6')

    def test_creation_and_configuration_channel(self):
        self.assertEquals(self.ec.get(self.channel, 'channel'), '6')
        self.assertEquals(self.ec.get(self.channel, 'xmppUser'), 'nepi')
        self.assertEquals(self.ec.get(self.channel, 'xmppServer'), 'xmpp-plexus.onelab.eu')
        self.assertEquals(self.ec.get(self.channel, 'xmppPort'), '5222')
        self.assertEquals(self.ec.get(self.channel, 'xmppPassword'), '1234')
        self.assertEquals(self.ec.get(self.channel, 'version'), '6')


    def test_creation_and_configuration_application(self):
        self.assertEquals(self.ec.get(self.app1, 'appid'), 'Vlc#1')
        self.assertEquals(self.ec.get(self.app1, 'command'), "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
        self.assertEquals(self.ec.get(self.app1, 'env'), 'DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority')
        self.assertEquals(self.ec.get(self.app1, 'version'), '6')

    def test_connection(self):
        self.assertEquals(len(self.ec.get_resource(self.node1).connections), 6)
        self.assertEquals(len(self.ec.get_resource(self.iface1).connections), 2)
        self.assertEquals(len(self.ec.get_resource(self.channel).connections), 1)
        self.assertEquals(len(self.ec.get_resource(self.app1).connections), 1)
        self.assertEquals(len(self.ec.get_resource(self.app2).connections), 1)

    def test_condition(self):
        self.assertEquals(len(self.ec.get_resource(self.app1).conditions[ResourceAction.STOP]), 1)
        self.assertEquals(len(self.ec.get_resource(self.app2).conditions[ResourceAction.START]), 1)
        self.assertEquals(len(self.ec.get_resource(self.app3).conditions[ResourceAction.START]), 1)
#.........这里部分代码省略.........
开发者ID:phiros,项目名称:nepi,代码行数:103,代码来源:omf6_vlc_normal_case.py

示例12:

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
app4 = ec.register_resource("omf::Application")
ec.set(app4, 'appid', 'Kill#1')
ec.set(app4, 'command', "/usr/bin/killall vlc_app")
ec.set(app4, 'env', " ")
ec.set(app4, 'version', "5")

# Connection
ec.register_connection(app3, node1)
ec.register_connection(app1, node1)
ec.register_connection(node1, iface1)
ec.register_connection(iface1, channel)
ec.register_connection(iface2, channel)
ec.register_connection(node2, iface2)
ec.register_connection(app2, node2)
ec.register_connection(app4, node2)

# User Behaviour
ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "4s")
ec.register_condition([app1, app2], ResourceAction.STOP, app2, ResourceState.STARTED , "22s")
ec.register_condition([app3, app4], ResourceAction.START, app2, ResourceState.STARTED , "25s")
ec.register_condition([app3, app4], ResourceAction.STOP, app3, ResourceState.STARTED , "1s")

# Deploy
ec.deploy()

ec.wait_finished([app1, app2, app3, app4])

# Stop Experiment
ec.shutdown()
开发者ID:phiros,项目名称:nepi,代码行数:31,代码来源:nepi_omf5_nitos_vlc.py

示例13: open

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
ec.set(client, "depends", "nc")
ec.set(client, "command", command)
ec.register_connection(client, node2)

# Register a tcpdump in the server node to monitor the file transfer 
command = "tcpdump -ni eth0 -w file_transfer.pcap -s0 port 1234 2>&1"

capture = ec.register_resource("linux::Application")
ec.set(capture, "depends", "tcpdump")
ec.set(capture, "command", command)
ec.set(capture, "sudo", True)
ec.register_connection(capture, node1)

# Register conditions 1. nodes ; 2. start tcpdump capture ; 3. client listen port 1234 ;
# 4. server start sending video
ec.register_condition(server, ResourceAction.START, client, ResourceState.STARTED) 
ec.register_condition(client, ResourceAction.START, capture, ResourceState.STARTED)

# Deploy
ec.deploy()

# Wait until the applications are finish to retrive the traces
ec.wait_finished([server, client])

# Retrieve traces from nc and tcpdump
bw = ec.trace(server, "bw.txt")
pcap = ec.trace(capture, "file_transfer.pcap")

# Choose a directory to store the traces, example f = open("/home/<user>/bw.txt", "w")
f = open("bw.txt", "w")
f.write(bw)
开发者ID:phiros,项目名称:nepi,代码行数:33,代码来源:netcat_file_transfer.py

示例14: add_app

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
            perfclient1 = add_app(ec, nodes[all_hosts[i]],  "#perfclient1", cmd, 
                            env, xmpp_slice, xmpp_host)
            iperfclient[all_hosts[i]].append(perfclient1)

        if i < (len(all_hosts)-1):
            cmd = "iperf -c " + all_ip[i+1] + " > /opt/iperclient2.txt"
            perfclient2 = add_app(ec, nodes[all_hosts[i]],  "#perfclient2", cmd, 
                            env, xmpp_slice, xmpp_host)
            iperfclient[all_hosts[i]].append(perfclient2)

        iperfserv[all_hosts[i]] = perfserv

    for i in xrange(len(all_hosts)):
         #ec.register_condition(iperfserv[all_hosts[i]], ResourceAction.START, link, ResourceState.STARTED, "2s")
         for elt in iperfclient[all_hosts[i]]:
             ec.register_condition(elt, ResourceAction.START, iperfserv[all_hosts[i]], ResourceState.STARTED, "3s")


## Streaming Server
#    pub = add_publish(ec, nodes[host5], movie, xmpp_slice, xmpp_host)

## Streaming client
#    stream = add_stream(ec, nodes[host6], xmpp_slice, xmpp_host)

## Streaming conditions
#    ec.register_condition(pub, ResourceAction.START, link, ResourceState.STARTED, "2s")
#    ec.register_condition(stream, ResourceAction.START, link, ResourceState.STARTED, "2s")
#    ec.register_condition(stream, ResourceAction.START, pub, ResourceState.STARTED, "2s")


开发者ID:phiros,项目名称:nepi,代码行数:30,代码来源:nepi_omf5_plexus_ccncat_linear.py

示例15: test_deploy

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_condition [as 别名]
    def test_deploy(self):
        ec = ExperimentController(exp_id = "5421" )

        self.node1 = ec.register_resource("omf::Node")
        ec.set(self.node1, 'hostname', 'wlab12')
        ec.set(self.node1, 'xmppUser', "nepi")
        ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
        ec.set(self.node1, 'xmppPort', "5222")
        ec.set(self.node1, 'xmppPassword', "1234")
        
        self.iface1 = ec.register_resource("omf::WifiInterface")
        ec.set(self.iface1, 'name', "wlan0")
        ec.set(self.iface1, 'mode', "adhoc")
        ec.set(self.iface1, 'hw_mode', "g")
        ec.set(self.iface1, 'essid', "vlcexp")
        ec.set(self.iface1, 'ip', "10.0.0.17/24")
        
        self.channel = ec.register_resource("omf::Channel")
        ec.set(self.channel, 'channel', "6")
        ec.set(self.channel, 'xmppUser', "nepi")
        ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
        ec.set(self.channel, 'xmppPort', "5222")
        ec.set(self.channel, 'xmppPassword', "1234")
        
        self.app1 = ec.register_resource("omf::Application")
        ec.set(self.app1, 'appid', 'Vlc#1')
        ec.set(self.app1, 'command', "ping -c5 10.0.0.17")

        ec.register_connection(self.app1, self.node1)
        ec.register_connection(self.node1, self.iface1)
        ec.register_connection(self.iface1, self.channel)

        ec.register_condition(self.app1, ResourceAction.STOP, self.app1, ResourceState.STARTED , "10s")

        ec.deploy()

        ec.wait_finished(self.app1)

        stdout_1 = ec.trace(self.app1, "stdout")
        stderr_1 = ec.trace(self.app1, "stderr")

        if stdout_1:
            f = open("app1_out.txt", "w")
            f.write(stdout_1)
            f.close()

        if stderr_1:
            f = open("app1_err.txt", "w")
            f.write(stderr_1)
            f.close()

        self.assertEquals(ec.get_resource(self.node1).state, ResourceState.STARTED)
        self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.STARTED)
        self.assertEquals(ec.get_resource(self.channel).state, ResourceState.STARTED)
        self.assertEquals(ec.get_resource(self.app1).state, ResourceState.STOPPED)

        ec.shutdown()

        self.assertEquals(ec.get_resource(self.node1).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.channel).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.app1).state, ResourceState.RELEASED)

        t = open("app1_out.txt", "r")
        l = t.readlines()
        self.assertEquals(l[0], "PING 10.0.0.17 (10.0.0.17) 56(84) bytes of data.\n")
        self.assertIn("5 packets transmitted, 5 received, 0% packet loss, time", l[-2])
        self.assertIn("rtt min/avg/max/mdev = ", l[-1])
        
        t.close()
        os.remove("app1_out.txt")
开发者ID:phiros,项目名称:nepi,代码行数:73,代码来源:omf6_vlc_traces.py


注:本文中的nepi.execution.ec.ExperimentController.register_condition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。