Some signature related things, prior to starting test scaffolding
This commit is contained in:
parent
b8e4e59d6b
commit
7ebf246ff1
4 changed files with 26 additions and 38 deletions
|
@ -15,13 +15,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from v2.playbook import Tag, Conditional
|
class Base(object):
|
||||||
|
|
||||||
class PlaybookBase(Tag, Conditional):
|
|
||||||
'''
|
|
||||||
Implements a common object, which supports filtering based on
|
|
||||||
both tags and when: conditional statements
|
|
||||||
'''
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -18,13 +18,7 @@
|
||||||
from v2.playbook.base import PlaybookBase
|
from v2.playbook.base import PlaybookBase
|
||||||
|
|
||||||
class Block(PlaybookBase):
|
class Block(PlaybookBase):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ds = None
|
pass
|
||||||
self.plays = []
|
|
||||||
|
|
||||||
def load(self, ds):
|
|
||||||
self.ds = ds
|
|
||||||
self.plays = []
|
|
||||||
|
|
||||||
def get_plays(self):
|
|
||||||
return self.plays
|
|
||||||
|
|
|
@ -20,20 +20,17 @@ from v2.inventory import Host
|
||||||
from v2.playbook import Task
|
from v2.playbook import Task
|
||||||
|
|
||||||
class Handler(Task):
|
class Handler(Task):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.triggered = False
|
pass
|
||||||
self.triggered_by = []
|
|
||||||
|
|
||||||
def flag_for_host(self, host):
|
def flag_for_host(self, host):
|
||||||
if not isinstance(host, Host):
|
assert instanceof(host, Host)
|
||||||
raise AnsibleError('handlers expected to be triggered by a Host(), instead got %s' % type(host))
|
pass
|
||||||
if host.name not in self.triggered_by:
|
|
||||||
triggered_by.append(host.name)
|
|
||||||
|
|
||||||
def get_has_triggered(self):
|
def has_triggered(self):
|
||||||
return self.triggered
|
return self._triggered
|
||||||
|
|
||||||
def set_has_triggered(self, triggered):
|
def set_triggered(self, triggered):
|
||||||
if not isinstance(triggered, bool):
|
assert instanceof(triggered, bool)
|
||||||
raise AnsibleError('a handlers triggered property should be a boolean, instead got %s' % type(triggered))
|
self._triggered = triggered
|
||||||
self.triggered = triggered
|
|
||||||
|
|
|
@ -19,19 +19,20 @@ from v2.playbook.base import PlaybookBase
|
||||||
from v2.utils import list_union
|
from v2.utils import list_union
|
||||||
|
|
||||||
class Role(PlaybookBase):
|
class Role(PlaybookBase):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def load(self, ds):
|
def load(self, ds):
|
||||||
self.ds = ds
|
self._ds = ds
|
||||||
self.tasks = []
|
self._tasks = []
|
||||||
self.handlers = []
|
self._handlers = []
|
||||||
self.blocks = []
|
self._blocks = []
|
||||||
self.dependencies = []
|
self._dependencies = []
|
||||||
self.metadata = dict()
|
self._metadata = dict()
|
||||||
self.defaults = dict()
|
self._defaults = dict()
|
||||||
self.vars = dict()
|
self._vars = dict()
|
||||||
self.params = dict()
|
self._params = dict()
|
||||||
|
|
||||||
def get_vars(self):
|
def get_vars(self):
|
||||||
# returns the merged variables for this role, including
|
# returns the merged variables for this role, including
|
||||||
|
@ -39,13 +40,13 @@ class Role(PlaybookBase):
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
def get_immediate_dependencies(self):
|
def get_immediate_dependencies(self):
|
||||||
return self.dependencies
|
return self._dependencies
|
||||||
|
|
||||||
def get_all_dependencies(self):
|
def get_all_dependencies(self):
|
||||||
# returns a list built recursively, of all deps from
|
# returns a list built recursively, of all deps from
|
||||||
# all child dependencies
|
# all child dependencies
|
||||||
all_deps = []
|
all_deps = []
|
||||||
for dep in self.dependencies:
|
for dep in self._dependencies:
|
||||||
list_union(all_deps, dep.get_all_dependencies())
|
list_union(all_deps, dep.get_all_dependencies())
|
||||||
all_deps = list_union(all_deps, self.dependencies)
|
all_deps = list_union(all_deps, self.dependencies)
|
||||||
return all_deps
|
return all_deps
|
||||||
|
@ -53,3 +54,5 @@ class Role(PlaybookBase):
|
||||||
def get_blocks(self):
|
def get_blocks(self):
|
||||||
# should return
|
# should return
|
||||||
return self.blocks
|
return self.blocks
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue