Merge "Add --stack to update, upgrade and ffwd-upgrade 'run' CLI."
This commit is contained in:
commit
4020387ff0
@ -738,3 +738,32 @@ class ProcessMultipleEnvironments(TestCase):
|
|||||||
|
|
||||||
mock_yaml_dump.assert_has_calls([mock.call(rewritten_env,
|
mock_yaml_dump.assert_has_calls([mock.call(rewritten_env,
|
||||||
default_flow_style=False)])
|
default_flow_style=False)])
|
||||||
|
|
||||||
|
|
||||||
|
class GetTripleoAnsibleInventory(TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(GetTripleoAnsibleInventory, self).setUp()
|
||||||
|
self.inventory_file = ''
|
||||||
|
self.ssh_user = 'heat_admin'
|
||||||
|
self.stack = 'foo-overcloud'
|
||||||
|
|
||||||
|
@mock.patch('tripleoclient.utils.get_tripleo_ansible_inventory',
|
||||||
|
autospec=True)
|
||||||
|
def test_get_tripleo_ansible_inventory(self, mock_inventory):
|
||||||
|
|
||||||
|
with mock.patch('os.path.exists') as mock_exists:
|
||||||
|
mock_exists.return_value = True
|
||||||
|
|
||||||
|
self.cmd = utils.get_tripleo_ansible_inventory(
|
||||||
|
inventory_file=self.inventory_file,
|
||||||
|
ssh_user=self.ssh_user,
|
||||||
|
stack=self.stack)
|
||||||
|
|
||||||
|
self.cmd.take_action()
|
||||||
|
|
||||||
|
mock_inventory.assert_called_once_with(
|
||||||
|
inventory_file='',
|
||||||
|
ssh_user='heat_admin',
|
||||||
|
stack='foo-overcloud'
|
||||||
|
)
|
||||||
|
@ -834,13 +834,16 @@ def load_environment_directories(directories):
|
|||||||
return environments
|
return environments
|
||||||
|
|
||||||
|
|
||||||
def get_tripleo_ansible_inventory(inventory_file='', ssh_user='heat-admin'):
|
def get_tripleo_ansible_inventory(inventory_file='',
|
||||||
|
ssh_user='heat-admin',
|
||||||
|
stack='overcloud'):
|
||||||
if not inventory_file:
|
if not inventory_file:
|
||||||
inventory_file = '%s/%s' % (os.path.expanduser('~'),
|
inventory_file = '%s/%s' % (os.path.expanduser('~'),
|
||||||
'tripleo-ansible-inventory.yaml')
|
'tripleo-ansible-inventory.yaml')
|
||||||
try:
|
try:
|
||||||
processutils.execute(
|
processutils.execute(
|
||||||
'/usr/bin/tripleo-ansible-inventory',
|
'/usr/bin/tripleo-ansible-inventory',
|
||||||
|
'--stack', stack,
|
||||||
'--ansible_ssh_user', ssh_user,
|
'--ansible_ssh_user', ssh_user,
|
||||||
'--static-yaml-inventory', inventory_file)
|
'--static-yaml-inventory', inventory_file)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
from osc_lib import utils
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
from tripleoclient import constants
|
from tripleoclient import constants
|
||||||
@ -133,6 +134,12 @@ class FFWDUpgradeRun(command.Command):
|
|||||||
help=_("The ssh user name for connecting to "
|
help=_("The ssh user name for connecting to "
|
||||||
"the overcloud nodes.")
|
"the overcloud nodes.")
|
||||||
)
|
)
|
||||||
|
parser.add_argument('--stack', dest='stack',
|
||||||
|
help=_('Name or ID of heat stack '
|
||||||
|
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||||
|
default=utils.env('OVERCLOUD_STACK_NAME',
|
||||||
|
default='overcloud')
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -140,9 +147,11 @@ class FFWDUpgradeRun(command.Command):
|
|||||||
oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log)
|
oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log)
|
||||||
|
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
|
stack = parsed_args.stack
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
parsed_args.static_inventory)
|
parsed_args.static_inventory, stack)
|
||||||
# Don't expost limit_hosts. We need this on the whole overcloud.
|
# Don't expost limit_hosts. We need this on the whole overcloud.
|
||||||
limit_hosts = ''
|
limit_hosts = ''
|
||||||
oooutils.run_update_ansible_action(
|
oooutils.run_update_ansible_action(
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
from osc_lib import utils
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
from tripleoclient import constants
|
from tripleoclient import constants
|
||||||
@ -138,11 +139,19 @@ class UpdateRun(command.Command):
|
|||||||
'generated in '
|
'generated in '
|
||||||
'~/tripleo-ansible-inventory.yaml')
|
'~/tripleo-ansible-inventory.yaml')
|
||||||
)
|
)
|
||||||
|
parser.add_argument('--stack', dest='stack',
|
||||||
|
help=_('Name or ID of heat stack '
|
||||||
|
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||||
|
default=utils.env('OVERCLOUD_STACK_NAME',
|
||||||
|
default='overcloud')
|
||||||
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug("take_action(%s)" % parsed_args)
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
|
stack = parsed_args.stack
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
nodes = parsed_args.nodes
|
nodes = parsed_args.nodes
|
||||||
@ -151,7 +160,7 @@ class UpdateRun(command.Command):
|
|||||||
nodes = None
|
nodes = None
|
||||||
playbook = parsed_args.playbook
|
playbook = parsed_args.playbook
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
parsed_args.static_inventory, parsed_args.ssh_user)
|
parsed_args.static_inventory, parsed_args.ssh_user, stack)
|
||||||
oooutils.run_update_ansible_action(self.log, clients, nodes, inventory,
|
oooutils.run_update_ansible_action(self.log, clients, nodes, inventory,
|
||||||
playbook, constants.UPDATE_QUEUE,
|
playbook, constants.UPDATE_QUEUE,
|
||||||
constants.MINOR_UPDATE_PLAYBOOKS,
|
constants.MINOR_UPDATE_PLAYBOOKS,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
from osc_lib import utils
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
from tripleoclient import constants
|
from tripleoclient import constants
|
||||||
@ -177,6 +178,12 @@ class UpgradeRun(command.Command):
|
|||||||
'upgrade and some services cannot be '
|
'upgrade and some services cannot be '
|
||||||
'started. ')
|
'started. ')
|
||||||
)
|
)
|
||||||
|
parser.add_argument('--stack', dest='stack',
|
||||||
|
help=_('Name or ID of heat stack '
|
||||||
|
'(default=Env: OVERCLOUD_STACK_NAME)'),
|
||||||
|
default=utils.env('OVERCLOUD_STACK_NAME',
|
||||||
|
default='overcloud'))
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def _validate_skip_tags(self, skip_tags):
|
def _validate_skip_tags(self, skip_tags):
|
||||||
@ -192,13 +199,15 @@ class UpgradeRun(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug("take_action(%s)" % parsed_args)
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
|
stack = parsed_args.stack
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
roles = parsed_args.roles
|
roles = parsed_args.roles
|
||||||
nodes = parsed_args.nodes
|
nodes = parsed_args.nodes
|
||||||
limit_hosts = roles or nodes
|
limit_hosts = roles or nodes
|
||||||
playbook = parsed_args.playbook
|
playbook = parsed_args.playbook
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
parsed_args.static_inventory, parsed_args.ssh_user)
|
parsed_args.static_inventory, parsed_args.ssh_user, stack)
|
||||||
skip_tags = self._validate_skip_tags(parsed_args.skip_tags)
|
skip_tags = self._validate_skip_tags(parsed_args.skip_tags)
|
||||||
oooutils.run_update_ansible_action(self.log, clients, limit_hosts,
|
oooutils.run_update_ansible_action(self.log, clients, limit_hosts,
|
||||||
inventory, playbook,
|
inventory, playbook,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user