Exemplo n.º 1
0
 def check(self):
     """
     This is dry-run mode
     """
     executor = Executor(self._policies, tags=self._tags)
     contexts = executor.check()
     return contexts
Exemplo n.º 2
0
 def apply(self):
     """
     This is live-configuration mode.
     """
     executor = Executor(self._policies, tags=self._tags)
     contexts = executor.apply()
     return contexts
Exemplo n.º 3
0
 def apply(self):
     """
     This is live-configuration mode.
     """
     executor = Executor(policies=self._policies, callbacks=self._callbacks)
     contexts = executor.apply()
     return contexts
Exemplo n.º 4
0
 def check(self):
     """
     This is dry-run mode
     """
     executor = Executor(policies=self._policies, callbacks=self._callbacks)
     contexts = executor.check()
     return contexts
Exemplo n.º 5
0
 def validate(self):
     """
     This just checks for invalid types in the python file as well as missing files
     and non-sensical option combinations.
     """
     executor = Executor(self._policies, tags=self._tags)
     contexts = executor.validate()
     return contexts
Exemplo n.º 6
0
Arquivo: api.py Projeto: toshok/opsmop
 def get_executor(self):
     return Executor(self._policies,
                     push=self._push,
                     extra_vars=self._extra_vars,
                     limit_groups=self._limit_groups,
                     limit_hosts=self._limit_hosts,
                     relative_root=self._relative_root)
Exemplo n.º 7
0
def remote_fn(caller, params, sender):
    """
    This is the remote function used for mitogen calls
    """

    # FIXME: REFACTOR: we have a bit of a growing inconsistency between what is a constructor parameter and what is passed around in Context.
    # we should change this to have context objects that have more meat, but also get passed around versus acting globally, and smaller
    # function signatures across the board.

    import dill
    from opsmop.core.executor import Executor

    params = dill.loads(zlib.decompress(params))

    host = params['host']
    policy = params['policy']
    role = params['role']
    mode = params['mode']
    tags = params['tags']
    checksums = params['checksums']
    relative_root = params['relative_root']
    hostvars = params['hostvars']
    extra_vars = params['extra_vars']

    Context().set_mode(mode)
    Context().set_caller(caller)
    assert relative_root is not None
    Context().set_checksums(checksums)

    Context().update_globals(hostvars)

    policy.roles = Roles(role)

    Callbacks().set_callbacks([
        EventStreamCallbacks(sender=sender),
        LocalCliCallbacks(),
        CommonCallbacks()
    ])
    executor = Executor([policy],
                        local_host=host,
                        push=False,
                        tags=params['tags'],
                        extra_vars=extra_vars,
                        relative_root=relative_root)  # remove single_role
    # FIXME: care about mode
    executor.apply()
Exemplo n.º 8
0
 def apply(self):
     """
     This is live-configuration mode.
     """
     return Executor(policies=self._policies, local=False).apply()
Exemplo n.º 9
0
 def check(self):
     """
     This is dry-run mode
     """
     return Executor(policies=self._policies, local=False).check()