Пример #1
0
    def __init__(self, *arguments, **keyword_arguments):

        self.support = importlib.import_module(
            os.environ["GRIDLINKER_SUPPORT"]).support

        self.context = self.support.get_context()

        ActionBase.__init__(self, *arguments, **keyword_arguments)
Пример #2
0
 def __init__(self, *n, **kw):
     # force 'no_log' to be true, since we want to return the private key as
     # a result variable and don't ever want it logged.
     # TODO: clearner way to do this?
     ctx = kw.get('play_context')
     if ctx:
         ctx.no_log = True
     ActionBase.__init__(self, *n, **kw)
Пример #3
0
    def test_sudo_only_if_user_differs(self):
        play_context = PlayContext()
        action_base = ActionBase(None, None, play_context, None, None, None)
        action_base._connection = Mock(exec_command=Mock(return_value=(0, '',
                                                                       '')))

        play_context.become = True
        play_context.become_user = play_context.remote_user = '******'
        play_context.make_become_cmd = Mock(return_value='CMD')

        action_base._low_level_execute_command('ECHO', sudoable=True)
        play_context.make_become_cmd.assert_not_called()

        play_context.remote_user = '******'
        action_base._low_level_execute_command('ECHO', sudoable=True)
        play_context.make_become_cmd.assert_called_once_with('ECHO',
                                                             executable=None)

        play_context.make_become_cmd.reset_mock()

        become_allow_same_user = C.BECOME_ALLOW_SAME_USER
        C.BECOME_ALLOW_SAME_USER = True
        try:
            play_context.remote_user = '******'
            action_base._low_level_execute_command('ECHO SAME', sudoable=True)
            play_context.make_become_cmd.assert_called_once_with(
                'ECHO SAME', executable=None)
        finally:
            C.BECOME_ALLOW_SAME_USER = become_allow_same_user
	def __init__ (self, * arguments, ** keyword_arguments):

		self.support = importlib.import_module (
			os.environ ["GRIDLINKER_SUPPORT"]).support

		self.context = self.support.get_context ()

		ActionBase.__init__ (
			self,
			* arguments,
			** keyword_arguments)
Пример #5
0
    def test_sudo_only_if_user_differs(self):
        play_context = PlayContext()
        action_base = ActionBase(None, None, play_context, None, None, None)
        action_base._connection = Mock(exec_command=Mock(return_value=(0, '', '')))

        play_context.become = True
        play_context.become_user = play_context.remote_user = '******'
        play_context.make_become_cmd = Mock(return_value='CMD')

        action_base._low_level_execute_command('ECHO', sudoable=True)
        play_context.make_become_cmd.assert_not_called()

        play_context.remote_user = '******'
        action_base._low_level_execute_command('ECHO', sudoable=True)
        play_context.make_become_cmd.assert_called_once_with('ECHO', executable=None)

        play_context.make_become_cmd.reset_mock()

        become_allow_same_user = C.BECOME_ALLOW_SAME_USER
        C.BECOME_ALLOW_SAME_USER = True
        try:
            play_context.remote_user = '******'
            action_base._low_level_execute_command('ECHO SAME', sudoable=True)
            play_context.make_become_cmd.assert_called_once_with('ECHO SAME', executable=None)
        finally:
            C.BECOME_ALLOW_SAME_USER = become_allow_same_user
Пример #6
0
    def __init__(self, *args, **kwargs):
        ActionBase.__init__(self, *args, **kwargs)
        self._supports_async = True

        if not self.NAME:
            raise Exception("Module name was not yet set")

        # Determine what is the target platform and choose the binary module accordingly
        if self.BINARY:
            platform = self._low_level_execute_command("uname -sm")
            if platform["rc"]:
                raise Exception(platform["stderr"])
            sysarch = platform["stdout"].lower().strip().split(" ")
            if len(sysarch) == 2:
                system, arch = sysarch
            else:
                raise Exception("Unknown platform: {}".format(
                    platform["stdout"]))
        else:
            system, arch = "any", "noarch"

        self.module_name = "{}-{}-{}".format(self.NAME, system, arch)
Пример #7
0
    def run(self, tmp=None, task_vars=None):
        """
        Call a binary module according to the platform specifics.
        """
        if not task_vars:
            task_vars = {}

        result = ActionBase.run(self, tmp=tmp, task_vars=task_vars)
        result.update(
            self._execute_module(module_name=self.module_name,
                                 module_args=self._task.args,
                                 task_vars=task_vars,
                                 wrap_async=self._task.async_val))

        return result
Пример #8
0
 def check_unparsable_filter_non_json_lines(self, stdout_line):
     ActionBase._filter_non_json_lines(stdout_line)
Пример #9
0
 def check_filter_non_json_lines(self, stdout_line, parsed):
     eq_(parsed, ActionBase._filter_non_json_lines(stdout_line))
Пример #10
0
 def check_unparsable_filter_non_json_lines(self, stdout_line):
     ActionBase._filter_non_json_lines(stdout_line)
Пример #11
0
 def check_filter_non_json_lines(self, stdout_line, parsed):
     eq_(parsed, ActionBase._filter_non_json_lines(stdout_line))
Пример #12
0
 def __init__(self, *n, **kw):
     ctx = kw.get('play_context')
     if ctx:
         ctx.no_log = False
     ActionBase.__init__(self, *n, **kw)
Пример #13
0
 def __init__(self, *args, **kw):
     ActionBase.__init__(self, *args, **kw)
Пример #14
0
 def __init__(self, *args, **kwargs):
   ActionBase.__init__(self, *args, **kwargs)
   AnsSpaceAndArgsPlugin.__init__(self)
   self._ansvar_updates = {}