From b860b441841dc5c5c3129b477291c4424912366a Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Wed, 6 Jun 2018 16:32:05 +0200 Subject: [PATCH] Supporting the a single statement in a recipe We now can use the all statement without any other statements. Signed-off-by: Jonatan Schlag --- src/nitsi/recipe.py | 12 ++++-------- src/nitsi/test.py | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/nitsi/recipe.py b/src/nitsi/recipe.py index 7d27ca4..f76066a 100644 --- a/src/nitsi/recipe.py +++ b/src/nitsi/recipe.py @@ -16,7 +16,7 @@ class RecipeExeption(Exception): # Should read the test, check if the syntax are valid # and return tuples with the ( host, command ) structure class recipe(): - def __init__(self, path, circle=[]): + def __init__(self, path, circle=[], machines=[]): self.recipe_file = path try: self.path = os.path.dirname(self.recipe_file) @@ -28,7 +28,9 @@ class recipe(): self.log = logger.getChild(self.name) self.log.debug("Path of recipe is: {}".format(self.recipe_file)) self._recipe = None - self._machines = None + self._machines = machines + + self.log.debug("Machine names we use when we substitute the all statement: {}".format(self._machines)) self.in_recursion = True if len(circle) == 0: @@ -57,12 +59,6 @@ class recipe(): @property def machines(self): - if not self._machines: - self._machines = [] - for line in self._recipe: - if line[0] != "all" and line[0] not in self._machines: - self._machines.append(line[0]) - return self._machines def parse(self): diff --git a/src/nitsi/test.py b/src/nitsi/test.py index e1ae24c..a861a48 100755 --- a/src/nitsi/test.py +++ b/src/nitsi/test.py @@ -103,7 +103,7 @@ class test(): def load_recipe(self): self.log.info("Going to load the recipe") try: - self.recipe = recipe.recipe(self.recipe_file) + self.recipe = recipe.recipe(self.recipe_file, machines=self.virtual_environ.machine_names) for line in self.recipe.recipe: self.log.debug(line) -- 2.47.3