本文整理汇总了Python中nepi.execution.ec.ExperimentController.deploy方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentController.deploy方法的具体用法?Python ExperimentController.deploy怎么用?Python ExperimentController.deploy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nepi.execution.ec.ExperimentController
的用法示例。
在下文中一共展示了ExperimentController.deploy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: t_deploy
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例2: t_nping
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例3: t_stdout
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例4: test_ccnpeek
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例5: test_stop_with_condition
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例6: test_concurrency
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例7: t_tun_create
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例8: t_rtt
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例9: t_tofile
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例10: t_dce_ccnpeek_with_stack
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例11: t_real_time
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [as 别名]
def t_real_time(self, host, user = None, identity = None):
ec = ExperimentController(exp_id = "test-ns3-real-time")
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, "cleanHome", 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.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")
# Create channel
chan = ec.register_resource("ns3::PointToPointChannel")
ec.set(chan, "Delay", "0s")
ec.register_connection(chan, dev1)
ec.register_connection(chan, dev2)
### create pinger
ping = ec.register_resource("ns3::V4Ping")
ec.set (ping, "Remote", "10.0.0.2")
ec.set (ping, "Interval", "1s")
ec.set (ping, "Verbose", True)
ec.set (ping, "StartTime", "0s")
ec.set (ping, "StopTime", "20s")
ec.register_connection(ping, nsnode1)
ec.deploy()
ec.wait_finished([ping])
stdout = ec.trace(simu, "stdout")
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
rm = ec.get_resource(ping)
start_time = rm.start_time
stop_time = rm.stop_time
delta = stop_time - start_time
self.assertTrue(delta.seconds >= 20, "Time elapsed %d" % delta.seconds)
self.assertTrue(delta.seconds < 25, "Time elapsed %d" % delta.seconds)
ec.shutdown()
示例12: t_tun_hybrid_gre_tunnel
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [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()
示例13: t_wifi_ping
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [as 别名]
def t_wifi_ping(self, host, user = None, identity = None):
bounds_width = bounds_height = 200
x = y = 100
speed = 1
ec = ExperimentController(exp_id = "test-ns3-wifi-ping")
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, "cleanHome", True)
simu = ec.register_resource("linux::ns3::Simulation")
ec.set(simu, "verbose", True)
ec.register_connection(simu, node)
nsnode1 = add_ns3_node(ec, simu)
dev1, phy1 = add_wifi_device(ec, nsnode1, "10.0.0.1", "24", access_point = True)
mobility1 = add_constant_mobility(ec, nsnode1, x, y, 0)
nsnode2 = add_ns3_node(ec, simu)
dev2, phy2 = add_wifi_device(ec, nsnode2, "10.0.0.2", "24", access_point = False)
mobility1 = add_constant_mobility(ec, nsnode2, x, y, 0)
#mobility2 = add_random_mobility(ec, nsnode2, x, y, 0, speed, bounds_width, bounds_height)
# Create channel
chan = add_wifi_channel(ec)
ec.register_connection(chan, phy1)
ec.register_connection(chan, phy2)
### create pinger
ping = ec.register_resource("ns3::V4Ping")
ec.set (ping, "Remote", "10.0.0.1")
ec.set (ping, "Interval", "1s")
ec.set (ping, "Verbose", True)
ec.set (ping, "StartTime", "1s")
ec.set (ping, "StopTime", "21s")
ec.register_connection(ping, nsnode2)
ec.deploy()
ec.wait_finished([ping])
stdout = ec.trace(simu, "stdout")
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
ec.shutdown()
示例14: t_compile_debug_mode
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [as 别名]
def t_compile_debug_mode(self, host, user = None, identity = None):
ec = ExperimentController(exp_id = "test-ns3-debug-mode")
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", "V4Ping:Node")
ec.set(simu, "buildMode", "debug")
ec.register_connection(simu, node)
nsnode1 = add_ns3_node(ec, simu)
dev1 = add_csma_device(ec, nsnode1, "10.0.0.1", "30")
nsnode2 = add_ns3_node(ec, simu)
dev2 = add_csma_device(ec, nsnode2, "10.0.0.2", "30")
# Create channel
chan = ec.register_resource("ns3::CsmaChannel")
ec.set(chan, "Delay", "0s")
ec.register_connection(chan, dev1)
ec.register_connection(chan, dev2)
### create pinger
ping = ec.register_resource("ns3::V4Ping")
ec.set (ping, "Remote", "10.0.0.2")
ec.set (ping, "Interval", "1s")
ec.set (ping, "Verbose", True)
ec.set (ping, "StartTime", "0s")
ec.set (ping, "StopTime", "20s")
ec.register_connection(ping, nsnode1)
ec.deploy()
ec.wait_finished([ping])
stdout = ec.trace(simu, "stdout")
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
stderr = ec.trace(simu, "stderr")
expected = "V4Ping:Read32"
self.assertTrue(stderr.find(expected) > -1)
ec.shutdown()
示例15: t_user_sources
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import deploy [as 别名]
def t_user_sources(self, host, user = None, identity = None):
ec = ExperimentController(exp_id = "test-ns3-user-sources")
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, "cleanHome", True)
simu = ec.register_resource("linux::ns3::Simulation")
ec.set(simu, "verbose", True)
sources = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"ns-3.18-user.tar.gz")
ec.set(simu, "sources", sources)
ec.set(simu, "pybindgenVersion", "834")
ec.register_connection(simu, node)
nsnode1 = add_ns3_node(ec, simu)
dev1 = add_csma_device(ec, nsnode1, "10.0.0.1", "30")
nsnode2 = add_ns3_node(ec, simu)
dev2 = add_csma_device(ec, nsnode2, "10.0.0.2", "30")
# Create channel
chan = ec.register_resource("ns3::CsmaChannel")
ec.set(chan, "Delay", "0s")
ec.register_connection(chan, dev1)
ec.register_connection(chan, dev2)
### create pinger
ping = ec.register_resource("ns3::V4Ping")
ec.set (ping, "Remote", "10.0.0.2")
ec.set (ping, "Interval", "1s")
ec.set (ping, "Verbose", True)
ec.set (ping, "StartTime", "0s")
ec.set (ping, "StopTime", "20s")
ec.register_connection(ping, nsnode1)
ec.deploy()
ec.wait_finished([ping])
stdout = ec.trace(simu, "stdout")
expected = "20 packets transmitted, 20 received, 0% packet loss"
self.assertTrue(stdout.find(expected) > -1)
ec.shutdown()