def run(hostnames, vsys_vnet, slicename, plc_host, pl_user, pl_pwd, pl_ssh_key, port_base, root_dir, port): exp_desc, pl_nodes, hostname, pl_app = create_ed(hostnames, vsys_vnet, slicename, plc_host, pl_user, pl_pwd, pl_ssh_key, port_base, root_dir, port) xml = exp_desc.to_xml() controller = ExperimentController(xml, root_dir) controller.start() while not TERMINATE and controller.status( pl_app.guid) == AS.STATUS_NOT_STARTED: time.sleep(0.5) proc = None if not TERMINATE: hostname = hostnames[-1] proc = exec_ccncatchunks(slicename, port, hostname) while not TERMINATE and proc and proc.poll() is None: time.sleep(0.5) if proc: if proc.poll() < 1: err = proc.stderr.read() print "ERROR ", err else: out = proc.stdout.read() print "OUTPUT ", out controller.stop() controller.shutdown()
def run(hostnames, vsys_vnet, slicename, plc_host, pl_user, pl_pwd, pl_ssh_key, port_base, root_dir, port): exp_desc, pl_nodes, hostname, pl_app = create_ed(hostnames, vsys_vnet, slicename, plc_host, pl_user, pl_pwd, pl_ssh_key, port_base, root_dir, port) xml = exp_desc.to_xml() controller = ExperimentController(xml, root_dir) controller.start() while not TERMINATE and controller.status(pl_app.guid) == AS.STATUS_NOT_STARTED: time.sleep(0.5) proc = None if not TERMINATE: hostname = hostnames[-1] proc = exec_ccncatchunks(slicename, port, hostname) while not TERMINATE and proc and proc.poll() is None: time.sleep(0.5) if proc: if proc.poll() < 1: err = proc.stderr.read() print "ERROR ", err else: out = proc.stdout.read() print "OUTPUT ", out controller.stop() controller.shutdown()
class ExperimentControllerServer(BaseServer): def __init__(self, root_dir, log_level, experiment_xml, environment_setup, clean_root): super(ExperimentControllerServer, self).__init__(root_dir, log_level, environment_setup = environment_setup, clean_root = clean_root) self._experiment_xml = experiment_xml self._experiment = None def post_daemonize(self): from nepi.core.execute import ExperimentController self._experiment = ExperimentController(self._experiment_xml, root_dir = self._root_dir) @Marshalling.handles(GUIDS) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def guids(self): return self._experiment.guids @Marshalling.handles(STARTED_TIME) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def started_time(self): return self._experiment.started_time @Marshalling.handles(STOPPED_TIME) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def stopped_time(self): return self._experiment.stopped_time @Marshalling.handles(XML) @Marshalling.args() @Marshalling.retval() def experiment_design_xml(self): return self._experiment.experiment_design_xml @Marshalling.handles(EXEC_XML) @Marshalling.args() @Marshalling.retval() def experiment_execute_xml(self): return self._experiment.experiment_execute_xml @Marshalling.handles(TRACE) @Marshalling.args(int, str, Marshalling.base64_data) @Marshalling.retval() def trace(self, guid, trace_id, attribute): return str(self._experiment.trace(guid, trace_id, attribute)) @Marshalling.handles(TRACES_INFO) @Marshalling.args() @Marshalling.retval( Marshalling.pickled_data ) def traces_info(self): return self._experiment.traces_info() @Marshalling.handles(FINISHED) @Marshalling.args(int) @Marshalling.retval(Marshalling.bool) def is_finished(self, guid): return self._experiment.is_finished(guid) @Marshalling.handles(STATUS) @Marshalling.args(int) @Marshalling.retval(int) def status(self, guid): return self._experiment.status(guid) @Marshalling.handles(GET) @Marshalling.args(int, Marshalling.base64_data, str) @Marshalling.retval( Marshalling.pickled_data ) def get(self, guid, name, time): return self._experiment.get(guid, name, time) @Marshalling.handles(SET) @Marshalling.args(int, Marshalling.base64_data, Marshalling.pickled_data, str) @Marshalling.retvoid def set(self, guid, name, value, time): self._experiment.set(guid, name, value, time) @Marshalling.handles(START) @Marshalling.args() @Marshalling.retvoid def start(self): self._experiment.start() @Marshalling.handles(STOP) @Marshalling.args() @Marshalling.retvoid def stop(self): self._experiment.stop() @Marshalling.handles(RECOVER) @Marshalling.args() @Marshalling.retvoid def recover(self): self._experiment.recover() @Marshalling.handles(SHUTDOWN) @Marshalling.args() @Marshalling.retvoid def shutdown(self): self._experiment.shutdown() @Marshalling.handles(GET_TESTBED_ID) @Marshalling.args(int) @Marshalling.retval() def get_testbed_id(self, guid): return self._experiment.get_testbed_id(guid) @Marshalling.handles(GET_FACTORY_ID) @Marshalling.args(int) @Marshalling.retval() def get_factory_id(self, guid): return self._experiment.get_factory_id(guid) @Marshalling.handles(GET_TESTBED_VERSION) @Marshalling.args(int) @Marshalling.retval() def get_testbed_version(self, guid): return self._experiment.get_testbed_version(guid)