From 7ebf246ff12bfc4f9bdf1984620db9df2f3f7a45 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 2 Oct 2014 13:29:24 -0400 Subject: [PATCH] Some signature related things, prior to starting test scaffolding --- lib/v2/playbook/base.py | 8 +------- lib/v2/playbook/block.py | 10 ++-------- lib/v2/playbook/handler.py | 21 +++++++++------------ lib/v2/playbook/role.py | 25 ++++++++++++++----------- 4 files changed, 26 insertions(+), 38 deletions(-) diff --git a/lib/v2/playbook/base.py b/lib/v2/playbook/base.py index 44abe4a6ea3..3b4785ee46b 100644 --- a/lib/v2/playbook/base.py +++ b/lib/v2/playbook/base.py @@ -15,13 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -from v2.playbook import Tag, Conditional - -class PlaybookBase(Tag, Conditional): - ''' - Implements a common object, which supports filtering based on - both tags and when: conditional statements - ''' +class Base(object): def __init__(self): pass diff --git a/lib/v2/playbook/block.py b/lib/v2/playbook/block.py index f4d5946135d..c5ab518efa9 100644 --- a/lib/v2/playbook/block.py +++ b/lib/v2/playbook/block.py @@ -18,13 +18,7 @@ from v2.playbook.base import PlaybookBase class Block(PlaybookBase): - def __init__(self): - self.ds = None - self.plays = [] - def load(self, ds): - self.ds = ds - self.plays = [] + def __init__(self): + pass - def get_plays(self): - return self.plays diff --git a/lib/v2/playbook/handler.py b/lib/v2/playbook/handler.py index 32a803dbc52..42d937ec464 100644 --- a/lib/v2/playbook/handler.py +++ b/lib/v2/playbook/handler.py @@ -20,20 +20,17 @@ from v2.inventory import Host from v2.playbook import Task class Handler(Task): + def __init__(self): - self.triggered = False - self.triggered_by = [] + pass def flag_for_host(self, host): - if not isinstance(host, Host): - raise AnsibleError('handlers expected to be triggered by a Host(), instead got %s' % type(host)) - if host.name not in self.triggered_by: - triggered_by.append(host.name) + assert instanceof(host, Host) + pass - def get_has_triggered(self): - return self.triggered + def has_triggered(self): + return self._triggered - def set_has_triggered(self, triggered): - if not isinstance(triggered, bool): - raise AnsibleError('a handlers triggered property should be a boolean, instead got %s' % type(triggered)) - self.triggered = triggered + def set_triggered(self, triggered): + assert instanceof(triggered, bool) + self._triggered = triggered diff --git a/lib/v2/playbook/role.py b/lib/v2/playbook/role.py index 80251833d06..0dd8817dbc9 100644 --- a/lib/v2/playbook/role.py +++ b/lib/v2/playbook/role.py @@ -19,19 +19,20 @@ from v2.playbook.base import PlaybookBase from v2.utils import list_union class Role(PlaybookBase): + def __init__(self): pass def load(self, ds): - self.ds = ds - self.tasks = [] - self.handlers = [] - self.blocks = [] - self.dependencies = [] - self.metadata = dict() - self.defaults = dict() - self.vars = dict() - self.params = dict() + self._ds = ds + self._tasks = [] + self._handlers = [] + self._blocks = [] + self._dependencies = [] + self._metadata = dict() + self._defaults = dict() + self._vars = dict() + self._params = dict() def get_vars(self): # returns the merged variables for this role, including @@ -39,13 +40,13 @@ class Role(PlaybookBase): return dict() def get_immediate_dependencies(self): - return self.dependencies + return self._dependencies def get_all_dependencies(self): # returns a list built recursively, of all deps from # all child dependencies all_deps = [] - for dep in self.dependencies: + for dep in self._dependencies: list_union(all_deps, dep.get_all_dependencies()) all_deps = list_union(all_deps, self.dependencies) return all_deps @@ -53,3 +54,5 @@ class Role(PlaybookBase): def get_blocks(self): # should return return self.blocks + +