Merge "Fix upgrade/external_update/external_upgrade" into stable/wallaby
This commit is contained in:
commit
54b8e336c6
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
The --static-inventory argument to the openstack update/upgrade commands
|
||||||
|
has been deprecated and would be ignored. The inventory generated in
|
||||||
|
work_dir with update/upgrade prepare would be used instead.
|
@ -18,8 +18,6 @@ import logging
|
|||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions as oscexc
|
from osc_lib import exceptions as oscexc
|
||||||
|
|
||||||
from tripleo_common.utils import config
|
|
||||||
|
|
||||||
from tripleoclient import exceptions
|
from tripleoclient import exceptions
|
||||||
from tripleoclient import utils
|
from tripleoclient import utils
|
||||||
|
|
||||||
@ -38,28 +36,6 @@ class Command(command.Command):
|
|||||||
self.log.exception("Exception occured while running the command")
|
self.log.exception("Exception occured while running the command")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_ansible_key_and_dir(stack, orchestration):
|
|
||||||
"""Return the ansible directory and key path.
|
|
||||||
|
|
||||||
:oaram stack: Name of a given stack to run against.
|
|
||||||
:type stack: String
|
|
||||||
|
|
||||||
:param orchestration: Orchestration client object.
|
|
||||||
:type orchestration: Object
|
|
||||||
|
|
||||||
:returns: Tuple
|
|
||||||
"""
|
|
||||||
key = utils.get_key(stack=stack)
|
|
||||||
stack_config = config.Config(orchestration)
|
|
||||||
with utils.TempDirs(chdir=False) as tmp:
|
|
||||||
stack_config.write_config(
|
|
||||||
stack_config.fetch_config(stack),
|
|
||||||
stack,
|
|
||||||
tmp
|
|
||||||
)
|
|
||||||
return key, tmp
|
|
||||||
|
|
||||||
def get_key_pair(self, parsed_args):
|
def get_key_pair(self, parsed_args):
|
||||||
"""Autodetect or return a user defined key file.
|
"""Autodetect or return a user defined key file.
|
||||||
|
|
||||||
|
@ -50,10 +50,8 @@ class ExternalUpdateRun(command.Command):
|
|||||||
dest='static_inventory',
|
dest='static_inventory',
|
||||||
action="store",
|
action="store",
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Path to an existing ansible inventory to '
|
help=_('DEPRECATED: tripleo-ansible-inventory.yaml'
|
||||||
'use. If not specified, one will be '
|
' in working dir will be used.')
|
||||||
'generated in '
|
|
||||||
'~/tripleo-ansible-inventory.yaml')
|
|
||||||
)
|
)
|
||||||
parser.add_argument("--ssh-user",
|
parser.add_argument("--ssh-user",
|
||||||
dest="ssh_user",
|
dest="ssh_user",
|
||||||
@ -114,7 +112,9 @@ class ExternalUpdateRun(command.Command):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--refresh',
|
'--refresh',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help=_('Refresh the config-download playbooks')
|
help=_('DEPRECATED: Refresh the config-download playbooks.'
|
||||||
|
'Use `overcloud update prepare` instead to refresh '
|
||||||
|
'playbooks.')
|
||||||
)
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
@ -130,56 +130,28 @@ class ExternalUpdateRun(command.Command):
|
|||||||
constants.UPDATE_PROMPT, self.log)):
|
constants.UPDATE_PROMPT, self.log)):
|
||||||
raise OvercloudUpdateNotConfirmed(constants.UPDATE_NO)
|
raise OvercloudUpdateNotConfirmed(constants.UPDATE_NO)
|
||||||
|
|
||||||
if parsed_args.refresh:
|
working_dir = oooutils.get_default_working_dir(parsed_args.stack)
|
||||||
_, ansible_dir = self.get_ansible_key_and_dir(
|
config_download_dir = os.path.join(working_dir, 'config-download')
|
||||||
stack=parsed_args.stack,
|
ansible_dir = os.path.join(config_download_dir, parsed_args.stack)
|
||||||
orchestration=self.app.client_manager.orchestration
|
inventory_path = os.path.join(ansible_dir,
|
||||||
)
|
'tripleo-ansible-inventory.yaml')
|
||||||
deployment.config_download(
|
key = oooutils.get_key(parsed_args.stack)
|
||||||
log=self.log,
|
playbooks = [os.path.join(ansible_dir, p)
|
||||||
clients=self.app.client_manager,
|
for p in constants.EXTERNAL_UPDATE_PLAYBOOKS]
|
||||||
stack_name=parsed_args.stack,
|
oooutils.run_ansible_playbook(
|
||||||
output_dir=ansible_dir,
|
playbook=playbooks,
|
||||||
verbosity=oooutils.playbook_verbosity(self=self),
|
inventory=inventory_path,
|
||||||
ansible_playbook_name=constants.EXTERNAL_UPDATE_PLAYBOOKS,
|
workdir=config_download_dir,
|
||||||
extra_vars=oooutils.parse_extra_vars(
|
tags=parsed_args.tags,
|
||||||
extra_var_strings=parsed_args.extra_vars
|
extra_vars=parsed_args.extra_vars,
|
||||||
),
|
skip_tags=parsed_args.skip_tags,
|
||||||
inventory_path=oooutils.get_tripleo_ansible_inventory(
|
limit_hosts=oooutils.playbook_limit_parse(
|
||||||
parsed_args.static_inventory,
|
limit_nodes=parsed_args.limit
|
||||||
parsed_args.ssh_user,
|
),
|
||||||
parsed_args.stack,
|
forks=parsed_args.ansible_forks,
|
||||||
return_inventory_file_path=True
|
key=key,
|
||||||
),
|
reproduce_command=True
|
||||||
tags=parsed_args.tags,
|
)
|
||||||
skip_tags=parsed_args.skip_tags,
|
|
||||||
limit_hosts=oooutils.playbook_limit_parse(
|
|
||||||
limit_nodes=parsed_args.limit
|
|
||||||
),
|
|
||||||
forks=parsed_args.ansible_forks
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
working_dir = oooutils.get_default_working_dir(parsed_args.stack)
|
|
||||||
config_download_dir = os.path.join(working_dir, 'config-download')
|
|
||||||
ansible_dir = os.path.join(config_download_dir, parsed_args.stack)
|
|
||||||
inventory_path = os.path.join(ansible_dir,
|
|
||||||
'tripleo-ansible-inventory.yaml')
|
|
||||||
key = oooutils.get_key(parsed_args.stack)
|
|
||||||
playbooks = [os.path.join(ansible_dir, p)
|
|
||||||
for p in constants.EXTERNAL_UPDATE_PLAYBOOKS]
|
|
||||||
oooutils.run_ansible_playbook(
|
|
||||||
playbook=playbooks,
|
|
||||||
inventory=inventory_path,
|
|
||||||
workdir=config_download_dir,
|
|
||||||
tags=parsed_args.tags,
|
|
||||||
skip_tags=parsed_args.skip_tags,
|
|
||||||
limit_hosts=oooutils.playbook_limit_parse(
|
|
||||||
limit_nodes=parsed_args.limit
|
|
||||||
),
|
|
||||||
forks=parsed_args.ansible_forks,
|
|
||||||
key=key,
|
|
||||||
reproduce_command=True
|
|
||||||
)
|
|
||||||
deployment.snapshot_dir(ansible_dir)
|
|
||||||
|
|
||||||
|
deployment.snapshot_dir(ansible_dir)
|
||||||
self.log.info("Completed Overcloud External Update Run.")
|
self.log.info("Completed Overcloud External Update Run.")
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
import os
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
@ -47,10 +49,8 @@ class ExternalUpgradeRun(command.Command):
|
|||||||
dest='static_inventory',
|
dest='static_inventory',
|
||||||
action="store",
|
action="store",
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Path to an existing ansible inventory to '
|
help=_('DEPRECATED: tripleo-ansible-inventory.yaml'
|
||||||
'use. If not specified, one will be '
|
' in working dir will be used.')
|
||||||
'generated in '
|
|
||||||
'~/tripleo-ansible-inventory.yaml')
|
|
||||||
)
|
)
|
||||||
parser.add_argument("--ssh-user",
|
parser.add_argument("--ssh-user",
|
||||||
dest="ssh_user",
|
dest="ssh_user",
|
||||||
@ -123,27 +123,28 @@ class ExternalUpgradeRun(command.Command):
|
|||||||
constants.UPGRADE_PROMPT, self.log)):
|
constants.UPGRADE_PROMPT, self.log)):
|
||||||
raise OvercloudUpgradeNotConfirmed(constants.UPGRADE_NO)
|
raise OvercloudUpgradeNotConfirmed(constants.UPGRADE_NO)
|
||||||
|
|
||||||
_, ansible_dir = self.get_ansible_key_and_dir(
|
working_dir = oooutils.get_default_working_dir(parsed_args.stack)
|
||||||
stack=parsed_args.stack,
|
config_download_dir = os.path.join(working_dir, 'config-download')
|
||||||
orchestration=self.app.client_manager.orchestration
|
ansible_dir = os.path.join(config_download_dir, parsed_args.stack)
|
||||||
)
|
inventory_path = os.path.join(ansible_dir,
|
||||||
deployment.config_download(
|
'tripleo-ansible-inventory.yaml')
|
||||||
log=self.log,
|
key = oooutils.get_key(parsed_args.stack)
|
||||||
clients=self.app.client_manager,
|
playbooks = [os.path.join(ansible_dir, p)
|
||||||
stack_name=parsed_args.stack,
|
for p in constants.EXTERNAL_UPGRADE_PLAYBOOKS]
|
||||||
output_dir=ansible_dir,
|
oooutils.run_ansible_playbook(
|
||||||
verbosity=oooutils.playbook_verbosity(self=self),
|
playbook=playbooks,
|
||||||
ansible_playbook_name=constants.EXTERNAL_UPGRADE_PLAYBOOKS,
|
inventory=inventory_path,
|
||||||
inventory_path=oooutils.get_tripleo_ansible_inventory(
|
workdir=config_download_dir,
|
||||||
parsed_args.static_inventory,
|
|
||||||
parsed_args.ssh_user,
|
|
||||||
parsed_args.stack,
|
|
||||||
return_inventory_file_path=True
|
|
||||||
),
|
|
||||||
tags=parsed_args.tags,
|
tags=parsed_args.tags,
|
||||||
skip_tags=parsed_args.skip_tags,
|
skip_tags=parsed_args.skip_tags,
|
||||||
|
extra_vars=parsed_args.extra_vars,
|
||||||
limit_hosts=oooutils.playbook_limit_parse(
|
limit_hosts=oooutils.playbook_limit_parse(
|
||||||
limit_nodes=parsed_args.limit),
|
limit_nodes=parsed_args.limit
|
||||||
forks=parsed_args.ansible_forks
|
),
|
||||||
|
forks=parsed_args.ansible_forks,
|
||||||
|
key=key,
|
||||||
|
reproduce_command=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
deployment.snapshot_dir(ansible_dir)
|
||||||
self.log.info("Completed Overcloud External Upgrade Run.")
|
self.log.info("Completed Overcloud External Upgrade Run.")
|
||||||
|
@ -119,10 +119,8 @@ class UpdateRun(command.Command):
|
|||||||
dest='static_inventory',
|
dest='static_inventory',
|
||||||
action="store",
|
action="store",
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Path to an existing ansible inventory to '
|
help=_('DEPRECATED: tripleo-ansible-inventory.yaml'
|
||||||
'use. If not specified, one will be '
|
' in working dir will be used.')
|
||||||
'generated in '
|
|
||||||
'~/tripleo-ansible-inventory.yaml')
|
|
||||||
)
|
)
|
||||||
parser.add_argument('--stack', dest='stack',
|
parser.add_argument('--stack', dest='stack',
|
||||||
help=_('Name or ID of heat stack '
|
help=_('Name or ID of heat stack '
|
||||||
@ -185,12 +183,7 @@ class UpdateRun(command.Command):
|
|||||||
'config-download',
|
'config-download',
|
||||||
parsed_args.stack)
|
parsed_args.stack)
|
||||||
|
|
||||||
if not parsed_args.static_inventory:
|
inventory = os.path.join(ansible_dir, 'tripleo-ansible-inventory.yaml')
|
||||||
inventory = os.path.join(ansible_dir,
|
|
||||||
'tripleo-ansible-inventory.yaml')
|
|
||||||
else:
|
|
||||||
inventory = parsed_args.static_inventory
|
|
||||||
|
|
||||||
ansible_cfg = os.path.join(ansible_dir, 'ansible.cfg')
|
ansible_cfg = os.path.join(ansible_dir, 'ansible.cfg')
|
||||||
key_file = oooutils.get_key(parsed_args.stack)
|
key_file = oooutils.get_key(parsed_args.stack)
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
import os
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
@ -141,10 +143,8 @@ class UpgradeRun(command.Command):
|
|||||||
dest='static_inventory',
|
dest='static_inventory',
|
||||||
action="store",
|
action="store",
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Path to an existing ansible inventory to '
|
help=_('DEPRECATED: tripleo-ansible-inventory.yaml'
|
||||||
'use. If not specified, one will be '
|
' in working dir will be used.')
|
||||||
'generated in '
|
|
||||||
'~/tripleo-ansible-inventory.yaml')
|
|
||||||
)
|
)
|
||||||
parser.add_argument("--ssh-user",
|
parser.add_argument("--ssh-user",
|
||||||
dest="ssh_user",
|
dest="ssh_user",
|
||||||
@ -216,30 +216,26 @@ class UpgradeRun(command.Command):
|
|||||||
else:
|
else:
|
||||||
playbook = parsed_args.playbook
|
playbook = parsed_args.playbook
|
||||||
|
|
||||||
_, ansible_dir = self.get_ansible_key_and_dir(
|
working_dir = oooutils.get_default_working_dir(parsed_args.stack)
|
||||||
stack=parsed_args.stack,
|
config_download_dir = os.path.join(working_dir, 'config-download')
|
||||||
orchestration=self.app.client_manager.orchestration
|
ansible_dir = os.path.join(config_download_dir, parsed_args.stack)
|
||||||
)
|
inventory_path = os.path.join(ansible_dir,
|
||||||
deployment.config_download(
|
'tripleo-ansible-inventory.yaml')
|
||||||
log=self.log,
|
key = oooutils.get_key(parsed_args.stack)
|
||||||
clients=self.app.client_manager,
|
oooutils.run_ansible_playbook(
|
||||||
stack_name=parsed_args.stack,
|
playbook=playbook,
|
||||||
output_dir=ansible_dir,
|
inventory=inventory_path,
|
||||||
verbosity=oooutils.playbook_verbosity(self=self),
|
workdir=config_download_dir,
|
||||||
ansible_playbook_name=playbook,
|
|
||||||
inventory_path=oooutils.get_tripleo_ansible_inventory(
|
|
||||||
parsed_args.static_inventory,
|
|
||||||
parsed_args.ssh_user,
|
|
||||||
parsed_args.stack,
|
|
||||||
return_inventory_file_path=True
|
|
||||||
),
|
|
||||||
tags=parsed_args.tags,
|
tags=parsed_args.tags,
|
||||||
skip_tags=parsed_args.skip_tags,
|
skip_tags=parsed_args.skip_tags,
|
||||||
limit_hosts=oooutils.playbook_limit_parse(
|
limit_hosts=oooutils.playbook_limit_parse(
|
||||||
limit_nodes=parsed_args.limit
|
limit_nodes=parsed_args.limit
|
||||||
),
|
),
|
||||||
forks=parsed_args.ansible_forks
|
forks=parsed_args.ansible_forks,
|
||||||
|
key=key,
|
||||||
|
reproduce_command=True
|
||||||
)
|
)
|
||||||
|
deployment.snapshot_dir(ansible_dir)
|
||||||
self.log.info("Completed Overcloud Major Upgrade Run.")
|
self.log.info("Completed Overcloud Major Upgrade Run.")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user