Add --hosts and --services support for reconfigure action
Change-Id: Ib84a45116b0975b8866499ff30cd1499c309e6af
This commit is contained in:
parent
2a16071261
commit
96f5956b3d
|
@ -215,22 +215,35 @@ class ControlPlaneApi(object):
|
|||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def reconfigure(verbose_level=1):
|
||||
# type: (int) -> Job
|
||||
def reconfigure(verbose_level=1, hostnames=[], servicenames=[]):
|
||||
# type: (int, List[str], List[str]) -> Job
|
||||
"""Reconfigure.
|
||||
|
||||
Reconfigure OpenStack service.
|
||||
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param servicenames: services to prechecks.
|
||||
:type servicenames: list of strings
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(servicenames, u._('Service names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
hostnames = safe_decode(hostnames)
|
||||
servicenames = safe_decode(servicenames)
|
||||
|
||||
check_kolla_args(hostnames=hostnames,
|
||||
servicenames=servicenames)
|
||||
|
||||
action = KollaAction(verbose_level=verbose_level,
|
||||
playbook_name='site.yml')
|
||||
ansible_job = action.reconfigure()
|
||||
ansible_job = action.reconfigure(hostnames, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -164,12 +164,26 @@ class Reconfigure(Command):
|
|||
"""Reconfigure OpenStack service."""
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(Reconfigure, self).get_parser(prog_name)
|
||||
parser.add_argument('--hosts', nargs='?',
|
||||
metavar='<host_list>',
|
||||
help=u._('Reconfigure host list'))
|
||||
parser.add_argument('--services', nargs='?',
|
||||
metavar='<service_list>',
|
||||
help=u._('Reconfigure service list'))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
hosts = []
|
||||
services = []
|
||||
try:
|
||||
verbose_level = self.app.options.verbose_level
|
||||
job = CLIENT.reconfigure(verbose_level)
|
||||
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(',')
|
||||
job = CLIENT.reconfigure(verbose_level, hosts, services)
|
||||
status = job.wait()
|
||||
handers_action_result(job, status, verbose_level)
|
||||
except Exception:
|
||||
|
|
|
@ -64,9 +64,11 @@ class KollaAction(object):
|
|||
job = self.playbook.run()
|
||||
return job
|
||||
|
||||
def reconfigure(self):
|
||||
def reconfigure(self, hostnames=[], servicenames=[]):
|
||||
'''Reconfigure OpenStack service.'''
|
||||
|
||||
self.playbook.hosts = hostnames
|
||||
self.playbook.services = servicenames
|
||||
self.playbook.extra_vars = 'kolla_action=reconfigure'
|
||||
|
||||
self._run_deploy_rules(self.playbook)
|
||||
|
|
Loading…
Reference in New Issue