Updating the python api syntax
Updating the python api syntax and also bumped openstack-kolla-ansible requirement for 4.x release. Change-Id: If9946511ecdcd7905579a9dac94458c16a1df2f2 Jira-Issue: OSTACKDEV-342
This commit is contained in:
parent
5281bdc67e
commit
69700b6020
|
@ -1,4 +1,4 @@
|
|||
# Copyright(c) 2015, Oracle and/or its affiliates. All Rights Reserved.
|
||||
# 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
|
||||
|
@ -207,8 +207,8 @@ License: GNU General Public License, Version 3
|
|||
Group: Applications/System
|
||||
# The plugin needs ansible 2.1 which is in the
|
||||
# requirement for openstack-kolla-ansible
|
||||
Requires: openstack-kolla-ansible >= 3.0.0
|
||||
Requires: openstack-kolla-ansible < 4.0.0
|
||||
Requires: openstack-kolla-ansible >= 4.0.0
|
||||
Requires: openstack-kolla-ansible < 5.0.0
|
||||
|
||||
%description -n openstack-kolla-ansible-plugin
|
||||
This ansible plugin supplies playbook activity to the
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
# Copyright(c) 2016, 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 kollacli.i18n as u
|
||||
|
||||
from kollacli.api.exceptions import InvalidArgument
|
||||
from kollacli.api.job import Job
|
||||
from kollacli.common.ansible import actions
|
||||
from kollacli.common.inventory import Inventory
|
||||
from kollacli.common.utils import check_arg
|
||||
from kollacli.common.utils import safe_decode
|
||||
|
||||
|
||||
class AsyncApi(object):
|
||||
|
||||
def async_deploy(self, hostnames=[],
|
||||
serial_flag=False, verbose_level=1, servicenames=[]):
|
||||
# type: (List[str], bool, int, List[str]) -> Job
|
||||
"""Deploy.
|
||||
|
||||
Deploy containers to hosts.
|
||||
|
||||
:param hostnames: hosts to deploy to. If empty, then deploy to all.
|
||||
:type hostnames: list of strings
|
||||
:param serial_flag: if true, deploy will be done one host at a time
|
||||
:type serial_flag: boolean
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param servicenames: services to deploy. If empty, then deploy all.
|
||||
: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(serial_flag, u._('Serial flag'), bool)
|
||||
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)
|
||||
|
||||
ansible_job = actions.deploy(hostnames,
|
||||
serial_flag, verbose_level, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
def async_upgrade(self, verbose_level=1, servicenames=[]):
|
||||
# type: (int, List[str]) -> Job
|
||||
"""Upgrade.
|
||||
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param servicenames: services to upgrade. If empty, then upgrade all.
|
||||
:type servicenames: list of strings
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
|
||||
Upgrade containers to new version specified by the property
|
||||
"openstack_release."
|
||||
"""
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(servicenames, u._('Service names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
servicenames = safe_decode(servicenames)
|
||||
|
||||
ansible_job = actions.upgrade(verbose_level, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
def async_host_destroy(self, hostnames, destroy_type, verbose_level=1,
|
||||
include_data=False, remove_images=False):
|
||||
# type: (List[str], str, int, bool, bool) -> Job
|
||||
"""Destroy Hosts.
|
||||
|
||||
Stops and removes all kolla related docker containers on the
|
||||
specified hosts.
|
||||
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param destroy_type: either 'kill' or 'stop'
|
||||
:type destroy_type: string
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param include_data: if true, destroy data containers too.
|
||||
:type include_data: boolean
|
||||
:param remove_images: if true, destroy will remove the docker images
|
||||
:type remove_images: boolean
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(destroy_type, u._('Destroy type'), str)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(include_data, u._('Include data'), bool)
|
||||
check_arg(remove_images, u._('Remove images'), bool)
|
||||
if destroy_type not in ['stop', 'kill']:
|
||||
raise InvalidArgument(
|
||||
u._('Invalid destroy type ({type}). Must be either '
|
||||
'"stop" or "kill".').format(type=destroy_type))
|
||||
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.destroy_hosts(hostnames, destroy_type,
|
||||
verbose_level, include_data,
|
||||
remove_images)
|
||||
return Job(ansible_job)
|
||||
|
||||
def async_host_precheck(self, hostnames, verbose_level=1):
|
||||
# type: (List[str], int) -> Job
|
||||
"""Check pre-deployment configuration of hosts.
|
||||
|
||||
Check if host is ready for a new deployment. This will fail if
|
||||
any of the hosts are not configured correctly or if they have
|
||||
already been deployed to.
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.precheck(hostnames, verbose_level)
|
||||
return Job(ansible_job)
|
||||
|
||||
def async_host_stop(self, hostnames, verbose_level=1):
|
||||
# type: (List[str], int) -> Job
|
||||
"""Stop Hosts.
|
||||
|
||||
Stops all kolla related docker containers on the specified hosts.
|
||||
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.stop_hosts(hostnames, verbose_level)
|
||||
return Job(ansible_job)
|
||||
|
||||
def async_reconfigure(self, verbose_level=1):
|
||||
# type: (int) -> Job
|
||||
"""Reconfigure.
|
||||
|
||||
Reconfigure containers on 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.reconfigure(verbose_level)
|
||||
return Job(ansible_job)
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright(c) 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
# 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
|
||||
|
@ -19,8 +19,7 @@ import sys
|
|||
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from kollacli.api.async import AsyncApi
|
||||
from kollacli.api.deploy import DeployApi
|
||||
from kollacli.api.control_plane import ControlPlaneApi
|
||||
from kollacli.api.group import GroupApi
|
||||
from kollacli.api.host import HostApi
|
||||
from kollacli.api.password import PasswordApi
|
||||
|
@ -34,12 +33,11 @@ LOG_FILE_MESSAGE_FORMAT = \
|
|||
'[%(asctime)s] %(levelname)-8s %(name)s %(message)s'
|
||||
LOG = None
|
||||
|
||||
VERSION = '1.0'
|
||||
VERSION = '2.0'
|
||||
|
||||
|
||||
class ClientApi(
|
||||
AsyncApi,
|
||||
DeployApi,
|
||||
ControlPlaneApi,
|
||||
GroupApi,
|
||||
HostApi,
|
||||
PasswordApi,
|
||||
|
@ -60,14 +58,17 @@ class ClientApi(
|
|||
def __init__(self):
|
||||
self._configure_logging()
|
||||
|
||||
def get_version(self):
|
||||
@staticmethod
|
||||
def get_version():
|
||||
# type: () -> str
|
||||
return VERSION
|
||||
|
||||
def base_call(self):
|
||||
@staticmethod
|
||||
def base_call():
|
||||
LOG.info('base call')
|
||||
|
||||
def enable_console_logging(self, level, enable=True):
|
||||
@staticmethod
|
||||
def enable_console_logging(level, enable=True):
|
||||
# type: (int, bool) -> None
|
||||
"""enable/disable console logging for the api
|
||||
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
# 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 kollacli.i18n as u
|
||||
|
||||
from kollacli.api.job import Job
|
||||
from kollacli.common.ansible import actions
|
||||
from kollacli.common.inventory import Inventory
|
||||
from kollacli.common.utils import check_arg
|
||||
from kollacli.common.utils import safe_decode
|
||||
|
||||
|
||||
class ControlPlaneApi(object):
|
||||
|
||||
@staticmethod
|
||||
def deploy(hostnames=[],
|
||||
serial_flag=False, verbose_level=1, servicenames=[]):
|
||||
# type: (List[str], bool, int, List[str]) -> Job
|
||||
"""Deploy.
|
||||
|
||||
Deploy containers to hosts.
|
||||
|
||||
:param hostnames: hosts to deploy to. If empty, then deploy to all.
|
||||
:type hostnames: list of strings
|
||||
:param serial_flag: if true, deploy will be done one host at a time
|
||||
:type serial_flag: boolean
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param servicenames: services to deploy. If empty, then deploy all.
|
||||
: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(serial_flag, u._('Serial flag'), bool)
|
||||
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)
|
||||
|
||||
ansible_job = actions.deploy(hostnames,
|
||||
serial_flag, verbose_level, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def upgrade(verbose_level=1, servicenames=[]):
|
||||
# type: (int, List[str]) -> Job
|
||||
"""Upgrade.
|
||||
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param servicenames: services to upgrade. If empty, then upgrade all.
|
||||
:type servicenames: list of strings
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
|
||||
Upgrade containers to new version specified by the property
|
||||
"openstack_release."
|
||||
"""
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(servicenames, u._('Service names'), list,
|
||||
empty_ok=True, none_ok=True)
|
||||
servicenames = safe_decode(servicenames)
|
||||
|
||||
ansible_job = actions.upgrade(verbose_level, servicenames)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def reconfigure(verbose_level=1):
|
||||
# type: (int) -> Job
|
||||
"""Reconfigure.
|
||||
|
||||
Reconfigure containers on 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.reconfigure(verbose_level)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def set_deploy_mode(remote_mode):
|
||||
# type: (bool) -> None
|
||||
"""Set deploy mode.
|
||||
|
||||
Set deploy mode to either local or remote. Local indicates
|
||||
that the openstack deployment will be to the local host.
|
||||
Remote means that the deployment is executed via ssh.
|
||||
|
||||
NOTE: local mode is not supported and should never be used
|
||||
in production environments.
|
||||
|
||||
:param remote_mode: if remote mode is True deployment is done via ssh
|
||||
:type remote_mode: bool
|
||||
"""
|
||||
check_arg(remote_mode, u._('Remote mode'), bool)
|
||||
inventory = Inventory.load()
|
||||
inventory.set_deploy_mode(remote_mode)
|
||||
Inventory.save(inventory)
|
|
@ -1,43 +0,0 @@
|
|||
# Copyright(c) 2016, 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 kollacli.i18n as u
|
||||
|
||||
from kollacli.common.inventory import Inventory
|
||||
from kollacli.common.utils import check_arg
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DeployApi(object):
|
||||
|
||||
def deploy_set_mode(self, remote_mode):
|
||||
# type: (bool) -> None
|
||||
"""Set deploy mode.
|
||||
|
||||
Set deploy mode to either local or remote. Local indicates
|
||||
that the openstack deployment will be to the local host.
|
||||
Remote means that the deployment is executed via ssh.
|
||||
|
||||
NOTE: local mode is not supported and should never be used
|
||||
in production environments.
|
||||
|
||||
:param remote_mode: if remote mode is True deployment is done via ssh
|
||||
:type remote_mode: bool
|
||||
"""
|
||||
check_arg(remote_mode, u._('Remote mode'), bool)
|
||||
inventory = Inventory.load()
|
||||
inventory.set_deploy_mode(remote_mode)
|
||||
Inventory.save(inventory)
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright(c) 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
# 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
|
||||
|
@ -14,6 +14,9 @@
|
|||
from copy import copy
|
||||
import kollacli.i18n as u
|
||||
|
||||
from kollacli.api.exceptions import InvalidArgument
|
||||
from kollacli.api.job import Job
|
||||
from kollacli.common.ansible import actions
|
||||
from kollacli.common.inventory import Inventory
|
||||
from kollacli.common.utils import check_arg
|
||||
from kollacli.common.utils import safe_decode
|
||||
|
@ -21,7 +24,8 @@ from kollacli.common.utils import safe_decode
|
|||
|
||||
class HostApi(object):
|
||||
|
||||
def host_add(self, hostnames):
|
||||
@staticmethod
|
||||
def host_add(hostnames):
|
||||
# type: (List[str]) -> None
|
||||
"""Add hosts to the inventory
|
||||
|
||||
|
@ -39,7 +43,8 @@ class HostApi(object):
|
|||
if any_changed:
|
||||
Inventory.save(inventory)
|
||||
|
||||
def host_remove(self, hostnames):
|
||||
@staticmethod
|
||||
def host_remove(hostnames):
|
||||
# type: (List[str]) -> None
|
||||
"""Remove hosts from the inventory
|
||||
|
||||
|
@ -57,7 +62,8 @@ class HostApi(object):
|
|||
if any_changed:
|
||||
Inventory.save(inventory)
|
||||
|
||||
def host_get_all(self):
|
||||
@staticmethod
|
||||
def host_get_all():
|
||||
# type: () -> List[Host]
|
||||
"""Get all hosts in the inventory
|
||||
|
||||
|
@ -71,7 +77,8 @@ class HostApi(object):
|
|||
hosts.append(Host(hostname, groupnames))
|
||||
return hosts
|
||||
|
||||
def host_get(self, hostnames):
|
||||
@staticmethod
|
||||
def host_get(hostnames):
|
||||
# type: (List[str]) -> List[Host]
|
||||
"""Get selected hosts in the inventory
|
||||
|
||||
|
@ -90,7 +97,8 @@ class HostApi(object):
|
|||
hosts.append(Host(hostname, host_groups[hostname]))
|
||||
return hosts
|
||||
|
||||
def host_ssh_check(self, hostnames):
|
||||
@staticmethod
|
||||
def host_ssh_check(hostnames):
|
||||
# type: (List[str]) -> Dict[str,Dict[str,object]]
|
||||
"""Check hosts for ssh connectivity
|
||||
|
||||
|
@ -112,7 +120,8 @@ class HostApi(object):
|
|||
summary = inventory.ssh_check_hosts(hostnames)
|
||||
return summary
|
||||
|
||||
def host_setup(self, hosts_info):
|
||||
@staticmethod
|
||||
def host_setup(hosts_info):
|
||||
# type: (Dict[str,Dict[str,object]]) -> None
|
||||
"""Setup multiple hosts for ssh access
|
||||
|
||||
|
@ -132,6 +141,95 @@ class HostApi(object):
|
|||
inventory.validate_hostnames(hosts_info.keys())
|
||||
inventory.setup_hosts(hosts_info)
|
||||
|
||||
@staticmethod
|
||||
def host_destroy(hostnames, destroy_type, verbose_level=1,
|
||||
include_data=False, remove_images=False):
|
||||
# type: (List[str], str, int, bool, bool) -> Job
|
||||
"""Destroy Hosts.
|
||||
|
||||
Stops and removes all kolla related docker containers on the
|
||||
specified hosts.
|
||||
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param destroy_type: either 'kill' or 'stop'
|
||||
:type destroy_type: string
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:param include_data: if true, destroy data containers too.
|
||||
:type include_data: boolean
|
||||
:param remove_images: if true, destroy will remove the docker images
|
||||
:type remove_images: boolean
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(destroy_type, u._('Destroy type'), str)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
check_arg(include_data, u._('Include data'), bool)
|
||||
check_arg(remove_images, u._('Remove images'), bool)
|
||||
if destroy_type not in ['stop', 'kill']:
|
||||
raise InvalidArgument(
|
||||
u._('Invalid destroy type ({type}). Must be either '
|
||||
'"stop" or "kill".').format(type=destroy_type))
|
||||
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.destroy_hosts(hostnames, destroy_type,
|
||||
verbose_level, include_data,
|
||||
remove_images)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def host_precheck(hostnames, verbose_level=1):
|
||||
# type: (List[str], int) -> Job
|
||||
"""Check pre-deployment configuration of hosts.
|
||||
|
||||
Check if host is ready for a new deployment. This will fail if
|
||||
any of the hosts are not configured correctly or if they have
|
||||
already been deployed to.
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.precheck(hostnames, verbose_level)
|
||||
return Job(ansible_job)
|
||||
|
||||
@staticmethod
|
||||
def host_stop(hostnames, verbose_level=1):
|
||||
# type: (List[str], int) -> Job
|
||||
"""Stop Hosts.
|
||||
|
||||
Stops all kolla related docker containers on the specified hosts.
|
||||
|
||||
:param hostnames: host names
|
||||
:type hostnames: list
|
||||
:param verbose_level: the higher the number, the more verbose
|
||||
:type verbose_level: integer
|
||||
:return: Job object
|
||||
:rtype: Job
|
||||
"""
|
||||
check_arg(hostnames, u._('Host names'), list)
|
||||
check_arg(verbose_level, u._('Verbose level'), int)
|
||||
|
||||
hostnames = safe_decode(hostnames)
|
||||
inventory = Inventory.load()
|
||||
inventory.validate_hostnames(hostnames)
|
||||
|
||||
ansible_job = actions.stop_hosts(hostnames, verbose_level)
|
||||
return Job(ansible_job)
|
||||
|
||||
|
||||
class Host(object):
|
||||
"""Host"""
|
||||
|
|
|
@ -74,8 +74,8 @@ class Deploy(Command):
|
|||
'Invalid hosts: {hosts}')
|
||||
.format(hosts=invalid_host_list))
|
||||
|
||||
job = CLIENT.async_deploy(hosts, serial_flag,
|
||||
verbose_level)
|
||||
job = CLIENT.deploy(hosts, serial_flag,
|
||||
verbose_level)
|
||||
|
||||
# wait for job to complete
|
||||
status = None
|
||||
|
@ -132,7 +132,7 @@ class Setdeploy(Command):
|
|||
raise CommandError(
|
||||
u._('Invalid deploy mode. Mode must be '
|
||||
'either "local" or "remote".'))
|
||||
CLIENT.deploy_set_mode(remote_flag)
|
||||
CLIENT.set_deploy_mode(remote_flag)
|
||||
except CommandError as e:
|
||||
raise e
|
||||
except Exception:
|
||||
|
|
|
@ -101,9 +101,9 @@ class HostDestroy(Command):
|
|||
return
|
||||
verbose_level = self.app.options.verbose_level
|
||||
|
||||
job = CLIENT.async_host_destroy(hostnames, destroy_type,
|
||||
verbose_level, include_data,
|
||||
remove_images)
|
||||
job = CLIENT.host_destroy(hostnames, destroy_type,
|
||||
verbose_level, include_data,
|
||||
remove_images)
|
||||
status = job.wait()
|
||||
if verbose_level > 2:
|
||||
LOG.info('\n\n' + 80 * '=')
|
||||
|
@ -208,7 +208,7 @@ class HostCheck(Command):
|
|||
if parsed_args.predeploy:
|
||||
# run pre-deploy checks
|
||||
verbose_level = self.app.options.verbose_level
|
||||
job = CLIENT.async_host_precheck(hostnames, verbose_level)
|
||||
job = CLIENT.host_precheck(hostnames, verbose_level)
|
||||
status = job.wait()
|
||||
if verbose_level > 2:
|
||||
LOG.info('\n\n' + 80 * '=')
|
||||
|
@ -332,7 +332,7 @@ class HostStop(Command):
|
|||
|
||||
verbose_level = self.app.options.verbose_level
|
||||
|
||||
job = CLIENT.async_host_stop(hostnames, verbose_level)
|
||||
job = CLIENT.host_stop(hostnames, verbose_level)
|
||||
status = job.wait()
|
||||
if verbose_level > 2:
|
||||
LOG.info('\n\n' + 80 * '=')
|
||||
|
|
|
@ -43,7 +43,7 @@ class Upgrade(Command):
|
|||
service_list = parsed_args.services.strip()
|
||||
services = service_list.split(',')
|
||||
verbose_level = self.app.options.verbose_level
|
||||
job = CLIENT.async_upgrade(verbose_level, services)
|
||||
job = CLIENT.upgrade(verbose_level, services)
|
||||
status = job.wait()
|
||||
if verbose_level > 2:
|
||||
LOG.info('\n\n' + 80 * '=')
|
||||
|
|
|
@ -363,7 +363,6 @@ def safe_decode(obj_to_decode):
|
|||
if obj_to_decode is None:
|
||||
return None
|
||||
|
||||
new_obj = None
|
||||
if isinstance(obj_to_decode, list):
|
||||
new_obj = []
|
||||
for text in obj_to_decode:
|
||||
|
|
|
@ -68,7 +68,7 @@ class TestFunctional(KollaCliTest):
|
|||
group.add_host(hostname)
|
||||
|
||||
self.log.info('Start a deployment')
|
||||
job = CLIENT.async_deploy()
|
||||
job = CLIENT.deploy()
|
||||
|
||||
time.sleep(120)
|
||||
self.log.info('\nwaking up from sleep............................\n')
|
||||
|
|
|
@ -158,7 +158,7 @@ class TestFunctional(KollaCliTest):
|
|||
test_config.load()
|
||||
hostnames = test_config.get_hostnames()
|
||||
CLIENT.host_add(hostnames)
|
||||
job = CLIENT.async_deploy(hostnames=[hostnames[0]])
|
||||
job = CLIENT.deploy(hostnames=[hostnames[0]])
|
||||
job.wait()
|
||||
msg = job.get_console_output()
|
||||
self.assertEqual(job.get_status(), 0,
|
||||
|
@ -201,7 +201,7 @@ class TestFunctional(KollaCliTest):
|
|||
test_config.load()
|
||||
hostnames = test_config.get_hostnames()
|
||||
CLIENT.host_add(hostnames)
|
||||
job = CLIENT.async_upgrade(servicenames=['rabbitmq'])
|
||||
job = CLIENT.upgrade(servicenames=['rabbitmq'])
|
||||
job.wait()
|
||||
msg = job.get_console_output()
|
||||
self.assertEqual(job.get_status(), 0,
|
||||
|
|
|
@ -85,8 +85,8 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
# destroy services, initialize server
|
||||
self.log.info('Start destroy #1')
|
||||
job = CLIENT.async_host_destroy(hostnames, destroy_type='kill',
|
||||
include_data=True)
|
||||
job = CLIENT.host_destroy(hostnames, destroy_type='kill',
|
||||
include_data=True)
|
||||
self._process_job(job, 'destroy #1', is_physical_host)
|
||||
|
||||
self.log.info('updating various properties for the test')
|
||||
|
@ -109,7 +109,7 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
# test killing a deploy
|
||||
self.log.info('Kill a deployment')
|
||||
job = CLIENT.async_deploy()
|
||||
job = CLIENT.deploy()
|
||||
time.sleep(random.randint(5, 8))
|
||||
job.kill()
|
||||
self._process_job(job, 'deploy-kill',
|
||||
|
@ -117,7 +117,7 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
# do a deploy of a limited set of services
|
||||
self.log.info('Start a deployment')
|
||||
job = CLIENT.async_deploy()
|
||||
job = CLIENT.deploy()
|
||||
self._process_job(job, 'deploy', is_physical_host)
|
||||
|
||||
if is_physical_host:
|
||||
|
@ -136,8 +136,8 @@ class TestFunctional(KollaCliTest):
|
|||
'after deploy.')
|
||||
|
||||
self.log.info('Start destroy #3, include data')
|
||||
job = CLIENT.async_host_destroy(hostnames, destroy_type='stop',
|
||||
include_data=True)
|
||||
job = CLIENT.host_destroy(hostnames, destroy_type='stop',
|
||||
include_data=True)
|
||||
self._process_job(job, 'destroy #3', is_physical_host)
|
||||
|
||||
if is_physical_host:
|
||||
|
|
|
@ -230,8 +230,8 @@ class TestFunctional(KollaCliTest):
|
|||
self.check_types(CLIENT.host_remove, [list])
|
||||
self.check_types(CLIENT.host_setup, [dict])
|
||||
self.check_types(CLIENT.host_ssh_check, [list])
|
||||
self.check_types(CLIENT.async_host_destroy, [list, str, int, bool])
|
||||
self.check_types(CLIENT.async_host_precheck, [list, int])
|
||||
self.check_types(CLIENT.host_destroy, [list, str, int, bool])
|
||||
self.check_types(CLIENT.host_precheck, [list, int])
|
||||
|
||||
def test_host_list_nonascii(self):
|
||||
hostname = 'host_test1'
|
||||
|
|
|
@ -34,7 +34,7 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
msg = ''
|
||||
try:
|
||||
job = CLIENT.async_reconfigure()
|
||||
job = CLIENT.reconfigure()
|
||||
job.wait()
|
||||
msg = job.get_console_output()
|
||||
self.assertEqual(job.get_status(), 0,
|
||||
|
|
|
@ -83,7 +83,7 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
# stop services, initialize server
|
||||
self.log.info('Start stop #1')
|
||||
job = CLIENT.async_host_stop(hostnames)
|
||||
job = CLIENT.host_stop(hostnames)
|
||||
self._process_job(job, 'stop #1', is_physical_host)
|
||||
|
||||
self.log.info('updating various properties for the test')
|
||||
|
@ -106,7 +106,7 @@ class TestFunctional(KollaCliTest):
|
|||
|
||||
# do a deploy of a limited set of services
|
||||
self.log.info('Start a deployment')
|
||||
job = CLIENT.async_deploy()
|
||||
job = CLIENT.deploy()
|
||||
self._process_job(job, 'deploy', is_physical_host)
|
||||
|
||||
if is_physical_host:
|
||||
|
@ -125,7 +125,7 @@ class TestFunctional(KollaCliTest):
|
|||
'after deploy.')
|
||||
|
||||
self.log.info('Start stop #2')
|
||||
job = CLIENT.async_host_stop(hostnames)
|
||||
job = CLIENT.host_stop(hostnames)
|
||||
self._process_job(job, 'stop #2', is_physical_host)
|
||||
|
||||
if is_physical_host:
|
||||
|
|
Loading…
Reference in New Issue