• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ec.ExperimentController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

    def setUp(self):
        self.ec = ExperimentController(exp_id = str(OMFVLCWrongCaseAllCritical.id))
        OMFVLCWrongCaseAllCritical.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', '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.49,port=1234,mux=ts}'")
        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)
开发者ID:phiros,项目名称:nepi,代码行数:25,代码来源:omf6_vlc_wrong_critical.py


示例2: setUp

    def setUp(self):
        self.ec = ExperimentController(exp_id = "99999")

        self.node1 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
        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.ec.set(self.node1, 'version', "5")
        
        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.ec.set(self.iface1, 'version', "5")
        
        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.ec.set(self.channel, 'version', "5")
        
        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.ec.set(self.app1, 'version', "5")

        self.app2 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app2, 'version', "5")

        self.app3 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app3, 'version', "5")

        self.app4 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app4, 'version', "5")

        self.app5 = self.ec.register_resource("omf::Application")
        self.ec.set(self.app5, 'version', "5")

        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")
开发者ID:phiros,项目名称:nepi,代码行数:60,代码来源:omf5_vlc_normal_case.py


示例3: setUp

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

        self.node1 = self.ec.register_resource("omf::Node")
        self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
        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.ec.set(self.node1, 'version', "5")
        
        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.ec.set(self.iface1, 'version', "5")

        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.set(self.app1, 'version', "5")

        self.ec.register_connection(self.app1, self.node1)
        self.ec.register_connection(self.node1, self.iface1)
开发者ID:phiros,项目名称:nepi,代码行数:28,代码来源:omf5_vlc_wrong_non_critical.py


示例4: test_schedule_print

    def test_schedule_print(self):
        def myfunc():
            return 'hola!' 

        ec = ExperimentController()
    
        tid = ec.schedule("0s", myfunc, track=True)
        
        while True:
            task = ec.get_task(tid)
            if task.status != TaskStatus.NEW:
                break

            time.sleep(1)

        self.assertEquals('hola!', task.result)

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


示例5: _ec_from_xml

    def _ec_from_xml(self, doc):
        from nepi.execution.ec import ExperimentController
        ec = None
        
        ecnode_list = doc.getElementsByTagName("experiment")
        for ecnode in ecnode_list:
            if ecnode.nodeType == doc.ELEMENT_NODE:
                exp_id = xmldecode(ecnode.getAttribute("exp_id"))
                run_id = xmldecode(ecnode.getAttribute("run_id"))
                local_dir = xmldecode(ecnode.getAttribute("local_dir"))

                # Configure number of preocessing threads
                nthreads = xmldecode(ecnode.getAttribute("nthreads"))
                os.environ["NEPI_NTHREADS"] = nthreads

                # Deserialize netgraph
                topology = None
                topo_type = None

                netgraph = self._netgraph_from_xml(doc, ecnode)
                
                if netgraph:
                    topo_type = netgraph.topo_type
                    topology = netgraph.topology

                # Instantiate EC
                ec = ExperimentController(exp_id = exp_id, local_dir = local_dir, 
                        topology = topology, topo_type = topo_type)

                connections = set()

                rmsnode_list = ecnode.getElementsByTagName("rms")
                if rmsnode_list:
                    rmnode_list = rmsnode_list[0].getElementsByTagName("rm") 
                    for rmnode in rmnode_list:
                        if rmnode.nodeType == doc.ELEMENT_NODE:
                            self._rm_from_xml(doc, rmnode, ec, connections)

                for (guid1, guid2) in connections:
                    ec.register_connection(guid1, guid2)

                break

        return ec
开发者ID:phiros,项目名称:nepi,代码行数:44,代码来源:xml_parser.py


示例6: test_schedule_exception

    def test_schedule_exception(self):
        def raise_error():
            # When this task is executed and the error raise,
            # the FailureManager should set its failure level to 
            # TASK_FAILURE
            raise RuntimeError, "NOT A REAL ERROR. JUST TESTING!"

        ec = ExperimentController()

        tid = ec.schedule("2s", raise_error, track = True)
        
        while True:
            task = ec.get_task(tid)
            if task.status != TaskStatus.NEW:
                break

            time.sleep(1)

        self.assertEquals(task.status, TaskStatus.ERROR)
开发者ID:phiros,项目名称:nepi,代码行数:19,代码来源:ec.py


示例7: test_schedule_date

    def test_schedule_date(self):
        def get_time():
            return datetime.datetime.now() 

        ec = ExperimentController()

        schedule_time = datetime.datetime.now()
        
        tid = ec.schedule("4s", get_time, track=True)

        while True:
            task = ec.get_task(tid)
            if task.status != TaskStatus.NEW:
                break

            time.sleep(1)

        execution_time = task.result
        delta = execution_time - schedule_time
        self.assertTrue(delta > datetime.timedelta(seconds=4))
        self.assertTrue(delta < datetime.timedelta(seconds=5))

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


示例8: run_experiment

    def run_experiment(self, filepath, wait_time, wait_guids):
        """ Run an experiment based on the description stored
        in filepath.

        """
        ec = ExperimentController.load(filepath)

        ec.deploy()
    
        ec.wait_finished(wait_guids)
        time.sleep(wait_time)

        ec.release()

        if ec.state == ECState.FAILED:
            raise RuntimeError, "Experiment failed"

        return ec
开发者ID:phiros,项目名称:nepi,代码行数:18,代码来源:runner.py


示例9: ExperimentController

	if source:
		ec.set(app,"sources",source)

	ec.set(app,"command",command)
	return app

#Argentina is missing ,"Argentina":"planet-lab2.itba.edu.ar"
#Host where the ground stations will be allocated

hosts ={"Argentina":"planetlab1.pop-rs.rnp.br","China":"planetlab1.buaa.edu.cn","Spain":"planetlab2.dit.upm.es","Norway":"planetlab1.cs.uit.no","New Zealand":"planetlab1.cs.otago.ac.nz","Florida":"planetlab1.csee.usf.edu","Israel":"planetlab2.mta.ac.il","Brazil":"planetlab1.pop-pa.rnp.br","Reunion Island":"lim-planetlab-1.univ-reunion.fr","Malaysia":"planetlab1.comp.nus.edu.sg","Canada":"planetlab-2.usask.ca","Australia":"pl1.eng.monash.edu.au"}
#hosts ={"Argentina":"planetlab1.pop-rs.rnp.br","China":"planetlab1.buaa.edu.cn","Spain":"planetlab2.dit.upm.es","Norway":"planetlab1.cs.uit.no","New Zealand":"planetlab1.cs.otago.ac.nz","Florida":"planetlab1.csee.usf.edu","Israel":"planetlab2.mta.ac.il","Brazil":"planetlab1.pop-pa.rnp.br","Malaysia":"planetlab1.comp.nus.edu.sg","Canada":"planetlab-2.usask.ca","Australia":"pl1.eng.monash.edu.au"}
#hosts={"New Zealand":"planetlab1.cs.otago.ac.nz"}
#Host where the BonFIRE cloud will be
bonfire_host = ("France","ple6.ipv6.lip6.fr")

ec = ExperimentController("test_ple")

# The username in this case is the slice name, the one to use for login in
# via ssh into PlanetLab nodes. Replace with your own slice name.

slice = "ibbtple_geocloud"
pleuser= os.environ["PL_USER"]
plepass= os.environ["PL_PASS"]
ssh_key = "~/.ssh/id_rsa"
#source_file = "/home/deimos/GeoCloudResources/E2E_0Gerardo.bin" #file that client will send
target_file = "data.txt"
port = 20004
seconds = 43200
seconds = 3600 #1 h
nodes = []
apps = []
开发者ID:ruben11291,项目名称:master-thesis,代码行数:31,代码来源:pPLE.py


示例10: ExperimentController

            "(e.g. hostname must be of form: node0ZZ)", 
        type="str")
parser.add_option("-c", "--channel", dest="channel", 
        help="Nitos reserved channel",
        type="str")
parser.add_option("-s", "--slice-name", dest="slicename", 
        help="Nitos slice name", type="str")
(options, args) = parser.parse_args()

nodex = options.nodex
nodez = options.nodez
slicename = options.slicename
chan = options.channel

# Create the EC
ec = ExperimentController(exp_id="nitos_omf6_ping")

# Create and Configure the Nodes
node1 = ec.register_resource("omf::Node")
ec.set(node1, "hostname", nodex)
ec.set(node1, "xmppUser", slicename)
ec.set(node1, "xmppServer", "nitlab.inf.uth.gr")
ec.set(node1, "xmppPort", "5222")
ec.set(node1, "xmppPassword", "1234")

# Create and Configure the Interfaces
iface1 = ec.register_resource("omf::WifiInterface")
ec.set(iface1, "name", "wlan0")
ec.set(iface1, "mode", "adhoc")
ec.set(iface1, "hw_mode", "g")
ec.set(iface1, "essid", "ping")
开发者ID:phiros,项目名称:nepi,代码行数:31,代码来源:nitos_omf6_ping.py


示例11: t_tap_create

    def t_tap_create(self, host, user=None, identity=None):

        ec = ExperimentController(exp_id="test-tap-create")
        
        node = ec.register_resource("linux::Node")
        ec.set(node, "hostname", host)

        if host != "localhost":
            ec.set(node, "username", user)
            ec.set(node, "identity", identity)

        ec.set(node, "cleanExperiment", True)
        ec.set(node, "cleanProcesses", True)

        tap = ec.register_resource("linux::Tap")
        ec.set(tap, "ip", "%s.1" % self.netblock)
        ec.set(tap, "prefix", "24")
        ec.register_connection(tap, node)

        app = ec.register_resource("linux::Application")
        cmd = "ping -c3 %s.1" % self.netblock
        ec.set(app, "command", cmd)
        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished(app)

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

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


示例12: str

    app = ec.register_resource("linux::Application")
    ec.set(app, "command", command)
    ec.register_connection(app, node)
    return app

############## Experiment design and execution ################################

platform = "planetlab"

# Set the number of threads. 
# NOTE: This must be done before instantiating the EC.
os.environ["NEPI_NTHREADS"] = str(thread_count)

# Create Experiment Controller:
exp_id = "%s_bench" % platform
ec = ExperimentController(exp_id)

# Authentication for MyPLC
username = 'inria_sfatest'
pl_user = os.environ.get("PL_USER")
pl_password = os.environ.get("PL_PASS")

# App to run on each node
command = "ping -c5 nepi.inria.fr"

# Add simulated nodes and applications
nodes = list()
apps = list()

for i in xrange(node_count):
    node = create_node(ec, username, pl_user, pl_password)
开发者ID:phiros,项目名称:nepi,代码行数:31,代码来源:planetlab.py


示例13: test_serialize

    def test_serialize(self):
        node_count = 4
        app_count = 2

        ec = ExperimentController(exp_id = "plotter-test")
       
        # Add simulated nodes and applications
        nodes = list()
        apps = list()
        ifaces = list()

        for i in xrange(node_count):
            node = ec.register_resource("dummy::Node")
            nodes.append(node)
            
            iface = ec.register_resource("dummy::Interface")
            ec.register_connection(node, iface)
            ifaces.append(iface)

            for i in xrange(app_count):
                app = ec.register_resource("dummy::Application")
                ec.register_connection(node, app)
                apps.append(app)

        link = ec.register_resource("dummy::Link")

        for iface in ifaces:
            ec.register_connection(link, iface)
       
        fpath = ec.plot()
        statinfo = os.stat(fpath)
        size = statinfo.st_size
        self.assertTrue(size > 0)
        self.assertTrue(fpath.endswith(".png"))

        os.remove(fpath)

        fpath = ec.plot(format = PFormats.DOT)
        statinfo = os.stat(fpath)
        size = statinfo.st_size
        self.assertTrue(size > 0)
        self.assertTrue(fpath.endswith(".dot"))

        os.remove(fpath)
开发者ID:phiros,项目名称:nepi,代码行数:44,代码来源:plotter.py


示例14: t_dce_ccnpeek

    def t_dce_ccnpeek(self, host, user = None, identity = None):
        ec = ExperimentController(exp_id = "test-dce-ccnpeek")

        node = ec.register_resource("linux::Node")
        if host == "localhost":
            ec.set(node, "hostname", host)
        else:
            ec.set(node, "hostname", host)
            ec.set(node, "username", user)
            ec.set(node, "identity", identity)
        
        ec.set(node, "cleanProcesses", True)
        #ec.set(node, "cleanHome", True)

        simu = ec.register_resource("linux::ns3::Simulation")
        ec.set(simu, "verbose", True)
        ec.set(simu, "nsLog", "DceApplication")
        ec.register_connection(simu, node)

        nsnode = add_ns3_node(ec, simu)

        ### create applications
        ccnd = ec.register_resource("linux::ns3::dce::CCND")
        ec.set (ccnd, "stackSize", 1<<20)
        ec.set (ccnd, "StartTime", "1s")
        ec.register_connection(ccnd, nsnode)

        ccnpoke = ec.register_resource("linux::ns3::dce::CCNPoke")
        ec.set (ccnpoke, "contentName", "ccnx:/chunk0")
        ec.set (ccnpoke, "content", "DATA")
        ec.set (ccnpoke, "stackSize", 1<<20)
        ec.set (ccnpoke, "StartTime", "2s")
        ec.register_connection(ccnpoke, nsnode)

        ccnpeek = ec.register_resource("linux::ns3::dce::CCNPeek")
        ec.set (ccnpeek, "contentName", "ccnx:/chunk0")
        ec.set (ccnpeek, "stackSize", 1<<20)
        ec.set (ccnpeek, "StartTime", "4s")
        ec.set (ccnpeek, "StopTime", "20s")
        ec.register_connection(ccnpeek, nsnode)

        ec.deploy()

        ec.wait_finished([ccnpeek])

        expected = "ccnpeek ccnx:/chunk0"
        cmdline = ec.trace(ccnpeek, "cmdline")
        self.assertTrue(cmdline.find(expected) > -1, cmdline)

        expected = "Start Time: NS3 Time:          4s ("
        status = ec.trace(ccnpeek, "status")
        self.assertTrue(status.find(expected) > -1, status)

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

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


示例15: add_ccncat

    ec.set(app, "command", command)

    return app

def add_ccncat(ec, content_name):
    env = "PATH=$PATH:${BIN}/ccnx-0.8.2/bin"
    command = "ccncat %s" % content_name

    app = ec.register_resource("linux::Application")
    ec.set(app, "env", env)
    ec.set(app, "command", command)

    return app

## Create the experiment controller
ec = ExperimentController(exp_id = "ccn_advanced_transfer")

# Register first PlanetLab host
node1 = add_node(ec, hostname1, username, ssh_key)

# Register CCN setup for host
peers = [hostname2]
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")
开发者ID:phiros,项目名称:nepi,代码行数:30,代码来源:ccn_transfer_using_linuxapp.py


示例16: test_deploy

    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', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
        ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")

        self.app2 = ec.register_resource("omf::Application")
        ec.set(self.app2, 'appid', 'Test#1')
        ec.set(self.app2, 'command', "/usr/bin/test -1")
        ec.set(self.app2, 'env', " ")

        self.app3 = ec.register_resource("omf::Application")
        ec.set(self.app3, 'appid', 'Test#2')
        ec.set(self.app3, 'command', "/usr/bin/test -2")
        ec.set(self.app3, 'env', " ")

        self.app4 = ec.register_resource("omf::Application")
        ec.set(self.app4, 'appid', 'Test#3')
        ec.set(self.app4, 'command', "/usr/bin/test -3")
        ec.set(self.app4, 'env', " ")

        self.app5 = ec.register_resource("omf::Application")
        ec.set(self.app5, 'appid', 'Kill#2')
        ec.set(self.app5, 'command', "/usr/bin/killall vlc")
        ec.set(self.app5, 'env', " ")

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

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

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

        ec.deploy()

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

        self.assertGreaterEqual(round(tdiffsec(ec.get_resource(self.app2).start_time, ec.get_resource(self.app1).start_time),0), 3.0)
        self.assertGreaterEqual(round(tdiffsec(ec.get_resource(self.app3).start_time, ec.get_resource(self.app2).start_time),0), 2.0)
        self.assertGreaterEqual(round(tdiffsec(ec.get_resource(self.app4).start_time, ec.get_resource(self.app3).start_time),0), 3.0)
        self.assertGreaterEqual(round(tdiffsec(ec.get_resource(self.app5).start_time, ec.get_resource(self.app3).start_time),0), 2.0)
        self.assertGreaterEqual(round(tdiffsec(ec.get_resource(self.app5).start_time, ec.get_resource(self.app1).start_time),0), 25.0)

        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)
        self.assertEquals(ec.get_resource(self.app2).state, ResourceState.STOPPED)
        self.assertEquals(ec.get_resource(self.app3).state, ResourceState.STOPPED)
        self.assertEquals(ec.get_resource(self.app4).state, ResourceState.STOPPED)
        self.assertEquals(ec.get_resource(self.app5).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)
        self.assertEquals(ec.get_resource(self.app2).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.app3).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.app4).state, ResourceState.RELEASED)
        self.assertEquals(ec.get_resource(self.app5).state, ResourceState.RELEASED)
开发者ID:phiros,项目名称:nepi,代码行数:94,代码来源:omf6_vlc_normal_case.py


示例17: OMFEachTestCase

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,代码行数:101,代码来源:omf6_vlc_normal_case.py


示例18: OptionParser

parser = OptionParser(usage = usage)
parser.add_option("-a", "--hostname", dest="hostname", 
        help="Remote host", type="str")
parser.add_option("-u", "--username", dest="username", 
        help="Username to SSH to remote host", type="str")
parser.add_option("-i", "--ssh-key", dest="ssh_key", 
        help="Path to private SSH key to be used for connection", 
        type="str")
(options, args) = parser.parse_args()

hostname = options.hostname
username = options.username
ssh_key = options.ssh_key

ec = ExperimentController(exp_id = "ping-exp")
        
node = ec.register_resource("linux::Node")
ec.set(node, "hostname", hostname)
ec.set(node, "username", username)
ec.set(node, "identity", ssh_key)
ec.set(node, "cleanExperiment", True)
ec.set(node, "cleanProcesses", True)

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

ec.deploy()

ec.wait_finished(app)
开发者ID:phiros,项目名称:nepi,代码行数:30,代码来源:ping.py


示例19: t_dce_ccn

    def t_dce_ccn(self, host, user = None, identity = None):
        ec = ExperimentController(exp_id = "test-dce-ccn-app")

        node = ec.register_resource("linux::Node")
        if host == "localhost":
            ec.set(node, "hostname", host)
        else:
            ec.set(node, "hostname", host)
            ec.set(node, "username", user)
            ec.set(node, "identity", identity)
        
        ec.set(node, "cleanProcesses", True)
        #ec.set(node, "cleanHome", True)

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

        nsnode1 = add_ns3_node(ec, simu)
        p2p1 = add_point2point_device(ec, nsnode1, "10.0.0.1", "30")
        ec.set(p2p1, "DataRate", "5Mbps")

        nsnode2 = add_ns3_node(ec, simu)
        p2p2 = add_point2point_device(ec, nsnode2, "10.0.0.2", "30")
        ec.set(p2p2, "DataRate", "5Mbps")

        # Create channel
        chan = ec.register_resource("ns3::PointToPointChannel")
        ec.set(chan, "Delay", "2ms")

        ec.register_connection(chan, p2p1)
        ec.register_connection(chan, p2p2)

        ### create applications
        ccnd1 = ec.register_resource("linux::ns3::dce::CCND")
        ec.set (ccnd1, "stackSize", 1<<20)
        ec.set (ccnd1, "debug", 7)
        ec.set (ccnd1, "capacity", 50000)
        ec.set (ccnd1, "StartTime", "1s")
        ec.set (ccnd1, "StopTime", "20s")
        ec.register_connection(ccnd1, nsnode1)

        repofile = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            "repoFile1")

        ccnr = ec.register_resource("linux::ns3::dce::CCNR")
        ec.set (ccnr, "repoFile1", repofile) 
        ec.set (ccnr, "stackSize", 1<<20)
        ec.set (ccnr, "StartTime", "2s")
        ec.set (ccnr, "StopTime", "120s")
        ec.register_connection(ccnr, nsnode1)

        ccndc1 = ec.register_resource("linux::ns3::dce::FIBEntry")
        ec.set (ccndc1, "protocol", "udp") 
        ec.set (ccndc1, "uri", "ccnx:/") 
        ec.set (ccndc1, "host", "10.0.0.2") 
        ec.set (ccndc1, "stackSize", 1<<20)
        ec.set (ccndc1, "StartTime", "2s")
        ec.set (ccndc1, "StopTime", "120s")
        ec.register_connection(ccndc1, nsnode1)

        ccnd2 = ec.register_resource("linux::ns3::dce::CCND")
        ec.set (ccnd2, "stackSize", 1<<20)
        ec.set (ccnd2, "debug", 7)
        ec.set (ccnd2, "capacity", 50000)
        ec.set (ccnd2, "StartTime", "1s")
        ec.set (ccnd2, "StopTime", "20s")
        ec.register_connection(ccnd2, nsnode2)

        ccndc2 = ec.register_resource("linux::ns3::dce::FIBEntry")
        ec.set (ccndc2, "protocol", "udp") 
        ec.set (ccndc2, "uri", "ccnx:/") 
        ec.set (ccndc2, "host", "10.0.0.1") 
        ec.set (ccndc2, "stackSize", 1<<20)
        ec.set (ccndc2, "StartTime", "2s")
        ec.set (ccndc2, "StopTime", "120s")
        ec.register_connection(ccndc2, nsnode2)

        ccnpeek = ec.register_resource("linux::ns3::dce::CCNPeek")
        e 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nereid.abort函数代码示例发布时间:2022-05-27
下一篇:
Python neovim.attach函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap