diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2021-07-19 21:56:11 +0200 |
---|---|---|
committer | Dimitri Staessens <dimitri@ouroboros.rocks> | 2021-07-19 21:56:11 +0200 |
commit | 1abd211bb7b58dc258570116af9403ecf0e28da9 (patch) | |
tree | 5f3dcd7bfb778e724b141d164f4dda4d33ba5f73 | |
parent | 97b16ada2b710cfe88c3bc6bf9e0dc42a943fca5 (diff) | |
download | rumba-1abd211bb7b58dc258570116af9403ecf0e28da9.tar.gz rumba-1abd211bb7b58dc258570116af9403ecf0e28da9.zip |
experiment: Move link rate setting to prototype
Apparently I didn't test my final change for this feature when I moved
it from the storyboard to the experiment. It didn't work, I tried to
put it in the testbed class, but that was a mess, so for now it's
moved to the prototype.
-rw-r--r-- | rumba/elements/experimentation.py | 36 | ||||
-rw-r--r-- | rumba/prototypes/ouroboros.py | 29 | ||||
-rw-r--r-- | rumba/testbeds/dockertb.py | 1 | ||||
-rw-r--r-- | rumba/testbeds/jfed.py | 2 |
4 files changed, 37 insertions, 31 deletions
diff --git a/rumba/elements/experimentation.py b/rumba/elements/experimentation.py index 03d90bb..efd7a3e 100644 --- a/rumba/elements/experimentation.py +++ b/rumba/elements/experimentation.py @@ -540,36 +540,22 @@ class Experiment(object): def _stop_metrics_exporter(self, nodes): raise Exception('start_metrics_exporter() method not implemented') - def set_eth_link_rate_to(self, src, dst, megabit): + @abc.abstractmethod + def _set_phy_link_rate_to(self, src, dst, megabit): + raise Exception('set_phy_k') + + def set_phy_link_rate_to(self, src, dst, megabit): """ - Sets the link rate on src NIC towards dst with ethtool - Fixme: This should be moved to the testbed class - Fixme: Test if testbed is a physical Linux server + Sets the physical link rate in the experiment """ + self._set_phy_link_rate_to(src, dst, megabit) - if megabit not in [10, 100, 1000]: - return - - self.run_command(src, "route | grep $(ping server -c 1 | head -n1 | cut -f3 -d' ' | head -c -3 | tail -c +2) | " - "grep -o '[^ ]*$' > iface ".format(dst)) - self.run_command(src, "sudo ethtool -s $(cat iface) speed {} duplex full autoneg off".format(megabit)) - self.run_command(src, "sudo ip link set $(cat iface) down") - self.run_command(src, "sudo ip link set $(cat iface) up && sleep 10") - self.run_command(src, "sudo ethtool $(cat iface) | grep '{}Mb/s'".format(megabit)) - self.run_command(src, "rm iface") - self.run_command(src, "while ! ping -c 1 {}; do sleep 1; done".format(dst)) - - def set_eth_link_rate_between(self, src, dst, megabit): + def set_phy_link_rate_between(self, src, dst, megabit): """ - Sets the link rate with ethtool - Fixme: This should be moved to the testbed class - Fixme: Test if testbed is a physical Linux server + Sets the physical link rate in the experiment """ - if megabit not in [10, 100, 1000]: - return - - self.set_eth_link_rate_to(src, dst, megabit) - self.set_eth_link_rate_to(dst, src, megabit) + self._set_phy_link_rate_to(src, dst, megabit) + self._set_phy_link_rate_to(dst, src, megabit) def swap_in(self): """ diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 1558acd..c8d286f 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -145,8 +145,10 @@ class Experiment(mod.Experiment): @staticmethod def make_executor(node, packages, testbed): def executor(commands): - ssh.aptitude_install(testbed, node, packages) - node.execute_commands(commands, time_out=None, use_proxy=True) + if packages and len(packages) > 0: + ssh.aptitude_install(testbed, node, packages) + if commands and len(commands) > 0: + node.execute_commands(commands, time_out=None, use_proxy=True) return executor def prototype_name(self): @@ -184,14 +186,20 @@ class Experiment(mod.Experiment): executors = [] args = [] + if nodes and isinstance(nodes, str): + nodes = [nodes] + if nodes is None: - nodes = self.nodes + _nodes = self.nodes + else: + _nodes = [node for node in self.nodes if node.name in nodes] - for node in nodes: + for node in _nodes: executor = self.make_executor(node, packages, self.testbed) names.append(node.name) executors.append(executor) args.append(cmds) + m_processing.call_in_parallel(names, args, executors) def install_ouroboros(self): @@ -293,6 +301,19 @@ class Experiment(mod.Experiment): self._install_packages_and_execute_cmds([], cmds, nodes) + def _set_phy_link_rate_to(self, src, dst, megabit): + + commands = ["route | grep $(ping server -c 1 | head -n1 | cut -f3 -d' ' | head -c -3 | tail -c +2) | " + "grep -o '[^ ]*$' > iface ".format(dst), + "sudo ethtool -s $(cat iface) speed {} duplex full autoneg off".format(megabit), + "sudo ip link set $(cat iface) down", + "sudo ip link set $(cat iface) up && sleep 10", + "sudo ethtool $(cat iface) | grep '{}Mb/s'".format(megabit), + "rm iface", + "while ! ping -c 1 {}; do sleep 1; done".format(dst)] + + self._install_packages_and_execute_cmds([], commands, [src]) + def create_ipcps(self): for node in self.nodes: cmds = list() diff --git a/rumba/testbeds/dockertb.py b/rumba/testbeds/dockertb.py index 1e92658..d2a1334 100644 --- a/rumba/testbeds/dockertb.py +++ b/rumba/testbeds/dockertb.py @@ -35,6 +35,7 @@ from rumba.executors.docker import DockerExecutor logger = log.get_logger(__name__) + class Testbed(mod.Testbed): """ Represents a docker testbed. diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py index 828a74e..be914cd 100644 --- a/rumba/testbeds/jfed.py +++ b/rumba/testbeds/jfed.py @@ -381,5 +381,3 @@ class Testbed(mod.Testbed): else: logger.debug("Node %s interface %s has name %s." % (node_n.name, mac, ifname)) - - |