Merge "Add --hosts variable support for upgrade action"
This commit is contained in:
commit
cc850c8083
|
@ -154,14 +154,16 @@ class ControlPlaneApi(object):
|
|||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def upgrade(verbose_level=1, servicenames=[]):
|
||||
# type: (int, List[str]) -> Job
|
||||
def upgrade(verbose_level=1, hostnames=[], servicenames=[]):
|
||||
# type: (int, List[str], List[str]) -> Job
|
||||
"""Upgrade.
|
||||
|
||||
Upgrades existing OpenStack Environment.
|
||||
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param hostnames: hostnames to upgrade.
|
||||
:type hostnames: list of strings.
|
||||
:param servicenames: services to upgrade. If empty, then upgrade all.
|
||||
:type servicenames: list of strings
|
||||
:return: Job object
|
||||
|
@ -171,15 +173,18 @@ class ControlPlaneApi(object):
|
|||
"openstack_release."
|
||||
"""
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(hostnames, u._('Host names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
check_arg(servicenames, u._('Service names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
|
||||
check_kolla_args(servicenames=servicenames)
|
||||
|
||||
hostnames = safe_decode(hostnames)
|
||||
servicenames = safe_decode(servicenames)
|
||||
action = KollaAction(verbose_level=verbose_level,
|
||||
playbook_name='site.yml')
|
||||
ansible_job = action.upgrade(servicenames)
|
||||
ansible_job = action.upgrade(hostnames, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -221,19 +221,26 @@ class Upgrade(Command):
|
|||
"""Upgrades existing OpenStack Environment."""
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(Upgrade, self).get_parser(prog_name)
|
||||
parser.add_argument('--hosts', nargs='?',
|
||||
metavar='<host_list>',
|
||||
help=u._('Upgrade host list'))
|
||||
parser.add_argument('--services', nargs='?',
|
||||
metavar='<service_list>',
|
||||
help=u._('Upgrade service list'))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
hosts = None
|
||||
services = None
|
||||
try:
|
||||
if parsed_args.hosts:
|
||||
host_list = parsed_args.hosts.strip()
|
||||
hosts = host_list.split(',')
|
||||
if parsed_args.services:
|
||||
service_list = parsed_args.services.strip()
|
||||
services = service_list.split(',')
|
||||
verbose_level = self.app.options.verbose_level
|
||||
job = CLIENT.upgrade(verbose_level, services)
|
||||
job = CLIENT.upgrade(verbose_level, hosts, services)
|
||||
status = job.wait()
|
||||
handers_action_result(job, status, verbose_level)
|
||||
except Exception:
|
||||
|
|
|
@ -153,9 +153,10 @@ class KollaAction(object):
|
|||
job = self.playbook.run()
|
||||
return job
|
||||
|
||||
def upgrade(self, servicenames=[]):
|
||||
def upgrade(self, hostnames=[], servicenames=[]):
|
||||
'''Upgrades existing OpenStack Environment.'''
|
||||
|
||||
self.playbook.hosts = hostnames
|
||||
self.playbook.services = servicenames
|
||||
self.playbook.extra_vars = 'kolla_action=upgrade'
|
||||
self.playbook.print_output = True
|
||||
|
|
Loading…
Reference in New Issue