Browse Source

Add stack_name support to ANSIBLE_INVENTORY

This change updates the ANSIBLE_INVENTORY constant to support stacks with different
names.

Change-Id: I601ff211d53a29dbda195cb2df8708e57efbcb94
Signed-off-by: Kevin Carter <kecarter@redhat.com>
changes/37/722337/5
Kevin Carter 2 years ago
parent
commit
329cad5794
No known key found for this signature in database
GPG Key ID: CE94BD890A47B20A
  1. 2
      tripleoclient/constants.py
  2. 24
      tripleoclient/tests/v2/overcloud_support/test_overcloud_support.py
  3. 7
      tripleoclient/v2/overcloud_support.py

2
tripleoclient/constants.py

@ -94,7 +94,7 @@ DEFAULT_WORK_DIR = os.path.join(os.environ.get('HOME', '~/'),
'config-download')
ANSIBLE_INVENTORY = os.path.join(DEFAULT_WORK_DIR,
'overcloud/tripleo-ansible-inventory.yaml')
'{}/tripleo-ansible-inventory.yaml')
ANSIBLE_VALIDATION_DIR = \
'/usr/share/openstack-tripleo-validations/playbooks'

24
tripleoclient/tests/v2/overcloud_support/test_overcloud_support.py

@ -14,9 +14,11 @@
#
import mock
import os
from osc_lib.tests import utils
from tripleoclient import constants
from tripleoclient.tests import fakes
from tripleoclient.v2 import overcloud_support
@ -66,3 +68,25 @@ class TestOvercloudSupportReport(utils.TestCommand):
'sos_destination': 'test'
}
)
@mock.patch('tripleoclient.utils.run_ansible_playbook',
autospec=True)
def test_overcloud_support_args_stack(self, mock_playbook):
arglist = ['server1', '--output', 'test', '--stack', 'notovercloud']
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
inv = os.path.join(
constants.DEFAULT_WORK_DIR,
'notovercloud/tripleo-ansible-inventory.yaml'
)
mock_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook='cli-support-collect-logs.yaml',
inventory=inv,
playbook_dir=mock.ANY,
verbosity=3,
extra_vars={
'server_name': 'server1',
'sos_destination': 'test'
}
)

7
tripleoclient/v2/overcloud_support.py

@ -34,6 +34,9 @@ class ReportExecute(command.Command):
' to match. For example "Controller" will'
' match all controllers for an'
' environment.'))
parser.add_argument('--stack',
help=_("Stack name to use for log collection."),
default='overcloud')
# Deprecated in U
parser.add_argument('-c',
'--container',
@ -90,7 +93,9 @@ class ReportExecute(command.Command):
with utils.TempDirs() as tmp:
utils.run_ansible_playbook(
playbook='cli-support-collect-logs.yaml',
inventory=constants.ANSIBLE_INVENTORY,
inventory=constants.ANSIBLE_INVENTORY.format(
parsed_args.stack
),
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
verbosity=utils.playbook_verbosity(self=self),

Loading…
Cancel
Save