From 26e3e22cd6ca6676b7b99624764f8e6f1ae1479d Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Fri, 21 Apr 2017 15:58:56 +0200 Subject: rumba: log: Added logging support, migrated from print to logging. + Added logging, migrated, default logging configuration is to stdout. + Minor PEP8 adjustments all-around --- rumba/prototypes/ouroboros.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'rumba/prototypes/ouroboros.py') diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 4fdacd6..9776c5e 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -21,6 +21,11 @@ import rumba.ssh_support as ssh import rumba.model as mod import time +import rumba.log as log + + +logger = log.get_logger(__name__) + # An experiment over the Ouroboros implementation class Experiment(mod.Experiment): @@ -48,7 +53,7 @@ class Experiment(mod.Experiment): cmds.append("irm b ap " + ap + " n " + name) ssh.execute_commands(self.testbed, node.ssh_config, - cmds, time_out = None) + cmds, time_out=None) def reg_names(self): for node in self.nodes: @@ -60,14 +65,14 @@ class Experiment(mod.Experiment): cmds.append(cmd) ssh.execute_commands(self.testbed, node.ssh_config, cmds, - time_out = None) + time_out=None) def create_ipcps(self): for node in self.nodes: cmds = list() for ipcp in node.ipcps: cmds2 = list() - if ipcp.dif_bootstrapper == True: + if ipcp.dif_bootstrapper: cmd = "irm i b n " + ipcp.name else: cmd = "irm i c n " + ipcp.name @@ -80,7 +85,7 @@ class Experiment(mod.Experiment): cmd += " dif " + ipcp.dif.name elif type(ipcp.dif) is mod.NormalDIF: cmd += " type normal" - if ipcp.dif_bootstrapper == True: + if ipcp.dif_bootstrapper: cmd += " dif " + ipcp.dif.name cmd2 = "irm b i " + ipcp.name + " name " + ipcp.dif.name cmds2.append(cmd2) @@ -97,7 +102,7 @@ class Experiment(mod.Experiment): cmd += " type shim-udp" cmd += " dif " + ipcp.dif.name else: - print("Unsupported IPCP type") + logger.error("Unsupported IPCP type") continue cmds.append(cmd) @@ -105,7 +110,7 @@ class Experiment(mod.Experiment): cmds.append(cmd) ssh.execute_commands(self.testbed, node.ssh_config, cmds, - time_out = None) + time_out=None) def enroll_ipcps(self): for el in self.enrollments: @@ -128,18 +133,18 @@ class Experiment(mod.Experiment): ssh.execute_commands(self.testbed, e['enrollee'].ssh_config, - cmds, time_out = None) + cmds, time_out=None) time.sleep(2) def run_prototype(self): - print("Setting up Ouroboros...") + logger.info("Setting up Ouroboros...") self.setup_ouroboros() - print("Binding names...") + logger.info("Binding names...") self.bind_names() - print("Creating IPCPs") + logger.info("Creating IPCPs") self.create_ipcps() - print("Enrolling IPCPs...") + logger.info("Enrolling IPCPs...") self.enroll_ipcps() - print("Registering names...") + logger.info("Registering names...") self.reg_names() - print("All done, have fun!") + logger.info("All done, have fun!") -- cgit v1.2.3