Add the support to pull specific service's images

this PS add the support to pull specific service's images

Change-Id: I5d82437e2f50059c654582ea5ed6e2498912daab
Co-Authored-By: caoyuan <cao.yuan@99cloud.net>
This commit is contained in:
zhulingjie 2019-03-27 15:08:34 +08:00 committed by cao.yuan
parent 81a8a22d9a
commit ad572a24cd
3 changed files with 19 additions and 4 deletions

View File

@ -62,18 +62,19 @@ class ControlPlaneApi(object):
return Job(ansible_job)
@staticmethod
def pull(verbose_level=1):
def pull(verbose_level=1, services=[]):
"""Pull.
Pull all images for containers (only pulls, no running container).
:param verbose_level: the higher the number, the more verbose
:type verbose_level: integer
:param servicenames: services to pull. If empty, then pull all.
:return: Job object
:rtype: Job
"""
check_arg(verbose_level, u._('Verbose level'), int)
ansible_job = actions.pull(verbose_level)
ansible_job = actions.pull(verbose_level, services)
return Job(ansible_job)
@staticmethod

View File

@ -101,10 +101,21 @@ class Deploy(Command):
class Pull(Command):
"""Pull all images for containers (only pulls, no running container)."""
def get_parser(self, prog_name):
parser = super(Pull, self).get_parser(prog_name)
parser.add_argument('--services', nargs='?',
metavar='<service_list>',
help=u._('Pull service list'))
return parser
def take_action(self, parsed_args):
services = []
try:
verbose_level = self.app.options.verbose_level
job = CLIENT.pull(verbose_level)
if parsed_args.services:
service_list = parsed_args.services.strip()
services = service_list.split(',')
job = CLIENT.pull(verbose_level, services)
status = job.wait()
handers_action_result(job, status, verbose_level)
except Exception:

View File

@ -125,14 +125,17 @@ def deploy(hostnames=[],
return job
def pull(verbose_level=1):
def pull(verbose_level=1, servicenames=[]):
'''run pull action against all hosts'''
playbook = AnsiblePlaybook()
kolla_home = get_kolla_ansible_home()
playbook.playbook_path = os.path.join(kolla_home,
'ansible/site.yml')
playbook.extra_vars = 'kolla_action=pull'
playbook.print_output = True
playbook.verbose_level = verbose_level
playbook.services = servicenames
job = playbook.run()
return job