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


Python ExperimentController.set方法代码示例

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


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

示例1: test_ccnpeek

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

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

示例3: make_experiment

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

示例4: t_simple_multirun

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

示例5: t_stdout

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

示例6: t_http_sources

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

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

        sources = "http://yans.pl.sophia.inria.fr/code/nef/archive/tip.tar.gz;" \
                "http://yans.pl.sophia.inria.fr/code/nef/raw-file/8ace577d4079/src/nef/images/menu/connect.png"

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

        command = "ls ${SRC}"
        ec.set(app, "command", command)

        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)

        exitcode = ec.trace(app, "deploy_exitcode")
        self.assertTrue(exitcode.strip() == "0")
        
        out = ec.trace(app, "deploy_stdout")
        self.assertTrue(out.find("tip.tar.gz") > -1)
        self.assertTrue(out.find("connect.png") > -1)

        stdout = ec.trace(app, "stdout")
        self.assertTrue(stdout.find("tip.tar.gz") > -1)
        self.assertTrue(stdout.find("connect.png") > -1)

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

示例7: test_critical

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

        ec = ExperimentController()

        node = ec.register_resource("Node")

        apps = list()
        
        eapp = ec.register_resource("ErrorApplication")
        ec.set(eapp, "critical", False)
        ec.register_connection(eapp, node)
        apps.append(eapp)

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

        ec.deploy()

        ec.wait_finished(apps)
        
        state = ec.state(eapp)
        self.assertEquals(state, ResourceState.FAILED)
      
        apps.remove(eapp)

        for app in apps:
            state = ec.state(app)
            self.assertEquals(state, ResourceState.STOPPED)
        
        ec.shutdown()

        self.assertEquals(ec._fm._failure_level, FailureLevel.OK)
开发者ID:phiros,项目名称:nepi,代码行数:42,代码来源:resource.py

示例8: t_nodns

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

        ec = ExperimentController(exp_id = "test-nodns")
        
        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::Mtr")
        ec.set(app, "noDns", False)
        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.") > -1)

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

示例9: t_count

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

        ec = ExperimentController(exp_id = "test-ping-count")
        
        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::Ping")
        ec.set(app, "count", "3")
        ec.set(app, "target", self.target)
        ec.register_connection(app, node)

        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)

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

示例10: t_xterm

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

        ec = ExperimentController(exp_id="test-xterm")
        
        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")
        ec.set(app, "command", "xterm")
        ec.set(app, "depends", "xterm")
        ec.set(app, "forwardX11", True)

        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished([app])

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

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

示例11: t_copy_files

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import set [as 别名]
    def t_copy_files(self, host, user):
        # create some temp files and directories to copy
        dirpath = tempfile.mkdtemp()
        f = tempfile.NamedTemporaryFile(dir=dirpath, delete=False)
        f.close()
      
        f1 = tempfile.NamedTemporaryFile(delete=False)
        f1.close()
        f1.name

        ec = ExperimentController(exp_id="test-copyfile")
        
        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")
        ec.set(app, "command", "ls ${SRC}")
        ec.set(app, "sources", "%s;%s" % (dirpath, f1.name))
        ec.register_connection(app, node)

        ec.deploy()

        ec.wait_finished([app])

        stdout = ec.trace(app, "stdout")
        
        self.assertTrue(stdout.find(os.path.basename(dirpath)) > -1)
        self.assertTrue(stdout.find(os.path.basename(f1.name)) > -1)

        ec.shutdown()
        
        os.remove(f1.name)
        shutil.rmtree(dirpath)
开发者ID:phiros,项目名称:nepi,代码行数:38,代码来源:application.py

示例12: t_concurrency

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

示例13: ExperimentController

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import set [as 别名]
            Julien Tribino <[email protected]>


"""

#!/usr/bin/env python
from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController

# Create the EC
ec = ExperimentController()

# Create and Configure the Nodes

node1 = ec.register_resource("omf::Node")
ec.set(node1, 'hostname', 'node025')
ec.set(node1, 'xmppServer', "nitlab.inf.uth.gr")
ec.set(node1, 'xmppUser', "nepi")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")

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', "vlc")
ec.set(iface1, 'ip', "192.168.0.25/24")

node2 = ec.register_resource("omf::Node")
ec.set(node2, 'hostname', 'node027')
ec.set(node2, 'xmppServer', "nitlab.inf.uth.gr")
开发者ID:phiros,项目名称:nepi,代码行数:33,代码来源:nepi_omf6_nitos_vlc.py

示例14: t_tap_create

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

示例15: ExperimentController

# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import set [as 别名]
        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")
ec.set(iface1, "ip", "192.168.0.%s/24" % nodex[-2:]) 
ec.register_connection(node1, iface1)

# Create and Configure the Nodes
开发者ID:phiros,项目名称:nepi,代码行数:33,代码来源:nitos_omf6_ping.py


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