Added support for pull command
Upstream added in a new pull playbook action so that updated container images can be pulled as a separate action to deploy, upgrade, reconfigure, etc. This should make it easier to perform some actions without hitting timeouts in environments with slow networks. Change-Id: I44a5c736d706f05262fe74c5ac7efc9edb786501 Jira-Issue: OPENSTACK-1635
This commit is contained in:
parent
99afdbcc1d
commit
2e70c5c59f
|
@ -54,6 +54,21 @@ class ControlPlaneApi(object):
|
||||||
serial_flag, verbose_level, servicenames)
|
serial_flag, verbose_level, servicenames)
|
||||||
return Job(ansible_job)
|
return Job(ansible_job)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def pull(verbose_level=1):
|
||||||
|
"""Pull.
|
||||||
|
|
||||||
|
Pull container images onto appropriate hosts.
|
||||||
|
|
||||||
|
:param verbose_level: the higher the number, the more verbose
|
||||||
|
:type verbose_level: integer
|
||||||
|
:return: Job object
|
||||||
|
:rtype: Job
|
||||||
|
"""
|
||||||
|
check_arg(verbose_level, u._('Verbose level'), int)
|
||||||
|
ansible_job = actions.pull(verbose_level)
|
||||||
|
return Job(ansible_job)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def upgrade(verbose_level=1, servicenames=[]):
|
def upgrade(verbose_level=1, servicenames=[]):
|
||||||
# type: (int, List[str]) -> Job
|
# type: (int, List[str]) -> Job
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Copyright(c) 2017, Oracle and/or its affiliates. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from cliff.command import Command
|
||||||
|
|
||||||
|
import kollacli.i18n as u
|
||||||
|
|
||||||
|
from kollacli.api.client import ClientApi
|
||||||
|
from kollacli.commands.exceptions import CommandError
|
||||||
|
|
||||||
|
CLIENT = ClientApi()
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Pull(Command):
|
||||||
|
"""Pull enabled service images onto appropriate hosts."""
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
try:
|
||||||
|
verbose_level = self.app.options.verbose_level
|
||||||
|
job = CLIENT.pull(verbose_level)
|
||||||
|
status = job.wait()
|
||||||
|
if verbose_level > 2:
|
||||||
|
LOG.info('\n\n' + 80 * '=')
|
||||||
|
LOG.info(u._('DEBUG command output:\n{out}')
|
||||||
|
.format(out=job.get_console_output()))
|
||||||
|
if status == 0:
|
||||||
|
LOG.info(u._('Success'))
|
||||||
|
else:
|
||||||
|
raise CommandError(u._('Job failed:\n{msg}')
|
||||||
|
.format(msg=job.get_error_message()))
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
raise Exception(traceback.format_exc())
|
|
@ -95,6 +95,19 @@ def precheck(hostnames, verbose_level=1):
|
||||||
return job
|
return job
|
||||||
|
|
||||||
|
|
||||||
|
def pull(verbose_level=1):
|
||||||
|
'''run pull action against all hosts'''
|
||||||
|
playbook = AnsiblePlaybook()
|
||||||
|
kolla_home = get_kolla_home()
|
||||||
|
playbook.playbook_path = os.path.join(kolla_home,
|
||||||
|
'ansible/site.yml')
|
||||||
|
playbook.extra_vars = 'action=pull'
|
||||||
|
playbook.verbose_level = verbose_level
|
||||||
|
|
||||||
|
job = playbook.run()
|
||||||
|
return job
|
||||||
|
|
||||||
|
|
||||||
def stop_hosts(hostnames=[], verbose_level=1):
|
def stop_hosts(hostnames=[], verbose_level=1):
|
||||||
'''stop containers on a set of hosts.
|
'''stop containers on a set of hosts.
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ from kollacli.common.utils import get_kollacli_etc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
VERSION = '0.3'
|
VERSION = '4.0'
|
||||||
|
|
||||||
|
|
||||||
class KollaCli(App):
|
class KollaCli(App):
|
||||||
|
|
|
@ -54,6 +54,7 @@ kolla.cli =
|
||||||
property_clear = kollacli.commands.property:PropertyClear
|
property_clear = kollacli.commands.property:PropertyClear
|
||||||
property_list = kollacli.commands.property:PropertyList
|
property_list = kollacli.commands.property:PropertyList
|
||||||
property_set = kollacli.commands.property:PropertySet
|
property_set = kollacli.commands.property:PropertySet
|
||||||
|
pull = kollacli.commands.pull:Pull
|
||||||
reconfigure = kollacli.commands.reconfigure:Reconfigure
|
reconfigure = kollacli.commands.reconfigure:Reconfigure
|
||||||
service_addgroup = kollacli.commands.service:ServiceAddGroup
|
service_addgroup = kollacli.commands.service:ServiceAddGroup
|
||||||
service_list = kollacli.commands.service:ServiceList
|
service_list = kollacli.commands.service:ServiceList
|
||||||
|
|
Loading…
Reference in New Issue