コード例 #1
0
def load_system_facts(inventory_file, os_facts_path, env_vars, verbose=False):
    """
    Retrieves system facts from the remote systems.
    """
    installer_log.debug("Inside load_system_facts")
    installer_log.debug("load_system_facts will run with Ansible/Openshift environment variables:")
    debug_env(env_vars)

    FNULL = open(os.devnull, 'w')
    args = ['ansible-playbook', '-v'] if verbose \
        else ['ansible-playbook']
    args.extend([
        '--inventory-file={}'.format(inventory_file),
        os_facts_path])
    installer_log.debug("Going to subprocess out to ansible now with these args: %s", ' '.join(args))
    installer_log.debug("Subprocess will run with Ansible/Openshift environment variables:")
    debug_env(env_vars)
    status = subprocess.call(args, env=env_vars, stdout=FNULL)
    if status != 0:
        installer_log.debug("Exit status from subprocess was not 0")
        return [], 1

    with open(CFG.settings['ansible_callback_facts_yaml'], 'r') as callback_facts_file:
        installer_log.debug("Going to try to read this file: %s", CFG.settings['ansible_callback_facts_yaml'])
        try:
            callback_facts = yaml.safe_load(callback_facts_file)
        except yaml.YAMLError as exc:
            print("Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc)
            print("Try deleting and rerunning the atomic-openshift-installer")
            sys.exit(1)

    return callback_facts, 0
コード例 #2
0
def run_ansible(playbook, inventory, env_vars, verbose=False):
    installer_log.debug("run_ansible will run with Ansible/Openshift environment variables:")
    debug_env(env_vars)

    args = ["ansible-playbook", "-v"] if verbose else ["ansible-playbook"]
    args.extend(["--inventory-file={}".format(inventory), playbook])
    installer_log.debug("Going to subprocess out to ansible now with these args: %s", " ".join(args))
    return subprocess.call(args, env=env_vars)
コード例 #3
0
ファイル: test_utils.py プロジェクト: PyRoOP/open
    def test_utils_debug_env_all_debugged(self):
        """Verify debug_env debugs specific env variables"""

        with mock.patch('ooinstall.utils.installer_log') as _il:
            debug_env(self.debug_all_params)

            # Debug was called for each item we expect
            self.assertEqual(len(self.debug_all_params), _il.debug.call_count)

            # Each item we expect was logged
            six.assertCountEqual(self, self.expected, _il.debug.call_args_list)
コード例 #4
0
def run_ansible(playbook, inventory, env_vars, verbose=False):
    installer_log.debug("run_ansible will run with Ansible/Openshift environment variables:")
    debug_env(env_vars)

    args = ['ansible-playbook', '-v'] if verbose \
        else ['ansible-playbook']
    args.extend([
        '--inventory-file={}'.format(inventory),
        playbook])
    installer_log.debug("Going to subprocess out to ansible now with these args: %s", ' '.join(args))
    return subprocess.call(args, env=env_vars)
コード例 #5
0
ファイル: test_utils.py プロジェクト: PyRoOP/open
    def test_utils_debug_env_some_debugged(self):
        """Verify debug_env skips non-wanted env variables"""
        debug_some_params = copy.deepcopy(self.debug_all_params)
        # This will not be logged by debug_env
        debug_some_params['MG_FRBBR'] = "SKIPPED"

        with mock.patch('ooinstall.utils.installer_log') as _il:
            debug_env(debug_some_params)

            # The actual number of debug calls was less than the
            # number of items passed to debug_env
            self.assertLess(_il.debug.call_count, len(debug_some_params))

            six.assertCountEqual(self, self.expected, _il.debug.call_args_list)
コード例 #6
0
    def test_utils_debug_env_all_debugged(self):
        """Verify debug_env debugs specific env variables"""

        with mock.patch('ooinstall.utils.installer_log') as _il:
            debug_env(self.debug_all_params)

            # Debug was called for each item we expect
            self.assertEqual(
                len(self.debug_all_params),
                _il.debug.call_count)

            # Each item we expect was logged
            six.assertCountEqual(
                self,
                self.expected,
                _il.debug.call_args_list)
コード例 #7
0
    def test_utils_debug_env_some_debugged(self):
        """Verify debug_env skips non-wanted env variables"""
        debug_some_params = copy.deepcopy(self.debug_all_params)
        # This will not be logged by debug_env
        debug_some_params['MG_FRBBR'] = "SKIPPED"

        with mock.patch('ooinstall.utils.installer_log') as _il:
            debug_env(debug_some_params)

            # The actual number of debug calls was less than the
            # number of items passed to debug_env
            self.assertLess(
                _il.debug.call_count,
                len(debug_some_params))

            self.assertItemsEqual(
                self.expected,
                _il.debug.call_args_list)