Add overcloud update command
Allows running step-through stack update, which triggers yum update on each node and removes hooks one-by-one. This patch depends on: https://review.openstack.org/#/c/179862/ Change-Id: Icec12a0ee5ce3bf7b1f8906d4a6f26b8de72c6e6
This commit is contained in:
parent
8d6e75e812
commit
43e5a48ddb
rdomanager_oscplugin
setup.cfg
48
rdomanager_oscplugin/tests/v1/overcloud_update/fakes.py
Normal file
48
rdomanager_oscplugin/tests/v1/overcloud_update/fakes.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import mock
|
||||
from openstackclient.tests import utils
|
||||
|
||||
|
||||
class FakeClientWrapper(object):
|
||||
|
||||
def __init__(self):
|
||||
self._instance = mock.Mock()
|
||||
self._orchestration = None
|
||||
self._management = None
|
||||
|
||||
def orchestration(self):
|
||||
|
||||
if self._orchestration is None:
|
||||
self._orchestration = mock.Mock()
|
||||
|
||||
return self._orchestration
|
||||
|
||||
def management(self):
|
||||
|
||||
if self._management is None:
|
||||
self._management = mock.Mock()
|
||||
|
||||
return self._management
|
||||
|
||||
|
||||
class TestOvercloudUpdate(utils.TestCommand):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOvercloudUpdate, self).setUp()
|
||||
|
||||
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
|
||||
self.app.client_manager.rdomanager_oscplugin = FakeClientWrapper()
|
@ -0,0 +1,44 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import mock
|
||||
|
||||
from rdomanager_oscplugin.tests.v1.overcloud_update import fakes
|
||||
from rdomanager_oscplugin.v1 import overcloud_update
|
||||
|
||||
|
||||
class TestOvercloudUpdate(fakes.TestOvercloudUpdate):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOvercloudUpdate, self).setUp()
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_update.UpdateOvercloud(self.app, None)
|
||||
|
||||
@mock.patch('tripleo_common.update.PackageUpdateManager')
|
||||
def test_update_out(self, update_manager):
|
||||
update_manager.return_value.get_status.return_value = (
|
||||
'UPDATE_COMPLETE', {})
|
||||
argslist = ['-i', '--plan', 'overcloud', 'overcloud']
|
||||
verifylist = [
|
||||
('stack', 'overcloud'),
|
||||
('plan', 'overcloud'),
|
||||
('interactive', True),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
update_manager.get_status.called_once()
|
||||
update_manager.update.called_once()
|
||||
update_manager.do_interactive_update.called_once()
|
70
rdomanager_oscplugin/v1/overcloud_update.py
Normal file
70
rdomanager_oscplugin/v1/overcloud_update.py
Normal file
@ -0,0 +1,70 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
||||
from cliff import command
|
||||
from openstackclient.common import utils
|
||||
from tripleo_common import update
|
||||
|
||||
|
||||
class UpdateOvercloud(command.Command):
|
||||
"""Updates packages on overcloud nodes"""
|
||||
|
||||
auth_required = False
|
||||
log = logging.getLogger(__name__ + ".UpdateOvercloud")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UpdateOvercloud, self).get_parser(prog_name)
|
||||
parser.add_argument('stack', nargs='?',
|
||||
help='Name or ID of heat stack to scale '
|
||||
'(default=Env: OVERCLOUD_STACK_NAME)',
|
||||
default=utils.env('OVERCLOUD_STACK_NAME'))
|
||||
parser.add_argument('--plan', dest='plan',
|
||||
help='Name or ID of tuskar plan to scale '
|
||||
'(default=Env: OVERCLOUD_PLAN_NAME)',
|
||||
default=utils.env('OVERCLOUD_PLAN_NAME'))
|
||||
parser.add_argument('-i', '--interactive', dest='interactive',
|
||||
action='store_true')
|
||||
parser.add_argument('-a', '--abort', dest='abort_update',
|
||||
action='store_true')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
management = self.app.client_manager.rdomanager_oscplugin.management()
|
||||
orchestration = (self.app.client_manager.rdomanager_oscplugin.
|
||||
orchestration())
|
||||
update_manager = update.PackageUpdateManager(
|
||||
tuskarclient=management,
|
||||
heatclient=orchestration,
|
||||
novaclient=self.app.client_manager.compute,
|
||||
plan_id=parsed_args.plan,
|
||||
stack_id=parsed_args.stack)
|
||||
if parsed_args.abort_update:
|
||||
print("cancelling package update on stack {0}".format(
|
||||
parsed_args.stack))
|
||||
update_manager.cancel()
|
||||
else:
|
||||
status, resources = update_manager.get_status()
|
||||
if status not in ['IN_PROGRESS', 'WAITING']:
|
||||
print("starting package update on stack {0}".format(
|
||||
parsed_args.stack))
|
||||
update_manager.update()
|
||||
|
||||
if parsed_args.interactive:
|
||||
update_manager.do_interactive_update()
|
||||
else:
|
||||
print("stack {0} status: {1}".format(parsed_args.stack, status))
|
@ -64,4 +64,5 @@ openstack.rdomanager_oscplugin.v1 =
|
||||
overcloud_image_build = rdomanager_oscplugin.v1.overcloud_image:BuildOvercloudImage
|
||||
overcloud_image_create = rdomanager_oscplugin.v1.overcloud_image:CreateOvercloud
|
||||
overcloud_scale_stack = rdomanager_oscplugin.v1.overcloud_scale:ScaleOvercloud
|
||||
overcloud_update_stack = rdomanager_oscplugin.v1.overcloud_update:UpdateOvercloud
|
||||
undercloud_install = rdomanager_oscplugin.v1.undercloud:InstallPlugin
|
||||
|
Loading…
x
Reference in New Issue
Block a user