From 6a32967e2de49eaee359f29a482e19b3238f5016 Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Thu, 29 Mar 2018 14:45:58 +0200 Subject: storyboard: add/format docstrings Also: + small docstring fixes in model + docstring fixes in log + log refactoring + other small refactoring + some small documentation fixes --- rumba/model.py | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'rumba/model.py') diff --git a/rumba/model.py b/rumba/model.py index f9a0d3c..a6925b3 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -59,7 +59,6 @@ except OSError: pass - class Testbed(object): """ Base class for every testbed plugin. @@ -124,6 +123,7 @@ class Testbed(object): def _swap_out(self, experiment): logger.info("swap_out(): nothing to do") + class DIF(object): """ Base class for DIFs. @@ -231,7 +231,7 @@ class ShimEthDIF(DIF): distribution=None): """ Set the delay parameters of the underlying link. - Parameters as in :py:meth:`.Delay.__init__` + Parameters as in :py:class:`.Delay` :param delay: average delay in ms :type delay: :py:class:`int` @@ -252,7 +252,7 @@ class ShimEthDIF(DIF): correlation=None): """ Set the loss parameter of the underlying link. - Parameters as in :py:meth:`.Loss.__init__` + Parameters as in :py:class:`.Loss` :param loss: loss in percentage :type loss: :py:class:`int` or :py:class:`float` @@ -321,11 +321,11 @@ class NormalDIF(DIF): :param comp: Component name. :param pol: Policy name """ - self.policy.del_policy(comp, policy_name) + self.policy.del_policy(comp, pol) def show(self): """ - :return: A string of the policies in the DIF. + :return: A string representing the policies in the DIF. """ s = DIF.__repr__(self) for comp, pol_dict in self.policy.get_policies().items(): @@ -338,6 +338,14 @@ class NormalDIF(DIF): class Distribution(Enum): """ An enum holding different statistical distributions. + + **Values:** + + `NORMAL = 1` + + `PARETO = 2` + + `PARETONORMAL = 3` """ NORMAL = 1 PARETO = 2 @@ -463,9 +471,9 @@ class LinkQuality(object): Clone old_quality, updating it with the provided parameters if present. - :param old_quality: A :py:class`.LinkQuality` instance to + :param old_quality: A :py:class:`.LinkQuality` instance to use as a base - :type old_quality: :py:class`.LinkQuality` + :type old_quality: :py:class:`.LinkQuality` :param delay: Delay object holding delay configuration or number corresponding to delay in ms :type delay: :py:class:`.Delay` or :py:class:`int` @@ -474,8 +482,8 @@ class LinkQuality(object): :type loss: :py:class:`.Loss` or :py:class:`float` :param rate: The rate of the link in mbit :type rate: :py:class:`int` - :return: a new :py:class`.LinkQuality` instance. - :rtype: py:class`LinkQuality` + :return: a new :py:class:`.LinkQuality` instance. + :rtype: :py:class:`.LinkQuality` """ if delay is None: delay = old_quality.delay @@ -568,6 +576,7 @@ class LinkQuality(object): "netem" % ipcp.ifname, as_root=True) LinkQuality._active.remove(ipcp) + class SSHConfig(object): def __init__(self, hostname, port=22, proxy_server=None): self.username = None @@ -588,6 +597,7 @@ class SSHConfig(object): def set_http_proxy(self, proxy): self.http_proxy = proxy + class Node(object): """ A node in the experiment. @@ -624,8 +634,8 @@ class Node(object): if hasattr(dif, 'policy'): # check if the dif supports policies self.policies[dif] = policies.get(dif, Policy(dif, self)) - self.executor = None # will be set by testbed on swap_in - self.startup_command = None # will be set by prototype + self.executor = None # will be set by testbed on swap_in + self.startup_command = None # will be set by prototype self._validate() @@ -742,6 +752,7 @@ class Node(object): """ Removes a policy. + :param dif: the dif to which the policy should be applied :param component_name: Name of the component. :param policy_name: Name of the policy. """ @@ -764,7 +775,10 @@ class Node(object): :param time_out: Seconds before timing out. :param use_proxy: Use a proxy to execute the commands? """ - return self.executor.execute_commands(self, commands, as_root, time_out) + return self.executor.execute_commands(self, + commands, + as_root, + time_out) def execute_command(self, command, as_root=False, time_out=3, use_proxy=False): @@ -777,7 +791,10 @@ class Node(object): :param use_proxy: Use a proxy to execute the commands? :return: The stdout of the command. """ - return self.executor.execute_command(self, command, as_root, time_out) + return self.executor.execute_command(self, + command, + as_root, + time_out) def copy_file(self, path, destination): """ @@ -801,7 +818,7 @@ class Node(object): """ Fetch file from the node. - :param paths: Location of the files on the node. + :param path: Location of the files on the node. :param destination: Destination location of the files. :param sudo: The file is owned by root on the node? """ @@ -828,6 +845,7 @@ class Node(object): self.execute_command('ip link set dev ' + ipcp.ifname + ' ' + state, as_root=True) + class IPCP(object): def __init__(self, name, node, dif): self.name = name @@ -868,6 +886,7 @@ class ShimUDPIPCP(IPCP): IPCP.__init__(self, name, node, dif) # TODO: add IP and port + class Policy(object): def __init__(self, dif, node=None, policies=None): self.dif = dif # type: NormalDIF @@ -940,6 +959,7 @@ class Policy(object): s += "\n]\n" return s + class Experiment(object): """ Base class for experiments. -- cgit v1.2.3