aboutsummaryrefslogtreecommitdiff
path: root/rumba/model.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2018-02-21 11:43:49 +0100
committerMarco Capitani <m.capitani@nextworks.it>2018-02-27 16:51:26 +0100
commit0158b68b1736ca8a5fb68de5a56cae234030774c (patch)
tree77d317940d9abcc0db9140fc494266c9a04effb2 /rumba/model.py
parent5e6f1b8dd525bf4c0f8a03463bdb1f4696f27dee (diff)
downloadrumba-0158b68b1736ca8a5fb68de5a56cae234030774c.tar.gz
rumba-0158b68b1736ca8a5fb68de5a56cae234030774c.zip
model & more: add prototype/system log fields
This commit adds the fields necessary to specify the paths and folders related to system logs and prototype logs and fetching them. Defaults are introduced and specific paths for rlite & qemu
Diffstat (limited to 'rumba/model.py')
-rw-r--r--rumba/model.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/rumba/model.py b/rumba/model.py
index b877209..5647b1e 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -28,6 +28,7 @@ import abc
import os
import stat
import time
+import shutil
import rumba.log as log
from rumba import ssh_support
@@ -70,13 +71,20 @@ class Testbed(object):
username,
password,
proj_name,
- http_proxy=None):
+ http_proxy=None,
+ system_logs=None):
self.username = username
self.password = password
self.proj_name = proj_name
self.exp_name = exp_name
self.http_proxy = http_proxy
self.flags = {'no_vlan_offload': False}
+ if system_logs is None:
+ self.system_logs = ['/var/log/syslog']
+ elif isinstance(system_logs, str):
+ self.system_logs = [system_logs]
+ else:
+ self.system_logs = system_logs
@abc.abstractmethod
def swap_in(self, experiment):
@@ -526,7 +534,12 @@ class Policy(object):
class Experiment(object):
__metaclass__ = abc.ABCMeta
- def __init__(self, testbed, nodes=None, git_repo=None, git_branch=None):
+ def __init__(self, testbed,
+ nodes=None,
+ git_repo=None,
+ git_branch=None,
+ log_dir=None,
+ prototype_logs=None):
if nodes is None:
nodes = list()
self.nodes = nodes
@@ -544,6 +557,22 @@ class Experiment(object):
self.dt_flows = [] # a list of per-DIF lists of data transfer flows
self.mgmt_flows = [] # a list of per-DIF lists of management flows
+ # Determine log directory
+ if log_dir is None:
+ # If it is None, use /tmp/rumba/{project}
+ # Wipe it and make it again
+ exp_name = self.testbed.exp_name.replace('/', '_') # Just in case
+ log_dir = '/tmp/rumba/' + exp_name + '/'
+ shutil.rmtree(log_dir, ignore_errors=True)
+ os.mkdir(log_dir)
+ self.log_dir = log_dir
+ if not os.path.isdir(self.log_dir):
+ raise Exception('Destination "%s" is not a directory. '
+ 'Cannot fetch logs.'
+ % self.log_dir)
+ self.prototype_logs = prototype_logs \
+ if prototype_logs is not None else []
+
# Generate missing information
self.generate()