예제 #1
0
    def test_positive_use_alternate_directory(self, fixture_vmsetup,
                                              module_org, default_sat):
        """Use alternate working directory on client to execute rex jobs

        :id: a0181f18-d3dc-4bd9-a2a6-430c2a49809e

        :expectedresults: Verify the job was successfully ran against the host

        :customerscenario: true

        :parametrized: yes
        """
        client = fixture_vmsetup
        testdir = gen_string('alpha')
        result = client.run(f'mkdir /{testdir}')
        assert result.status == 0
        result = client.run(f'chcon --reference=/var /{testdir}')
        assert result.status == 0
        result = default_sat.execute(
            f"sed -i r's/^:remote_working_dir:.*/:remote_working_dir: \\/{testdir}/' \
            /etc/foreman-proxy/settings.d/remote_execution_ssh.yml", )
        assert result.status == 0
        result = default_sat.execute('systemctl restart foreman-proxy')
        assert result.status == 0

        command = f'echo {gen_string("alpha")}'
        invocation_command = make_job_invocation({
            'job-template':
            'Run Command - SSH Default',
            'inputs':
            f'command={command}',
            'search-query':
            f"name ~ {client.hostname}",
        })
        result = JobInvocation.info({'id': invocation_command['id']})
        try:
            assert result['success'] == '1'
        except AssertionError:
            output = ' '.join(
                JobInvocation.get_output({
                    'id': invocation_command['id'],
                    'host': client.hostname
                }))
            result = f'host output: {output}'
            raise AssertionError(result)

        task = Task.list_tasks({"search": command})[0]
        search = Task.list_tasks({"search": f'id={task["id"]}'})
        assert search[0]["action"] == task["action"]
예제 #2
0
    def test_positive_run_default_job_template_by_ip(self, fixture_vmsetup, fixture_org):
        """Run default template on host connected by ip and list task

        :id: 811c7747-bec6-4a2d-8e5c-b5045d3fbc0d

        :expectedresults: Verify the job was successfully ran against the host
            and task can be listed by name and ID

        :BZ: 1647582

        :parametrized: yes
        """
        self.org = fixture_org
        self.client = fixture_vmsetup
        # set connecting to host via ip
        Host.set_parameter(
            {
                'host': self.client.hostname,
                'name': 'remote_execution_connect_by_ip',
                'value': 'True',
            }
        )
        command = "echo {}".format(gen_string('alpha'))
        invocation_command = make_job_invocation(
            {
                'job-template': 'Run Command - SSH Default',
                'inputs': f'command={command}',
                'search-query': f"name ~ {self.client.hostname}",
            }
        )

        try:
            assert invocation_command['success'] == '1'
        except AssertionError:
            result = 'host output: {}'.format(
                ' '.join(
                    JobInvocation.get_output(
                        {'id': invocation_command['id'], 'host': self.client.hostname}
                    )
                )
            )
            raise AssertionError(result)

        task = Task.list_tasks({"search": command})[0]
        search = Task.list_tasks({"search": 'id={}'.format(task["id"])})
        assert search[0]["action"] == task["action"]
예제 #3
0
    def test_positive_run_default_job_template_by_ip(self, rex_contenthost):
        """Run default template on host connected by ip and list task

        :id: 811c7747-bec6-4a2d-8e5c-b5045d3fbc0d

        :expectedresults: Verify the job was successfully ran against the host
            and task can be listed by name and ID

        :BZ: 1647582

        :customerscenario: true

        :parametrized: yes
        """
        client = rex_contenthost
        command = f'echo {gen_string("alpha")}'
        invocation_command = make_job_invocation({
            'job-template':
            'Run Command - SSH Default',
            'inputs':
            f'command={command}',
            'search-query':
            f"name ~ {client.hostname}",
        })
        result = JobInvocation.info({'id': invocation_command['id']})
        try:
            assert result['success'] == '1'
        except AssertionError:
            result = 'host output: {}'.format(' '.join(
                JobInvocation.get_output({
                    'id': invocation_command['id'],
                    'host': client.hostname
                })))
            raise AssertionError(result)

        task = Task.list_tasks({'search': command})[0]
        search = Task.list_tasks({'search': f'id={task["id"]}'})
        assert search[0]['action'] == task['action']