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


Python ExperimentController.register_connection方法代码示例

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


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

示例1: t_nping

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

        ec = ExperimentController(exp_id = "test-nping")
        
        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)

        app = ec.register_resource("linux::NPing")
        ec.set(app, "c", 1)
        ec.set(app, "tcp", True)
        ec.set(app, "p", 80)
        ec.set(app, "target", self.target)
        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished(app)

        stdout = ec.trace(app, "stdout")
        self.assertTrue(stdout.find("1 IP address pinged in") > -1)

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

示例2: t_stdout

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

        ec = ExperimentController(exp_id = "test-stdout")
        
        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)

        app = ec.register_resource("linux::Application")
        cmd = "echo 'HOLA'"
        ec.set(app, "command", cmd)
        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished(app)

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

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

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

示例3: test_concurrency

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

        ec = ExperimentController()

        node = ec.register_resource("Node")

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

        ec.deploy()

        ec.wait_finished(apps)
        
        self.assertTrue(ec.state(node) == ResourceState.STARTED)
        self.assertTrue(
               all([ec.state(guid) == ResourceState.STOPPED \
                for guid in apps])
                )

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

示例4: t_tofile

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_tofile(self, host, user):
        ec = ExperimentController(exp_id = "test-to-file")
        
        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)

        pcap = ec.register_resource("linux::Tcpdump")
        ec.set(pcap, "i", "eth0")
        ec.set(pcap, "w", "custom_output")
        ec.register_connection(pcap, node)

        app = ec.register_resource("linux::Ping")
        ec.set(app, "count", "20")
        ec.set(app, "target", self.target)
        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished(app)

        output = ec.trace(pcap, "custom_output")
        self.assertTrue(len(output) > 0)

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

示例5: t_rtt

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_rtt(self, user1, host1, user2, host2):

        ec = ExperimentController(exp_id = "test-udptest-rtt")
        
        node1 = ec.register_resource("linux::Node")
        ec.set(node1, "hostname", host1)
        ec.set(node1, "username", user1)
        ec.set(node1, "cleanExperiment", True)
        ec.set(node1, "cleanProcesses", True)

        server = ec.register_resource("linux::UdpTest")
        ec.set(server, "s", True)
        ec.register_connection(server, node1)
 
        node2 = ec.register_resource("linux::Node")
        ec.set(node2, "hostname", host2)
        ec.set(node2, "username", user2)
        ec.set(node2, "cleanExperiment", True)
        ec.set(node2, "cleanProcesses", True)

        client = ec.register_resource("linux::UdpTest")
        ec.set(client, "a", True)
        ec.set(client, "target", host1)
        ec.register_connection(client, node2)

        ec.deploy()

        ec.wait_finished(client)

        stdout = ec.trace(client, "stderr")
        self.assertTrue(stdout.find("10 trials with message size 64 Bytes.") > -1)

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

示例6: test_stop_with_condition

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [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

示例7: t_tun_create

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

        ec = ExperimentController(exp_id="test-un-create")
        
        node = ec.register_resource("planetlab::Node")
        ec.set(node, "hostname", host)
        ec.set(node, "username", user)
        ec.set(node, "identity", identity)
        ec.set(node, "cleanExperiment", True)
        ec.set(node, "cleanProcesses", True)

        tun = ec.register_resource("planetlab::Tun")
        ec.set(tun, "ip", "%s.1" % self.netblock)
        ec.set(tun, "prefix", "24")
        ec.register_connection(tun, 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(tun, "deviceName")
        self.assertTrue(if_name.startswith("tun"))

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

示例8: t_deploy

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_deploy(self, host, user):
        from nepi.execution.resource import ResourceFactory
        
        ResourceFactory.register_type(LinuxNode)
        ResourceFactory.register_type(LinuxInterface)
        ResourceFactory.register_type(LinuxChannel)

        ec = ExperimentController()
        
        node = ec.register_resource("linux::Node")
        ec.set(node, "hostname", host)
        ec.set(node, "username", user)

        iface = ec.register_resource("linux::Interface")
        chan = ec.register_resource("linux::Channel")

        ec.register_connection(iface, node)
        ec.register_connection(iface, chan)

        ec.deploy()

        while not all([ ec.state(guid) == ResourceState.STARTED \
                for guid in [node, iface]]):
            time.sleep(0.5)

        self.assertTrue(ec.state(node) == ResourceState.STARTED)
        self.assertTrue(ec.state(iface) == ResourceState.STARTED)
        self.assertTrue(ec.get(iface, "deviceName") == "eth0")

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

示例9: t_dce_ccnpeek_with_stack

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_dce_ccnpeek_with_stack(self, host, user = None, identity = None):
        ec = ExperimentController(exp_id = "test-dce-peek-lostack")
        
        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.register_connection(simu, node)

        nsnode = ec.register_resource("ns3::Node")
        ec.set(nsnode, "enableStack", True)
        ec.register_connection(nsnode, 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,代码行数:61,代码来源:ns3dceccnpeek.py

示例10: make_experiment

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
def make_experiment(node_count, app_count, opdelay, delay):

    ResourceManager._reschedule_delay = "%0.1fs" % delay

    # Create Experiment Controller:
    ec = ExperimentController("dce_bench")

    # Add the physical host in which to run the simulation
    lnode = add_linux_node(ec)

    # Add a simulation resource
    simu = ec.register_resource("linux::ns3::Simulation")
    ec.set(simu, "verbose", True)
    ec.register_connection(simu, lnode)

    # Add simulated nodes and applications
    nodes = list()
    apps = list()
    devs = list()
    ips = dict()

    prefix = "16"
    base_addr = "10.0.0.0/%s" % prefix
    net = ipaddr.IPv4Network(base_addr)
    host_itr = net.iterhosts()

    for i in xrange(node_count):
        node = add_node(ec, simu)
        nodes.append(node)
        
        ip = host_itr.next()
        ip = ip.exploded
        dev = add_device(ec, node, ip, prefix)
        devs.append(dev)

        ips[node] = ip

    for nid in nodes:
        for j in xrange(app_count):
            # If there is only one node, ping itself. If there are more
            # choose one target randomly.
            remote_ip = ips[nid]
            
            if len(nodes) > 1:
                choices = ips.values()
                choices.remove(remote_ip)
                remote_ip = random.choice(choices)

            app = add_ping_app(ec, node, remote_ip)
            apps.append(app)

    chan = ec.register_resource("ns3::CsmaChannel")
    ec.set(chan, "Delay", "0s")

    for dev in devs:
        ec.register_connection(chan, dev)

    return (ec, apps, nodes + apps + devs)
开发者ID:phiros,项目名称:nepi,代码行数:60,代码来源:dce.py

示例11: t_simple_multirun

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

        dirpath = tempfile.mkdtemp()

        ec = ExperimentController(exp_id = "test-condition-multirun", 
                local_dir = dirpath)
        
        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)

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

        collector = ec.register_resource("Collector")
        ec.set(collector, "traceName", "stdout")
        ec.register_connection(ping, collector)

        def compute_metric_callback(ping, ec, run):
            stdout = ec.trace(ping, "stdout")

            m = _ping_re.match(stdout)
            if not m:
                return None
            
            return float(m.groupdict()["min"])

        metric_callback = functools.partial(compute_metric_callback, ping)

        rnr = ExperimentRunner()
        runs = rnr.run(ec, min_runs = 5, 
                compute_metric_callback = metric_callback,
                wait_guids = [ping],
                wait_time = 0)

        self.assertTrue(runs >= 5)

        dircount = 0

        for d in os.listdir(ec.exp_dir):
            path = os.path.join(ec.exp_dir, d)
            if os.path.isdir(path):
                dircount += 1
                logs = glob.glob(os.path.join(path, "*.stdout"))
                self.assertEquals(len(logs), 1)
        
        self.assertEquals(runs, dircount)

        shutil.rmtree(dirpath)
开发者ID:phiros,项目名称:nepi,代码行数:54,代码来源:multirun.py

示例12: t_tun_hybrid_gre_tunnel

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_tun_hybrid_gre_tunnel(self, user1, host1, identity1, 
            user2, host2, identity2):

        ec = ExperimentController(exp_id="test-tap-hybrid-gre-tunnel")
        
        node1 = ec.register_resource("planetlab::Node")
        ec.set(node1, "hostname", host1)
        ec.set(node1, "username", user1)
        ec.set(node1, "identity", identity1)
        ec.set(node1, "cleanExperiment", True)
        ec.set(node1, "cleanProcesses", True)

        tun1 = ec.register_resource("planetlab::Tun")
        ec.set(tun1, "ip", "%s.1" % self.netblock)
        ec.set(tun1, "prefix", "24")
        ec.register_connection(tun1, node1)

        node2 = ec.register_resource("linux::Node")
        ec.set(node2, "hostname", host2)
        ec.set(node2, "username", user2)
        ec.set(node2, "identity", identity2)
        ec.set(node2, "cleanExperiment", True)
        ec.set(node2, "cleanProcesses", True)

        tun2 = ec.register_resource("linux::Tun")
        ec.set(tun2, "ip", "%s.2" % self.netblock)
        ec.set(tun2, "prefix", "24")
        ec.register_connection(tun2, node2)

        gretun = ec.register_resource("linux::GRETunnel")
        ec.register_connection(tun1, gretun)
        ec.register_connection(tun2, gretun)

        app = ec.register_resource("linux::Application")
        # It seems the hybrid tunnel takes some time to setup... we add a sleep 5
        # XXX: Debug this to see if it can be fixed on the RMs
        cmd = "sleep 5; ping -c3 %s.2" % self.netblock
        ec.set(app, "command", cmd)
        ec.register_connection(app, node1)

        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(tun1, "deviceName")
        self.assertTrue(if_name.startswith("tun"))
        
        if_name = ec.get(tun2, "deviceName")
        self.assertTrue(if_name.startswith("tun"))

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

示例13: _ec_from_xml

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    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,代码行数:46,代码来源:xml_parser.py

示例14: t_tap_udp_tunnel

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import register_connection [as 别名]
    def t_tap_udp_tunnel(self, user1, host1, identity1, user2, host2, 
            identity2):

        ec = ExperimentController(exp_id="test-tap-udp-tunnel")
        
        node1 = ec.register_resource("linux::Node")
        ec.set(node1, "hostname", host1)
        ec.set(node1, "username", user1)
        ec.set(node1, "identity", identity1)
        ec.set(node1, "cleanExperiment", True)
        ec.set(node1, "cleanProcesses", True)

        tap1 = ec.register_resource("linux::Tap")
        ec.set(tap1, "ip", "%s.1" % self.netblock)
        ec.set(tap1, "prefix", "32")
        ec.register_connection(tap1, node1)

        node2 = ec.register_resource("linux::Node")
        ec.set(node2, "hostname", host2)
        ec.set(node2, "username", user2)
        ec.set(node2, "identity", identity2)
        ec.set(node2, "cleanExperiment", True)
        ec.set(node2, "cleanProcesses", True)

        tap2 = ec.register_resource("linux::Tap")
        ec.set(tap2, "ip", "%s.2" % self.netblock)
        ec.set(tap2, "prefix", "32")
        ec.register_connection(tap2, node2)

        udptun = ec.register_resource("linux::UdpTunnel")
        ec.register_connection(tap1, udptun)
        ec.register_connection(tap2, udptun)

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

        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)
        
        vif_name = ec.get(tap1, "deviceName")
        self.assertTrue(vif_name.startswith("tap"))
        
        vif_name = ec.get(tap2, "deviceName")
        self.assertTrue(vif_name.startswith("tap"))

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

示例15: t_concurrency

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

        ec = ExperimentController(exp_id="test-concurrency")
        
        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)

        apps = list()
        for i in xrange(50):
            app = ec.register_resource("linux::Application")
            cmd = "ping -c5 %s" % self.target 
            ec.set(app, "command", cmd)
            ec.register_connection(app, node)
            apps.append(app)

        ec.deploy()

        ec.wait_finished(apps)

        self.assertTrue(ec.state(node) == ResourceState.STARTED)
        self.assertTrue(
               all([ec.state(guid) == ResourceState.STOPPED \
                for guid in apps])
                )

        for app in apps:
            stdout = ec.trace(app, 'stdout')
            size = ec.trace(app, 'stdout', attr = TraceAttr.SIZE)
            self.assertEquals(len(stdout), size)
            
            block = ec.trace(app, 'stdout', attr = TraceAttr.STREAM, block = 5, offset = 1)
            self.assertEquals(block, stdout[5:10])

            path = ec.trace(app, 'stdout', attr = TraceAttr.PATH)
            rm = ec.get_resource(app)
            p = os.path.join(rm.run_home, 'stdout')
            self.assertEquals(path, p)

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


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