本文整理汇总了Python中nepi.execution.ec.ExperimentController.state方法的典型用法代码示例。如果您正苦于以下问题:Python ExperimentController.state方法的具体用法?Python ExperimentController.state怎么用?Python ExperimentController.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nepi.execution.ec.ExperimentController
的用法示例。
在下文中一共展示了ExperimentController.state方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: t_stdout
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()
示例2: test_concurrency
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()
示例3: t_deploy
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()
示例4: t_concurrency
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()
示例5: t_http_sources
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()
示例6: test_critical
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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)
示例7: t_condition
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [as 别名]
def t_condition(self, host, user, depends):
ec = ExperimentController(exp_id="test-condition")
node = ec.register_resource("linux::Node")
ec.set(node, "hostname", host)
ec.set(node, "username", user)
ec.set(node, "cleanExperiment", True)
ec.set(node, "cleanProcesses", True)
server = ec.register_resource("linux::Application")
cmd = "echo 'HOLA' | nc -l 3333"
ec.set(server, "command", cmd)
ec.set(server, "depends", depends)
ec.register_connection(server, node)
client = ec.register_resource("linux::Application")
cmd = "nc 127.0.0.1 3333"
ec.set(client, "command", cmd)
ec.register_connection(client, node)
ec.register_condition(client, ResourceAction.START, server, ResourceState.STARTED)
apps = [client, server]
ec.deploy()
ec.wait_finished(apps)
self.assertTrue(ec.state(node) == ResourceState.STARTED)
self.assertTrue(ec.state(server) == ResourceState.STOPPED)
self.assertTrue(ec.state(client) == ResourceState.STOPPED)
stdout = ec.trace(client, "stdout")
self.assertTrue(stdout.strip() == "HOLA")
ec.shutdown()
示例8: t_xterm
# 需要导入模块: from nepi.execution.ec import ExperimentController [as 别名]
# 或者: from nepi.execution.ec.ExperimentController import state [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()