Exemple #1
0
 def test_run_command_quiet(self, mock_call, mock_open):
     mock_devnull = mock_open.return_value.__enter__.return_value
     output = utils.run_command(["command", "to", "run"], quiet=True)
     mock_call.assert_called_once_with(["command", "to", "run"],
                                       stdout=mock_devnull,
                                       stderr=mock_devnull)
     self.assertIsNone(output)
Exemple #2
0
def run_playbooks(parsed_args,
                  playbooks,
                  extra_vars=None,
                  limit=None,
                  tags=None,
                  quiet=False,
                  verbose_level=None,
                  check=None):
    """Run a JavaRole Ansible playbook."""
    _validate_args(parsed_args, playbooks)
    cmd = build_args(parsed_args,
                     playbooks,
                     extra_vars=extra_vars,
                     limit=limit,
                     tags=tags,
                     verbose_level=verbose_level,
                     check=check)
    try:
        utils.run_command(cmd, quiet=quiet)
    except subprocess.CalledProcessError as e:
        LOG.error("JavaRole playbook(s) %s exited %d", ", ".join(playbooks),
                  e.returncode)
        sys.exit(e.returncode)
Exemple #3
0
def run(parsed_args,
        command,
        inventory_filename,
        extra_vars=None,
        tags=None,
        quiet=False,
        verbose_level=None,
        extra_args=None,
        limit=None):
    """Run a Kolla Ansible command."""
    _validate_args(parsed_args, inventory_filename)
    cmd = build_args(parsed_args,
                     command,
                     inventory_filename=inventory_filename,
                     extra_vars=extra_vars,
                     tags=tags,
                     verbose_level=verbose_level,
                     extra_args=extra_args,
                     limit=limit)
    try:
        utils.run_command(" ".join(cmd), quiet=quiet, shell=True)
    except subprocess.CalledProcessError as e:
        LOG.error("lordoftheflies-ansible %s exited %d", command, e.returncode)
        sys.exit(e.returncode)
Exemple #4
0
 def test_run_command_check_output(self, mock_output):
     mock_output.return_value = "command output"
     output = utils.run_command(["command", "to", "run"], check_output=True)
     mock_output.assert_called_once_with(["command", "to", "run"])
     self.assertEqual(output, "command output")
Exemple #5
0
 def test_run_command(self, mock_call):
     output = utils.run_command(["command", "to", "run"])
     mock_call.assert_called_once_with(["command", "to", "run"])
     self.assertIsNone(output)