diff --git a/doc/build/html/_modules/index.html b/doc/build/html/_modules/index.html index 8f4dc7f..fb992b7 100644 --- a/doc/build/html/_modules/index.html +++ b/doc/build/html/_modules/index.html @@ -6,7 +6,7 @@
-
-# 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.
+# 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
@@ -72,8 +72,8 @@
[docs]class AsyncApi(object):
- # TODO(bmace) -- update this to only take host names
- # and we will probably only support compute host individual deploys
+ # TODO(bmace) -- update this to only take host names
+ # and we will probably only support compute host individual deploys
[docs] def async_deploy(self, hostnames=[], groupnames=[], servicenames=[],
serial_flag=False, verbose_level=1):
"""Deploy.
@@ -93,14 +93,14 @@
:return: Job object
:rtype: Job
"""
- check_arg(hostnames, u._('Host names'), list,
+ check_arg(hostnames, u._('Host names'), list,
empty_ok=True, none_ok=True)
- check_arg(groupnames, u._('Group names'), list,
+ check_arg(groupnames, u._('Group names'), list,
empty_ok=True, none_ok=True)
- check_arg(servicenames, u._('Service names'), list,
+ check_arg(servicenames, u._('Service 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(serial_flag, u._('Serial flag'), bool)
+ check_arg(verbose_level, u._('Verbose level'), int)
hostnames = safe_decode(hostnames)
groupnames = safe_decode(groupnames)
servicenames = safe_decode(servicenames)
@@ -120,7 +120,7 @@
Upgrade containers to new version specified by the property
"openstack_release."
"""
- check_arg(verbose_level, u._('Verbose level'), int)
+ check_arg(verbose_level, u._('Verbose level'), int)
ansible_job = actions.upgrade(verbose_level)
return Job(ansible_job)
@@ -143,14 +143,14 @@
: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)
- if destroy_type not in ['stop', 'kill']:
+ 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)
+ if destroy_type not in ['stop', 'kill']:
raise InvalidArgument(
- u._('Invalid destroy type ({type}). Must be either '
- '"stop" or "kill".').format(type=destroy_type))
+ u._('Invalid destroy type ({type}). Must be either '
+ '"stop" or "kill".').format(type=destroy_type))
hostnames = safe_decode(hostnames)
inventory = Inventory.load()
@@ -173,8 +173,8 @@
:return: Job object
:rtype: Job
"""
- check_arg(hostnames, u._('Host names'), list)
- check_arg(verbose_level, u._('Verbose level'), int)
+ 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)
@@ -214,7 +214,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/api/client.html b/doc/build/html/_modules/kollacli/api/client.html
index 4590517..c927558 100644
--- a/doc/build/html/_modules/kollacli/api/client.html
+++ b/doc/build/html/_modules/kollacli/api/client.html
@@ -6,7 +6,7 @@
- kollacli.api.client — kollacli 1.0.0.dev396 documentation
+ kollacli.api.client — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
-# 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.
+# 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
import logging
@@ -77,9 +77,9 @@
from kollacli.api.service import ServiceApi
from kollacli.api.support import SupportApi
-CONSOLE_MESSAGE_FORMAT = '%(message)s'
+CONSOLE_MESSAGE_FORMAT = '%(message)s'
LOG_FILE_MESSAGE_FORMAT = \
- '[%(asctime)s] %(levelname)-8s %(name)s %(message)s'
+ '[%(asctime)s] %(levelname)-8s %(name)s %(message)s'
LOG = logging.getLogger(__name__)
@@ -98,7 +98,7 @@
self._configure_logging()
[docs] def enable_console_logging(self, level, enable=True):
"""enable/disable console logging for the api
@@ -107,7 +107,7 @@
level: logging.INFO, logging.DEBUG, logging.WARNING,
logging.CRITICAL...
"""
- root_logger = logging.getLogger('')
+ root_logger = logging.getLogger('')
console = logging.StreamHandler(sys.stderr)
if enable:
console.setLevel(level)
@@ -118,7 +118,7 @@
root_logger.removeHandler(console)
def _configure_logging(self):
- root_logger = logging.getLogger('')
+ root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
handler_found = False
@@ -128,18 +128,18 @@
handler_found = True
break
if not handler_found:
- # logger has not been set up
+ # logger has not been set up
try:
rotate_handler = RotatingFileHandler(
os.path.join(os.path.abspath(os.sep),
- 'var', 'log', 'kolla', 'kolla.log'),
+ 'var', 'log', 'kolla', 'kolla.log'),
maxBytes=self._get_kolla_log_file_size(),
backupCount=4)
except IOError as e:
- # most likely the caller is not part of the kolla group
- raise IOError(u._('Permission denied to run the kolla client.'
- '\nPlease add user to the kolla group and '
- 'then log out and back in. {error}')
+ # most likely the caller is not part of the kolla group
+ raise IOError(u._('Permission denied to run the kolla client.'
+ '\nPlease add user to the kolla group and '
+ 'then log out and back in. {error}')
.format(error=str(e)))
formatter = logging.Formatter(LOG_FILE_MESSAGE_FORMAT)
@@ -148,13 +148,13 @@
root_logger.addHandler(rotate_handler)
def _get_kolla_log_file_size(self):
- envvar = 'KOLLA_LOG_FILE_SIZE'
- size_str = os.environ.get(envvar, '500000')
+ envvar = 'KOLLA_LOG_FILE_SIZE'
+ size_str = os.environ.get(envvar, '500000')
try:
size = int(size_str)
except Exception:
- LOG.error(('Environmental variable ({env_var}) is not an '
- 'integer ({log_size}).')
+ LOG.error(('Environmental variable ({env_var}) is not an '
+ 'integer ({log_size}).')
.format(env_var=envvar, log_size=size_str))
size = 50000
return size
-# 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.
+# 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
@@ -82,7 +82,7 @@
: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)
+ check_arg(remote_mode, u._('Remote mode'), bool)
inventory = Inventory.load()
inventory.set_deploy_mode(remote_mode)
Inventory.save(inventory)
-# 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.
+# 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.
"""Exception definitions."""
import kollacli.i18n as u
@@ -68,7 +68,7 @@
"""KollaClient Base Class Exception"""
def __init__(self, message, *args):
if not message:
- message = u._('An unknown exception occurred.')
+ message = u._('An unknown exception occurred.')
super(ClientException, self).__init__(message, *args)
-# 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.
+# 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.
from copy import copy
import kollacli.i18n as u
@@ -99,7 +99,7 @@
:type servicename: string
"""
- check_arg(servicename, u._('Service name'), str)
+ check_arg(servicename, u._('Service name'), str)
servicename = safe_decode(servicename)
inventory = Inventory.load()
inventory.validate_servicenames([servicename])
@@ -107,7 +107,7 @@
group_services = inventory.get_group_services()
self._servicenames = group_services[self.name]
if servicename not in self._servicenames:
- # service not associated with group, add it
+ # service not associated with group, add it
inventory.add_group_to_service(self.name, servicename)
Inventory.save(inventory)
-# 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.
+# 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.
from copy import copy
import kollacli.i18n as u
@@ -97,7 +97,7 @@
:param hostnames: list of strings
"""
- check_arg(hostnames, u._('Host names'), list)
+ check_arg(hostnames, u._('Host names'), list)
hostnames = safe_decode(hostnames)
inventory = Inventory.load()
@@ -114,7 +114,7 @@
:param hostnames: list of strings
"""
- check_arg(hostnames, u._('Host names'), list)
+ check_arg(hostnames, u._('Host names'), list)
hostnames = safe_decode(hostnames)
inventory = Inventory.load()
@@ -146,7 +146,7 @@
:return: hosts
:rtype: Host
"""
- check_arg(hostnames, u._('Host names'), list)
+ check_arg(hostnames, u._('Host names'), list)
hostnames = safe_decode(hostnames)
inventory = Inventory.load()
inventory.validate_hostnames(hostnames)
@@ -171,7 +171,7 @@
:return: check status
:rtype: dictionary
"""
- check_arg(hostnames, u._('Host names'), list)
+ check_arg(hostnames, u._('Host names'), list)
inventory = Inventory.load()
hostnames = safe_decode(hostnames)
inventory.validate_hostnames(hostnames)
@@ -191,7 +191,7 @@
:param hosts_info: dictionary
"""
- check_arg(hosts_info, u._('Hosts info'), dict)
+ check_arg(hosts_info, u._('Hosts info'), dict)
inventory = Inventory.load()
inventory.validate_hostnames(hosts_info.keys())
inventory.setup_hosts(hosts_info)
-# 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.
+# 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.
[docs]class Job(object):
@@ -138,7 +138,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/api/password.html b/doc/build/html/_modules/kollacli/api/password.html
index 2669f23..38041b9 100644
--- a/doc/build/html/_modules/kollacli/api/password.html
+++ b/doc/build/html/_modules/kollacli/api/password.html
@@ -6,7 +6,7 @@
- kollacli.api.password — kollacli 1.0.0.dev396 documentation
+ kollacli.api.password — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
-# 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.
+# 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.common.passwords import clear_password
@@ -78,7 +78,7 @@
:param value: value of the password
:type value: string
"""
- check_arg(name, u._('Password name'), str)
+ check_arg(name, u._('Password name'), str)
set_password(name, value)
-# 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.
+# 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
@@ -71,9 +71,9 @@
LOG = logging.getLogger(__name__)
-GLOBAL_TYPE = 'global'
-GROUP_TYPE = 'group'
-HOST_TYPE = 'host'
+GLOBAL_TYPE = 'global'
+GROUP_TYPE = 'group'
+HOST_TYPE = 'host'
PROP_TYPES = [GLOBAL_TYPE, GROUP_TYPE, HOST_TYPE]
@@ -126,13 +126,13 @@
"""
for key, value in property_dict.items():
- check_arg(key, u._('Property Key'), str)
- check_arg(value, u._('Property Value'), str)
+ check_arg(key, u._('Property Key'), str)
+ check_arg(value, u._('Property Value'), str)
property_dict = safe_decode(property_dict)
self._check_type(property_type)
if property_type is not GLOBAL_TYPE:
- check_arg(change_set, u._('Change Set'), list, none_ok=True)
+ check_arg(change_set, u._('Change Set'), list, none_ok=True)
change_set = safe_decode(change_set)
ansible_properties = AnsibleProperties()
@@ -157,12 +157,12 @@
:type change_set: list of strings
"""
- check_arg(property_list, u._('Property List'), list)
+ check_arg(property_list, u._('Property List'), list)
property_list = safe_decode(property_list)
self._check_type(property_type)
if property_type is not GLOBAL_TYPE:
- check_arg(change_set, u._('Change Set'), list, none_ok=True)
+ check_arg(change_set, u._('Change Set'), list, none_ok=True)
change_set = safe_decode(change_set)
ansible_properties = AnsibleProperties()
@@ -209,8 +209,8 @@
-# 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.
+# 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.
from copy import copy
import kollacli.i18n as u
@@ -143,7 +143,7 @@
:return: services
:rtype: list of Service objects
"""
- check_arg(servicenames, u._('Service names'), list)
+ check_arg(servicenames, u._('Service names'), list)
servicenames = safe_decode(servicenames)
return self._get_services(servicenames)
-# 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.
+# 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
import os
@@ -85,10 +85,10 @@
:return: path to dump file
:rtype: string
"""
- check_arg(dirpath, u._('Directory path'), str)
+ check_arg(dirpath, u._('Directory path'), str)
dirpath = safe_decode(dirpath)
if not os.path.exists(dirpath):
- raise InvalidArgument(u._('Directory path: {path} does not exist')
+ raise InvalidArgument(u._('Directory path: {path} does not exist')
.format(path=dirpath))
dumpfile_path = dump(dirpath)
return dumpfile_path
@@ -108,15 +108,15 @@
:param dirpath: path of directory where log files will be written
:type dirpath: string
"""
- check_arg(dirpath, u._('Directory path'), str)
+ check_arg(dirpath, u._('Directory path'), str)
dirpath = safe_decode(dirpath)
if not os.path.exists(dirpath):
- raise InvalidArgument(u._('Directory path: {path} does not exist')
+ raise InvalidArgument(u._('Directory path: {path} does not exist')
.format(path=dirpath))
- check_arg(servicenames, u._('Service names'), list)
+ check_arg(servicenames, u._('Service names'), list)
servicenames = safe_decode(servicenames)
- check_arg(hostname, u._('Host names'), str)
+ check_arg(hostname, u._('Host names'), str)
hostname = safe_decode(hostname)
get_logs(servicenames, hostname, dirpath)
-# 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.
+# 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 traceback
@@ -78,17 +78,17 @@
"""Deploy."""
[docs] def get_parser(self, prog_name):
parser = super(Deploy, self).get_parser(prog_name)
- parser.add_argument('--hosts', nargs='?',
- metavar='<host_list>',
- help=u._('Deployment host list'))
- parser.add_argument('--groups', nargs='?',
- metavar='<group_list>',
- help=u._('Deployment group list'))
- parser.add_argument('--services', nargs='?',
- metavar='<service_list>',
- help=u._('Deployment service list'))
- parser.add_argument('--serial', action='store_true',
- help=u._('Deploy serially'))
+ parser.add_argument('--hosts', nargs='?',
+ metavar='<host_list>',
+ help=u._('Deployment host list'))
+ parser.add_argument('--groups', nargs='?',
+ metavar='<group_list>',
+ help=u._('Deployment group list'))
+ parser.add_argument('--services', nargs='?',
+ metavar='<service_list>',
+ help=u._('Deployment service list'))
+ parser.add_argument('--serial', action='store_true',
+ help=u._('Deploy serially'))
return parser
[docs] def take_action(self, parsed_args):
@@ -100,13 +100,13 @@
try:
if parsed_args.hosts:
host_list = parsed_args.hosts.strip()
- hosts = host_list.split(',')
+ hosts = host_list.split(',')
if parsed_args.groups:
group_list = parsed_args.groups.strip()
- groups = group_list.split(',')
+ groups = group_list.split(',')
if parsed_args.services:
service_list = parsed_args.services.strip()
- services = service_list.split(',')
+ services = service_list.split(',')
if parsed_args.serial:
serial_flag = True
@@ -114,18 +114,18 @@
verbose_level)
status = job.wait()
if verbose_level > 2:
- LOG.info('\n\n' + 80 * '=')
- LOG.info(u._('DEBUG command output:\n{out}')
+ LOG.info('\n\n' + 80 * '=')
+ LOG.info(u._('DEBUG command output:\n{out}')
.format(out=job.get_console_output()))
if status == 0:
if verbose_level > 1:
- # log any ansible warnings
+ # log any ansible warnings
msg = job.get_error_message()
if msg:
LOG.warn(msg)
- LOG.info(u._('Success'))
+ LOG.info(u._('Success'))
else:
- raise CommandError(u._('Job failed:\n{msg}')
+ raise CommandError(u._('Job failed:\n{msg}')
.format(msg=job.get_error_message()))
except Exception:
@@ -141,20 +141,20 @@
"""
[docs] def get_parser(self, prog_name):
parser = super(Setdeploy, self).get_parser(prog_name)
- parser.add_argument('mode', metavar='<mode>',
- help=u._('mode=<local, remote>'))
+ parser.add_argument('mode', metavar='<mode>',
+ help=u._('mode=<local, remote>'))
return parser
[docs] def take_action(self, parsed_args):
try:
mode = parsed_args.mode.strip()
remote_flag = False
- if mode == 'remote':
+ if mode == 'remote':
remote_flag = True
- elif mode != 'local':
+ elif mode != 'local':
raise CommandError(
- u._('Invalid deploy mode. Mode must be '
- 'either "local" or "remote".'))
+ u._('Invalid deploy mode. Mode must be '
+ 'either "local" or "remote".'))
CLIENT.deploy_set_mode(remote_flag)
except CommandError as e:
raise e
@@ -193,7 +193,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/exceptions.html b/doc/build/html/_modules/kollacli/commands/exceptions.html
index 3d0977f..cfc68c5 100644
--- a/doc/build/html/_modules/kollacli/commands/exceptions.html
+++ b/doc/build/html/_modules/kollacli/commands/exceptions.html
@@ -6,7 +6,7 @@
- kollacli.commands.exceptions — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.exceptions — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.exceptions
-# 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.
+# 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.
"""Exception definitions."""
import kollacli.i18n as u
@@ -67,7 +67,7 @@
[docs]class CommandError(Exception):
"""CLI command error"""
def __init__(self, message, *args):
- prefix = u._('ERROR: ')
+ prefix = u._('ERROR: ')
if not message.startswith(prefix):
message = prefix + message
super(CommandError, self).__init__(message, *args)
@@ -104,7 +104,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/group.html b/doc/build/html/_modules/kollacli/commands/group.html
index 064f91f..b26dde6 100644
--- a/doc/build/html/_modules/kollacli/commands/group.html
+++ b/doc/build/html/_modules/kollacli/commands/group.html
@@ -6,7 +6,7 @@
- kollacli.commands.group — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.group — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.group
-# 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.
+# 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 traceback
import kollacli.i18n as u
@@ -78,8 +78,8 @@
"""Add group to openstack-kolla."""
[docs] def get_parser(self, prog_name):
parser = super(GroupAdd, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -98,8 +98,8 @@
[docs] def get_parser(self, prog_name):
parser = super(GroupRemove, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -117,10 +117,10 @@
"""Add host to group."""
[docs] def get_parser(self, prog_name):
parser = super(GroupAddhost, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
- parser.add_argument('hostname', metavar='<hostname>',
- help=u._('Host name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
+ parser.add_argument('hostname', metavar='<hostname>',
+ help=u._('Host name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -142,10 +142,10 @@
[docs] def get_parser(self, prog_name):
parser = super(GroupRemovehost, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
- parser.add_argument('hostname', metavar='<hostname>',
- help=u._('Host name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
+ parser.add_argument('hostname', metavar='<hostname>',
+ help=u._('Host name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -167,14 +167,14 @@
[docs] def take_action(self, parsed_args):
try:
- data = [('', '')]
+ data = [('', '')]
groups = CLIENT.group_get_all()
if groups:
data = []
for group in groups:
data.append((group.get_name(),
sorted(group.get_hosts())))
- return ((u._('Group'), u._('Hosts')), sorted(data))
+ return ((u._('Group'), u._('Hosts')), sorted(data))
except ClientException as e:
raise CommandError(str(e))
except Exception as e:
@@ -185,10 +185,10 @@
"""Add service to group."""
[docs] def get_parser(self, prog_name):
parser = super(GroupAddservice, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
- parser.add_argument('servicename', metavar='<servicename>',
- help=u._('Service name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
+ parser.add_argument('servicename', metavar='<servicename>',
+ help=u._('Service name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -210,10 +210,10 @@
[docs] def get_parser(self, prog_name):
parser = super(GroupRemoveservice, self).get_parser(prog_name)
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
- parser.add_argument('servicename', metavar='<servicename>',
- help=u._('Service name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
+ parser.add_argument('servicename', metavar='<servicename>',
+ help=u._('Service name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -235,14 +235,14 @@
[docs] def take_action(self, parsed_args):
try:
- data = [('', '')]
+ data = [('', '')]
groups = CLIENT.group_get_all()
if groups:
data = []
for group in groups:
data.append((group.get_name(),
sorted(group.get_services())))
- return ((u._('Group'), u._('Services')), sorted(data))
+ return ((u._('Group'), u._('Services')), sorted(data))
except ClientException as e:
raise CommandError(str(e))
except Exception as e:
@@ -280,7 +280,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/host.html b/doc/build/html/_modules/kollacli/commands/host.html
index 119a37f..e111083 100644
--- a/doc/build/html/_modules/kollacli/commands/host.html
+++ b/doc/build/html/_modules/kollacli/commands/host.html
@@ -6,7 +6,7 @@
- kollacli.commands.host — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.host — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.host
-# 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.
+# 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 argparse
import getpass
import logging
@@ -85,8 +85,8 @@
[docs] def get_parser(self, prog_name):
parser = super(HostAdd, self).get_parser(prog_name)
- parser.add_argument('hostname', metavar='<hostname>',
- help=u._('Host name or ip address'))
+ parser.add_argument('hostname', metavar='<hostname>',
+ help=u._('Host name or ip address'))
return parser
[docs] def take_action(self, parsed_args):
@@ -109,12 +109,12 @@
[docs] def get_parser(self, prog_name):
parser = super(HostDestroy, self).get_parser(prog_name)
- parser.add_argument('hostname', metavar='<hostname | all>',
- help=u._('Host name or ip address or "all"'))
- parser.add_argument('--stop', action='store_true',
- help=u._('Stop rather than kill'))
- parser.add_argument('--includedata', action='store_true',
- help=u._('Destroy data containers'))
+ parser.add_argument('hostname', metavar='<hostname | all>',
+ help=u._('Host name or ip address or "all"'))
+ parser.add_argument('--stop', action='store_true',
+ help=u._('Stop rather than kill'))
+ parser.add_argument('--includedata', action='store_true',
+ help=u._('Destroy data containers'))
return parser
[docs] def take_action(self, parsed_args):
@@ -122,12 +122,12 @@
hostname = parsed_args.hostname.strip()
hostnames = [hostname]
- if hostname == 'all':
+ if hostname == 'all':
hostnames = _get_all_hostnames()
- destroy_type = 'kill'
+ destroy_type = 'kill'
if parsed_args.stop:
- destroy_type = 'stop'
+ destroy_type = 'stop'
include_data = False
if parsed_args.includedata:
include_data = True
@@ -138,14 +138,14 @@
verbose_level, include_data)
status = job.wait()
if verbose_level > 2:
- LOG.info('\n\n' + 80 * '=')
- LOG.info(u._('DEBUG command output:\n{out}')
+ LOG.info('\n\n' + 80 * '=')
+ LOG.info(u._('DEBUG command output:\n{out}')
.format(out=job.get_console_output()))
if status != 0:
- raise CommandError(u._('Job failed:\n{msg}')
+ raise CommandError(u._('Job failed:\n{msg}')
.format(msg=job.get_error_message()))
elif verbose_level > 1:
- # log any ansible warnings
+ # log any ansible warnings
msg = job.get_error_message()
if msg:
LOG.warn(msg)
@@ -161,15 +161,15 @@
[docs] def get_parser(self, prog_name):
parser = super(HostRemove, self).get_parser(prog_name)
- parser.add_argument('hostname', metavar='<hostname | all>',
- help=u._('Host name or "all"'))
+ parser.add_argument('hostname', metavar='<hostname | all>',
+ help=u._('Host name or "all"'))
return parser
[docs] def take_action(self, parsed_args):
try:
hostname = parsed_args.hostname.strip()
hostnames = [hostname]
- if hostname == 'all':
+ if hostname == 'all':
hostnames = _get_all_hostnames()
CLIENT.host_remove(hostnames)
@@ -187,8 +187,8 @@
[docs] def get_parser(self, prog_name):
parser = super(HostList, self).get_parser(prog_name)
- parser.add_argument('hostname', nargs='?', metavar='[hostname]',
- help=u._('Host name'))
+ parser.add_argument('hostname', nargs='?', metavar='[hostname]',
+ help=u._('Host name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -208,9 +208,9 @@
for host in hosts:
data.append((host.name, host.get_groups()))
else:
- data.append(('', ''))
+ data.append(('', ''))
- return ((u._('Host'), u._('Groups')), sorted(data))
+ return ((u._('Host'), u._('Groups')), sorted(data))
except ClientException as e:
raise CommandError(str(e))
@@ -223,52 +223,52 @@
[docs] def get_parser(self, prog_name):
parser = super(HostCheck, self).get_parser(prog_name)
- parser.add_argument('hostname', metavar='<hostname | all>',
- help=u._('Host name or "all"'))
- parser.add_argument('--predeploy', action='store_true',
- help=u._('Run pre-deploy host checks.'))
+ parser.add_argument('hostname', metavar='<hostname | all>',
+ help=u._('Host name or "all"'))
+ parser.add_argument('--predeploy', action='store_true',
+ help=u._('Run pre-deploy host checks.'))
return parser
[docs] def take_action(self, parsed_args):
try:
hostname = parsed_args.hostname.strip()
hostnames = [hostname]
- if hostname == 'all':
+ if hostname == 'all':
hostnames = _get_all_hostnames()
if parsed_args.predeploy:
- # run pre-deploy checks
+ # run pre-deploy checks
verbose_level = self.app.options.verbose_level
job = CLIENT.async_host_precheck(hostnames, verbose_level)
status = job.wait()
if verbose_level > 2:
- LOG.info('\n\n' + 80 * '=')
- LOG.info(u._('DEBUG command output:\n{out}')
+ LOG.info('\n\n' + 80 * '=')
+ LOG.info(u._('DEBUG command output:\n{out}')
.format(out=job.get_console_output()))
if status != 0:
- raise CommandError(u._('Job failed:\n{msg}')
+ raise CommandError(u._('Job failed:\n{msg}')
.format(msg=job.get_error_message()))
elif verbose_level > 1:
- # log any ansible warnings
+ # log any ansible warnings
msg = job.get_error_message()
if msg:
LOG.warn(msg)
else:
- # just do an ssh check
+ # just do an ssh check
summary = CLIENT.host_ssh_check(hostnames)
all_ok = True
for hostname, info in summary.items():
- status = u._('success')
- msg = ''
- if not info['success']:
- status = u._('failed- ')
- msg = info['msg']
+ status = u._('success')
+ msg = ''
+ if not info['success']:
+ status = u._('failed- ')
+ msg = info['msg']
all_ok = False
- LOG.info(u._('Host {host}: {sts} {msg}')
+ LOG.info(u._('Host {host}: {sts} {msg}')
.format(host=hostname, sts=status, msg=msg))
if not all_ok:
- raise CommandError(u._('Host check failed.'))
+ raise CommandError(u._('Host check failed.'))
except ClientException as e:
raise CommandError(str(e))
except Exception as e:
@@ -280,45 +280,45 @@
[docs] def get_parser(self, prog_name):
parser = super(HostSetup, self).get_parser(prog_name)
- parser.add_argument('hostname', nargs='?',
- metavar='<hostname>', help=u._('Host name'))
- parser.add_argument('--insecure', nargs='?', help=argparse.SUPPRESS)
- parser.add_argument('--file', '-f', nargs='?',
- metavar='<hosts_info_file>',
- help=u._('Absolute path to hosts info file '))
+ parser.add_argument('hostname', nargs='?',
+ metavar='<hostname>', help=u._('Host name'))
+ parser.add_argument('--insecure', nargs='?', help=argparse.SUPPRESS)
+ parser.add_argument('--file', '-f', nargs='?',
+ metavar='<hosts_info_file>',
+ help=u._('Absolute path to hosts info file '))
return parser
[docs] def take_action(self, parsed_args):
try:
if not parsed_args.hostname and not parsed_args.file:
raise CommandError(
- u._('Host name or hosts info file path is required.'))
+ u._('Host name or hosts info file path is required.'))
if parsed_args.hostname and parsed_args.file:
raise CommandError(
- u._('Host name and hosts info file path '
- 'cannot both be present.'))
+ u._('Host name and hosts info file path '
+ 'cannot both be present.'))
if parsed_args.file:
- # multi-host setup via xml file
+ # multi-host setup via xml file
hosts_data = self._get_yml_data(parsed_args.file.strip())
CLIENT.host_setup(hosts_data)
else:
- # single host setup
+ # single host setup
hostname = parsed_args.hostname.strip()
summary = CLIENT.host_ssh_check([hostname])
- if summary[hostname]['success']:
+ if summary[hostname]['success']:
LOG.info(
- u._LI('Skipping setup of host ({host}) as '
- 'ssh check is ok.').format(host=hostname))
+ u._LI('Skipping setup of host ({host}) as '
+ 'ssh check is ok.').format(host=hostname))
return True
if parsed_args.insecure:
password = parsed_args.insecure.strip()
else:
password = getpass.getpass(
- u._('kolla password for {host}: ')
+ u._('kolla password for {host}: ')
.format(host=hostname))
- CLIENT.host_setup({hostname: {'password': password}})
+ CLIENT.host_setup({hostname: {'password': password}})
except ClientException as e:
raise CommandError(str(e))
@@ -328,15 +328,15 @@
def _get_yml_data(self, yml_path):
if not os.path.isfile(yml_path):
raise CommandError(
- u._('No file exists at {path}. An absolute file path is '
- 'required.').format(path=yml_path))
+ u._('No file exists at {path}. An absolute file path is '
+ 'required.').format(path=yml_path))
- with open(yml_path, 'r') as hosts_file:
+ with open(yml_path, 'r') as hosts_file:
file_data = hosts_file.read()
hosts_info = yaml.safe_load(file_data)
if not hosts_info:
- raise CommandError(u._('{path} is empty.').format(path=yml_path))
+ raise CommandError(u._('{path} is empty.').format(path=yml_path))
return hosts_info
@@ -379,7 +379,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/password.html b/doc/build/html/_modules/kollacli/commands/password.html
index 0998321..d210383 100644
--- a/doc/build/html/_modules/kollacli/commands/password.html
+++ b/doc/build/html/_modules/kollacli/commands/password.html
@@ -6,7 +6,7 @@
- kollacli.commands.password — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.password — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.password
-# 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.
+# 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 argparse
import getpass
import traceback
@@ -76,13 +76,13 @@
[docs]class PasswordSet(Command):
- "Password Set"
+ "Password Set"
[docs] def get_parser(self, prog_name):
parser = super(PasswordSet, self).get_parser(prog_name)
- parser.add_argument('passwordname', metavar='<passwordname>',
- help=u._('Password name'))
- parser.add_argument('--insecure', nargs='?', help=argparse.SUPPRESS)
+ parser.add_argument('passwordname', metavar='<passwordname>',
+ help=u._('Password name'))
+ parser.add_argument('--insecure', nargs='?', help=argparse.SUPPRESS)
return parser
[docs] def take_action(self, parsed_args):
@@ -91,11 +91,11 @@
if parsed_args.insecure:
password = parsed_args.insecure.strip()
else:
- password = getpass.getpass(u._('Password: ')).strip()
- passtwo = getpass.getpass(u._('Retype Password: ')).strip()
+ password = getpass.getpass(u._('Password: ')).strip()
+ passtwo = getpass.getpass(u._('Retype Password: ')).strip()
if password != passtwo:
- raise CommandError(u._('Passwords do not match'))
+ raise CommandError(u._('Passwords do not match'))
CLIENT.password_set(password_name, password)
@@ -104,12 +104,12 @@
[docs]class PasswordClear(Command):
- "Password Clear"
+ "Password Clear"
[docs] def get_parser(self, prog_name):
parser = super(PasswordClear, self).get_parser(prog_name)
- parser.add_argument('passwordname', metavar='<passwordname>',
- help=u._('Password name'))
+ parser.add_argument('passwordname', metavar='<passwordname>',
+ help=u._('Password name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -130,9 +130,9 @@
data = []
for password_name in password_names:
- data.append((password_name, '-'))
+ data.append((password_name, '-'))
- return ((u._('Password Name'), u._('Password')), data)
+ return ((u._('Password Name'), u._('Password')), data)
except Exception:
raise Exception(traceback.format_exc())
@@ -168,7 +168,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/property.html b/doc/build/html/_modules/kollacli/commands/property.html
index d4ccc35..5d99832 100644
--- a/doc/build/html/_modules/kollacli/commands/property.html
+++ b/doc/build/html/_modules/kollacli/commands/property.html
@@ -6,7 +6,7 @@
- kollacli.commands.property — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.property — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.property
-# 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.
+# 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 traceback
import kollacli.i18n as u
@@ -76,27 +76,27 @@
def _get_names(args_list):
csv_list = args_list[0].strip()
- names = utils.convert_to_unicode(csv_list).split(',')
- if 'all' in names:
+ names = utils.convert_to_unicode(csv_list).split(',')
+ if 'all' in names:
names = None
return names
[docs]class PropertySet(Command):
- "Property Set"
+ "Property Set"
[docs] def get_parser(self, prog_name):
parser = super(PropertySet, self).get_parser(prog_name)
- parser.add_argument('propertyname', metavar='<propertyname>',
- help=u._('Property name'))
- parser.add_argument('propertyvalue', metavar='<propertyvalue',
- help=u._('Property value'))
- parser.add_argument('--hosts', nargs=1,
- metavar='<host_list>',
- help=u._('Property host list'))
- parser.add_argument('--groups', nargs=1,
- metavar='<group_list>',
- help=u._('Property group list'))
+ parser.add_argument('propertyname', metavar='<propertyname>',
+ help=u._('Property name'))
+ parser.add_argument('propertyvalue', metavar='<propertyvalue',
+ help=u._('Property value'))
+ parser.add_argument('--hosts', nargs=1,
+ metavar='<host_list>',
+ help=u._('Property host list'))
+ parser.add_argument('--groups', nargs=1,
+ metavar='<group_list>',
+ help=u._('Property group list'))
return parser
[docs] def take_action(self, parsed_args):
@@ -109,40 +109,40 @@
if parsed_args.hosts:
if parsed_args.groups:
raise CommandError(
- u._('Invalid to use both hosts and groups arguments '
- 'together.'))
+ u._('Invalid to use both hosts and groups arguments '
+ 'together.'))
host_names = _get_names(parsed_args.hosts)
CLIENT.property_set(property_dict,
- 'host', host_names)
+ 'host', host_names)
elif parsed_args.groups:
group_names = _get_names(parsed_args.groups)
CLIENT.property_set(property_dict,
- 'group', group_names)
+ 'group', group_names)
else:
CLIENT.property_set(property_dict,
- 'global')
+ 'global')
except Exception:
raise Exception(traceback.format_exc())
[docs]class PropertyClear(Command):
- "Property Clear"
+ "Property Clear"
[docs] def get_parser(self, prog_name):
parser = super(PropertyClear, self).get_parser(prog_name)
- parser.add_argument('propertyname', metavar='<propertyname>',
- help=u._('Property name'))
- parser.add_argument('--hosts', nargs=1,
- metavar='<host_list>',
- help=u._('Property host list'))
- parser.add_argument('--groups', nargs=1,
- metavar='<group_list>',
- help=u._('Property group list'))
+ parser.add_argument('propertyname', metavar='<propertyname>',
+ help=u._('Property name'))
+ parser.add_argument('--hosts', nargs=1,
+ metavar='<host_list>',
+ help=u._('Property host list'))
+ parser.add_argument('--groups', nargs=1,
+ metavar='<group_list>',
+ help=u._('Property group list'))
return parser
[docs] def take_action(self, parsed_args):
@@ -154,20 +154,20 @@
if parsed_args.hosts:
if parsed_args.groups:
raise CommandError(
- u._('Invalid to use both hosts and groups arguments '
- 'together.'))
+ u._('Invalid to use both hosts and groups arguments '
+ 'together.'))
host_names = _get_names(parsed_args.hosts)
- CLIENT.property_clear(property_list, 'host',
+ CLIENT.property_clear(property_list, 'host',
host_names)
elif parsed_args.groups:
group_names = _get_names(parsed_args.groups)
- CLIENT.property_clear(property_list, 'group',
+ CLIENT.property_clear(property_list, 'group',
group_names)
else:
- CLIENT.property_clear(property_list, 'global')
+ CLIENT.property_clear(property_list, 'global')
except Exception:
raise Exception(traceback.format_exc())
@@ -187,16 +187,16 @@
[docs] def get_parser(self, prog_name):
parser = super(PropertyList, self).get_parser(prog_name)
- parser.add_argument('--all', action='store_true',
- help=u._('List all properties'))
- parser.add_argument('--long', action='store_true',
- help=u._('Show all property attributes'))
- parser.add_argument('--hosts', nargs=1,
- metavar='<host_list>',
- help=u._('Property host list'))
- parser.add_argument('--groups', nargs=1,
- metavar='<group_list>',
- help=u._('Property group list'))
+ parser.add_argument('--all', action='store_true',
+ help=u._('List all properties'))
+ parser.add_argument('--long', action='store_true',
+ help=u._('Show all property attributes'))
+ parser.add_argument('--hosts', nargs=1,
+ metavar='<host_list>',
+ help=u._('Property host list'))
+ parser.add_argument('--groups', nargs=1,
+ metavar='<group_list>',
+ help=u._('Property group list'))
return parser
[docs] def take_action(self, parsed_args):
@@ -209,25 +209,25 @@
if parsed_args.hosts:
if parsed_args.groups:
raise CommandError(
- u._('Invalid to use both hosts and groups arguments '
- 'together.'))
+ u._('Invalid to use both hosts and groups arguments '
+ 'together.'))
self.is_global = False
- self.list_type = u._('Host')
+ self.list_type = u._('Host')
host_names = _get_names(parsed_args.hosts)
- property_list = CLIENT.property_get('host',
+ property_list = CLIENT.property_get('host',
host_names)
elif parsed_args.groups:
self.is_global = False
- self.list_type = u._('Group')
+ self.list_type = u._('Group')
group_names = _get_names(parsed_args.groups)
- property_list = CLIENT.property_get('group',
+ property_list = CLIENT.property_get('group',
group_names)
else:
- property_list = CLIENT.property_get('global')
+ property_list = CLIENT.property_get('global')
data = self._get_list_data(property_list)
header = self._get_list_header()
@@ -240,21 +240,21 @@
header = None
if self.is_long_flag:
if self.is_global:
- header = (u._('OVR'),
- u._('Property Name'), u._('Property Value'),
- u._('Original Value'))
+ header = (u._('OVR'),
+ u._('Property Name'), u._('Property Value'),
+ u._('Original Value'))
else:
- header = (u._('OVR'),
- u._('Property Name'), u._('Property Value'),
- u._('Original Value'),
+ header = (u._('OVR'),
+ u._('Property Name'), u._('Property Value'),
+ u._('Original Value'),
self.list_type)
else:
if self.is_global:
- header = (u._('OVR'),
- u._('Property Name'), u._('Property Value'))
+ header = (u._('OVR'),
+ u._('Property Name'), u._('Property Value'))
else:
- header = (u._('OVR'),
- u._('Property Name'), u._('Property Value'),
+ header = (u._('OVR'),
+ u._('Property Name'), u._('Property Value'),
self.list_type)
return header
@@ -274,16 +274,16 @@
if not include_prop:
continue
- ovr_global = '-'
- ovr_group = '-'
- ovr_host = '-'
+ ovr_global = '-'
+ ovr_group = '-'
+ ovr_host = '-'
if prop.ovr_global:
- ovr_global = '*'
+ ovr_global = '*'
if prop.ovr_group:
- ovr_group = 'G'
+ ovr_group = 'G'
if prop.ovr_host:
- ovr_host = 'H'
+ ovr_host = 'H'
prop_ovr = ovr_global + ovr_group + ovr_host
@@ -303,14 +303,14 @@
else:
if self.is_long_flag:
if self.is_global:
- data.append(('', '', '', ''))
+ data.append(('', '', '', ''))
else:
- data.append(('', '', '', '', ''))
+ data.append(('', '', '', '', ''))
else:
if self.is_global:
- data.append(('', '', ''))
+ data.append(('', '', ''))
else:
- data.append(('', '', '', ''))
+ data.append(('', '', '', ''))
return data
@@ -346,7 +346,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/service.html b/doc/build/html/_modules/kollacli/commands/service.html
index a8d4da5..2f9e462 100644
--- a/doc/build/html/_modules/kollacli/commands/service.html
+++ b/doc/build/html/_modules/kollacli/commands/service.html
@@ -6,7 +6,7 @@
- kollacli.commands.service — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.service — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.service
-# 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.
+# 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 traceback
import kollacli.i18n as u
@@ -83,10 +83,10 @@
[docs] def get_parser(self, prog_name):
parser = super(ServiceAddGroup, self).get_parser(prog_name)
- parser.add_argument('servicename', metavar='<servicename>',
- help=u._('Service name'))
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
+ parser.add_argument('servicename', metavar='<servicename>',
+ help=u._('Service name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -108,10 +108,10 @@
[docs] def get_parser(self, prog_name):
parser = super(ServiceRemoveGroup, self).get_parser(prog_name)
- parser.add_argument('servicename', metavar='<servicename>',
- help=u._('Service name'))
- parser.add_argument('groupname', metavar='<groupname>',
- help=u._('Group name'))
+ parser.add_argument('servicename', metavar='<servicename>',
+ help=u._('Service name'))
+ parser.add_argument('groupname', metavar='<groupname>',
+ help=u._('Group name'))
return parser
[docs] def take_action(self, parsed_args):
@@ -133,23 +133,23 @@
[docs] def take_action(self, parsed_args):
try:
- data = [('', '')]
+ data = [('', '')]
services = CLIENT.service_get_all()
if services:
data = []
for service in services:
- inh_str = '-'
+ inh_str = '-'
groupnames = sorted(service.get_groups())
parentname = service.get_parent()
if parentname:
- # this is a subservice
- inh_str = 'no'
+ # this is a subservice
+ inh_str = 'no'
if not groupnames:
- # sub-service is inheriting groups from parent
- inh_str = 'yes'
- groupnames = ''
+ # sub-service is inheriting groups from parent
+ inh_str = 'yes'
+ groupnames = ''
data.append((service.name, groupnames, inh_str))
- return ((u._('Service'), u._('Groups'), u._('Inherited')),
+ return ((u._('Service'), u._('Groups'), u._('Inherited')),
sorted(data))
except ClientException as e:
raise CommandError(str(e))
@@ -162,15 +162,15 @@
[docs] def take_action(self, parsed_args):
try:
- data = [('', '')]
+ data = [('', '')]
services = CLIENT.service_get_all()
if services:
data = []
for service in services:
if not service.get_parent():
- # this is a service, not a subservice
+ # this is a service, not a subservice
data.append((service.name, service.get_children()))
- return ((u._('Service'), u._('Sub-Services')), sorted(data))
+ return ((u._('Service'), u._('Sub-Services')), sorted(data))
except ClientException as e:
raise CommandError(str(e))
@@ -209,7 +209,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/support.html b/doc/build/html/_modules/kollacli/commands/support.html
index 098a9e7..bc58c14 100644
--- a/doc/build/html/_modules/kollacli/commands/support.html
+++ b/doc/build/html/_modules/kollacli/commands/support.html
@@ -6,7 +6,7 @@
- kollacli.commands.support — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.support — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.support
-# 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.
+# 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.
from cliff.command import Command
from kollacli.api.client import ClientApi
import kollacli.i18n as u
@@ -81,9 +81,9 @@
[docs] def take_action(self, parsed_args):
try:
dump_path = CLIENT.support_dump(tempfile.gettempdir())
- LOG.info(u._('Dump successful to {path}').format(path=dump_path))
+ LOG.info(u._('Dump successful to {path}').format(path=dump_path))
except Exception:
- msg = (u._('Dump failed: {reason}')
+ msg = (u._('Dump failed: {reason}')
.format(reason=traceback.format_exc()))
raise Exception(msg)
@@ -119,7 +119,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/commands/upgrade.html b/doc/build/html/_modules/kollacli/commands/upgrade.html
index 2320c2c..9062a50 100644
--- a/doc/build/html/_modules/kollacli/commands/upgrade.html
+++ b/doc/build/html/_modules/kollacli/commands/upgrade.html
@@ -6,7 +6,7 @@
- kollacli.commands.upgrade — kollacli 1.0.0.dev396 documentation
+ kollacli.commands.upgrade — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.commands.upgrade
-# 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.
+# 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 traceback
@@ -88,13 +88,13 @@
job = CLIENT.async_upgrade(verbose_level)
status = job.wait()
if verbose_level > 2:
- LOG.info('\n\n' + 80 * '=')
- LOG.info(u._('DEBUG command output:\n{out}')
+ 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'))
+ LOG.info(u._('Success'))
else:
- raise CommandError(u._('Job failed:\n{msg}')
+ raise CommandError(u._('Job failed:\n{msg}')
.format(msg=job.get_error_message()))
except Exception:
@@ -132,7 +132,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/ansible/actions.html b/doc/build/html/_modules/kollacli/common/ansible/actions.html
index 048cebe..def924e 100644
--- a/doc/build/html/_modules/kollacli/common/ansible/actions.html
+++ b/doc/build/html/_modules/kollacli/common/ansible/actions.html
@@ -6,7 +6,7 @@
- kollacli.common.ansible.actions — kollacli 1.0.0.dev396 documentation
+ kollacli.common.ansible.actions — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.common.ansible.actions
-# 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.
+# 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 os
@@ -88,26 +88,26 @@
or killed. That will be determined by the destroy_type,
which can either be 'stop' or 'kill'.
'''
- playbook_name = 'host_destroy_no_data.yml'
+ playbook_name = 'host_destroy_no_data.yml'
if include_data:
- playbook_name = 'host_destroy.yml'
+ playbook_name = 'host_destroy.yml'
- LOG.info(u._LI('Please be patient as this may take a while.'))
+ LOG.info(u._LI('Please be patient as this may take a while.'))
ansible_properties = properties.AnsibleProperties()
base_distro = \
- ansible_properties.get_property('kolla_base_distro')
+ ansible_properties.get_property('kolla_base_distro')
install_type = \
- ansible_properties.get_property('kolla_install_type')
- container_prefix = base_distro + '-' + install_type
+ ansible_properties.get_property('kolla_install_type')
+ container_prefix = base_distro + '-' + install_type
kollacli_home = get_kollacli_home()
playbook = AnsiblePlaybook()
playbook.playbook_path = os.path.join(kollacli_home,
- 'ansible/' + playbook_name)
+ 'ansible/' + playbook_name)
- # 'hosts' is defined as 'all' in the playbook yml code, but inventory
- # filtering will subset that down to the hosts in playbook.hosts.
- playbook.extra_vars = 'prefix=' + container_prefix + \
- ' destroy_type=' + destroy_type
+ # 'hosts' is defined as 'all' in the playbook yml code, but inventory
+ # filtering will subset that down to the hosts in playbook.hosts.
+ playbook.extra_vars = 'prefix=' + container_prefix + \
+ ' destroy_type=' + destroy_type
playbook.hosts = hostnames
if verbose_level <= 1:
playbook.print_output = False
@@ -121,7 +121,7 @@
playbook = AnsiblePlaybook()
kolla_home = get_kolla_home()
playbook.playbook_path = os.path.join(kolla_home,
- 'ansible/site.yml')
+ 'ansible/site.yml')
playbook.hosts = hostnames
playbook.groups = groupnames
playbook.services = servicenames
@@ -137,15 +137,15 @@
[docs]def precheck(hostnames, verbose_level=1):
'''run check playbooks on a set of hosts'''
- playbook_name = 'prechecks.yml'
+ playbook_name = 'prechecks.yml'
kolla_home = get_kolla_home()
playbook = AnsiblePlaybook()
playbook.playbook_path = os.path.join(kolla_home,
- 'ansible/' + playbook_name)
+ 'ansible/' + playbook_name)
- # define 'hosts' to be all, but inventory filtering will subset
- # that down to the hosts in playbook.hosts.
- playbook.extra_vars = 'hosts=all'
+ # define 'hosts' to be all, but inventory filtering will subset
+ # that down to the hosts in playbook.hosts.
+ playbook.extra_vars = 'hosts=all'
playbook.hosts = hostnames
playbook.print_output = True
playbook.verbose_level = verbose_level
@@ -157,8 +157,8 @@
playbook = AnsiblePlaybook()
kolla_home = get_kolla_home()
playbook.playbook_path = os.path.join(kolla_home,
- 'ansible/site.yml')
- playbook.extra_vars = 'action=upgrade'
+ 'ansible/site.yml')
+ playbook.extra_vars = 'action=upgrade'
playbook.print_output = True
playbook.verbose_level = verbose_level
job = playbook.run()
@@ -169,21 +169,21 @@
properties = AnsibleProperties()
inventory = Inventory.load()
- # cannot have both groups and hosts
+ # cannot have both groups and hosts
if playbook.hosts and playbook.groups:
raise InvalidArgument(
- u._('Hosts and Groups arguments cannot '
- 'both be present at the same time.'))
+ u._('Hosts and Groups arguments cannot '
+ 'both be present at the same time.'))
- # verify that all services exists
+ # verify that all services exists
if playbook.services:
for service in playbook.services:
valid_service = inventory.get_service(service)
if not valid_service:
- raise NotInInventory(u._('Service'), service)
+ raise NotInInventory(u._('Service'), service)
- # check that every group with enabled services
- # has hosts associated to it
+ # check that every group with enabled services
+ # has hosts associated to it
group_services = inventory.get_group_services()
failed_groups = []
failed_services = []
@@ -203,29 +203,29 @@
if len(failed_groups) > 0:
raise InvalidConfiguration(
- u._('Deploy failed. '
- 'Groups: {groups} with enabled '
- 'services : {services} '
- 'have no associated hosts')
+ u._('Deploy failed. '
+ 'Groups: {groups} with enabled '
+ 'services : {services} '
+ 'have no associated hosts')
.format(groups=failed_groups, services=failed_services))
- # check that ring files are in /etc/kolla/config/swift if
- # swift is enabled
- expected_files = ['account.ring.gz',
- 'container.ring.gz',
- 'object.ring.gz']
- is_enabled = properties.get_property('enable_swift')
+ # check that ring files are in /etc/kolla/config/swift if
+ # swift is enabled
+ expected_files = ['account.ring.gz',
+ 'container.ring.gz',
+ 'object.ring.gz']
+ is_enabled = properties.get_property('enable_swift')
if is_string_true(is_enabled):
- path_pre = os.path.join(get_kolla_etc(), 'config', 'swift')
+ path_pre = os.path.join(get_kolla_etc(), 'config', 'swift')
for expected_file in expected_files:
path = os.path.join(path_pre, expected_file)
if not os.path.isfile(path):
msg = u._(
- 'Deploy failed. '
- 'Swift is enabled but ring buffers have '
- 'not yet been set up. Please see the '
- 'documentation for swift configuration '
- 'instructions.')
+ 'Deploy failed. '
+ 'Swift is enabled but ring buffers have '
+ 'not yet been set up. Please see the '
+ 'documentation for swift configuration '
+ 'instructions.')
raise InvalidConfiguration(msg)
@@ -235,13 +235,13 @@
sub_service = inventory.get_sub_service(servicename)
if sub_service is not None:
- enabled_property = 'enable_' + servicename.replace('-', '_')
+ enabled_property = 'enable_' + servicename.replace('-', '_')
is_enabled = properties.get_property(enabled_property)
if is_string_true(is_enabled):
service_enabled = True
- # Only bother looking at the parent service if the sub service
- # is enabled.
+ # Only bother looking at the parent service if the sub service
+ # is enabled.
if service_enabled:
servicename = sub_service.get_parent_servicename()
if servicename is None:
@@ -249,7 +249,7 @@
service = inventory.get_service(servicename)
if service is not None:
- enabled_property = 'enable_' + servicename.replace('-', '_')
+ enabled_property = 'enable_' + servicename.replace('-', '_')
is_enabled = properties.get_property(enabled_property)
if is_string_true(is_enabled):
service_enabled = True
@@ -300,7 +300,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/ansible/job.html b/doc/build/html/_modules/kollacli/common/ansible/job.html
index 5b7d313..65cbdec 100644
--- a/doc/build/html/_modules/kollacli/common/ansible/job.html
+++ b/doc/build/html/_modules/kollacli/common/ansible/job.html
@@ -6,7 +6,7 @@
- kollacli.common.ansible.job — kollacli 1.0.0.dev396 documentation
+ kollacli.common.ansible.job — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,25 +47,25 @@
Source code for kollacli.common.ansible.job
-# 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.
+# 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 fcntl
import json
import logging
import os
import pwd
-import subprocess # nosec
+import subprocess # nosec
import tempfile
import time
@@ -85,14 +85,14 @@
LINE_LENGTH = 80
-PIPE_PREFIX = '.kolla_pipe_'
+PIPE_PREFIX = '.kolla_pipe_'
-# action defs
-ACTION_PLAY_START = 'play_start'
-ACTION_TASK_START = 'task_start'
-ACTION_TASK_END = 'task_end'
-ACTION_INCLUDE_FILE = 'includefile'
-ACTION_STATS = 'stats'
+# action defs
+ACTION_PLAY_START = 'play_start'
+ACTION_TASK_START = 'task_start'
+ACTION_TASK_END = 'task_end'
+ACTION_INCLUDE_FILE = 'includefile'
+ACTION_STATS = 'stats'
[docs]class AnsibleJob(object):
@@ -104,43 +104,41 @@
self._print_output = print_output
self._temp_inv_path = inventory_path
- self._fragment = ''
+ self._fragment = ''
self._is_first_packet = True
self._fifo_path = os.path.join(
- tempfile.gettempdir(), '%s_%s' % (PIPE_PREFIX, self._deploy_id))
+ tempfile.gettempdir(), '%s_%s' % (PIPE_PREFIX, self._deploy_id))
self._fifo_fd = None
self._process = None
self._process_std_err = None
self._errors = []
- self._cmd_output = ''
+ self._cmd_output = ''
self._kill_uname = None
- self._ansible_lock = Lock(get_ansible_lock_path(), 'ansible_job')
+ self._ansible_lock = Lock(get_ansible_lock_path(), 'ansible_job')
[docs] def run(self):
try:
locked = self._ansible_lock.wait_acquire()
if not locked:
raise Exception(
- u._('unable to run ansible job {cmd} '
- 'as we couldn\'t get lock held by {owner}:{pid}.')
- .format(cmd=self._command,
- owner=self._ansible_lock.current_owner,
- pid=self._ansible_lock.current_pid))
+ u._('unable to run ansible job {cmd} '
+ 'as we couldn\'t get lock.')
+ .format(cmd=self._command))
- # create and open named pipe, must be owned by kolla group
+ # create and open named pipe, must be owned by kolla group
os.mkfifo(self._fifo_path, 0o660)
_, grp_id = get_admin_uids()
os.chown(self._fifo_path, os.getuid(), grp_id)
self._fifo_fd = os.open(self._fifo_path,
os.O_RDONLY | os.O_NONBLOCK)
- self._process = subprocess.Popen(self._command, # nosec
+ self._process = subprocess.Popen(self._command, # nosec
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- # setup stdout to be read without blocking
- LOG.debug('process pid: %s' % self._process.pid)
+ # setup stdout to be read without blocking
+ LOG.debug('process pid: %s' % self._process.pid)
flags = fcntl.fcntl(self._process.stdout, fcntl.F_GETFL)
fcntl.fcntl(self._process.stdout, fcntl.F_SETFL,
(flags | os.O_NONBLOCK))
@@ -172,12 +170,12 @@
status = self._process.poll()
self._read_from_callback()
out = self._read_stream(self._process.stdout)
- self._cmd_output = ''.join([self._cmd_output, out])
+ self._cmd_output = ''.join([self._cmd_output, out])
if status is not None:
- # job has completed
+ # job has completed
if self._kill_uname:
status = 2
- msg = (u._('Job killed by user ({name})')
+ msg = (u._('Job killed by user ({name})')
.format(name=self._kill_uname))
self._errors = [msg]
else:
@@ -185,7 +183,7 @@
if status != 0:
status = 1
if not self._process_std_err:
- # read stderr from process
+ # read stderr from process
std_err = self._read_stream(self._process.stderr)
self._process_std_err = std_err.strip()
self._cleanup()
@@ -193,11 +191,11 @@
[docs] def get_error_message(self):
""""get error message"""
- msg = ''
+ msg = ''
for error in self._errors:
- msg = ''.join([msg, error, '\n'])
+ msg = ''.join([msg, error, '\n'])
- # if no error from the callback, check the process error
+ # if no error from the callback, check the process error
if not msg:
msg = self._process_std_err
return msg
@@ -215,35 +213,35 @@
The process pid is owned by root, so
that is not killable. Need to kill all its children.
"""
- # the kill must be run as the kolla user so the
- # kolla_actions program must be used.
+ # the kill must be run as the kolla user so the
+ # kolla_actions program must be used.
actions_path = get_kolla_actions_path()
kolla_user = get_admin_user()
- cmd_prefix = ('/usr/bin/sudo -u %s %s job -t -p '
+ cmd_prefix = ('/usr/bin/sudo -u %s %s job -t -p '
% (kolla_user, actions_path))
- # kill the children from largest to smallest pids.
+ # kill the children from largest to smallest pids.
child_pids = PidManager.get_child_pids(self._process.pid)
for child_pid in sorted(child_pids, reverse=True):
- cmd = ''.join([cmd_prefix, child_pid])
+ cmd = ''.join([cmd_prefix, child_pid])
err_msg, output = run_cmd(cmd, print_output=False)
if err_msg:
- LOG.debug('kill failed: %s %s' % (err_msg, output))
+ LOG.debug('kill failed: %s %s' % (err_msg, output))
- # record the name of user who killed the job
+ # record the name of user who killed the job
cur_uid = os.getuid()
self._kill_uname = pwd.getpwuid(cur_uid)[0]
def _read_stream(self, stream):
- out = ''
+ out = ''
if stream and not stream.closed:
try:
out = safe_decode(stream.read())
- except IOError: # nosec
- # error can happen if stream is empty
+ except IOError: # nosec
+ # error can happen if stream is empty
pass
if out is None:
- out = ''
+ out = ''
return out
def _log_lines(self, lines):
@@ -258,13 +256,13 @@
- close stdout and stderr
- close and delete named pipe (fifo)
"""
- # try to clear the ansible lock
+ # try to clear the ansible lock
self._ansible_lock.release()
- # delete temp inventory file
+ # delete temp inventory file
remove_temp_inventory(self._temp_inv_path)
- # close the process's stdout and stderr streams
+ # close the process's stdout and stderr streams
if (self._process and self._process.stdout and not
self._process.stdout.closed):
self._process.stdout.close()
@@ -272,12 +270,12 @@
self._process.stderr.closed):
self._process.stderr.close()
- # close and delete the named pipe (fifo)
+ # close and delete the named pipe (fifo)
if self._fifo_fd:
try:
os.close(self._fifo_fd)
- except OSError: # nosec
- # fifo already closed
+ except OSError: # nosec
+ # fifo already closed
pass
if self._fifo_path and os.path.exists(self._fifo_path):
os.remove(self._fifo_path)
@@ -288,18 +286,18 @@
try:
data = os.read(self._fifo_fd, 1000000)
data = safe_decode(data)
- except OSError: # nosec
- # error can happen if fifo is empty
+ except OSError: # nosec
+ # error can happen if fifo is empty
pass
if data:
packets = self._deserialize_packets(data)
for packet in packets:
formatted_data = self._format_packet(packet)
- lines = formatted_data.split('\n')
+ lines = formatted_data.split('\n')
self._log_lines(lines)
def _format_packet(self, packet):
- action = packet['action']
+ action = packet['action']
if action == ACTION_INCLUDE_FILE:
return self._format_include_file(packet)
elif action == ACTION_PLAY_START:
@@ -311,101 +309,112 @@
elif action == ACTION_TASK_START:
return self._format_task_start(packet)
else:
- raise Exception(u._('Invalid action [{action}] from callback')
+ raise Exception(u._('Invalid action [{action}] from callback')
.format(action=action))
def _format_include_file(self, packet):
- return 'included: %s' % packet['filename']
+ return 'included: %s' % packet['filename']
def _format_play_start(self, packet):
- msg = '\n' + self._add_filler('PLAY ', LINE_LENGTH, '*')
+ msg = '\n' + self._add_filler('PLAY ', LINE_LENGTH, '*')
if self._is_first_packet:
- msg += '\nPlaybook: %s' % packet['playbook']
+ msg += '\nPlaybook: %s' % packet['playbook']
self._is_first_packet = False
return msg
def _format_stats(self, packet):
- # each element is a dictionary with host as key
- msg = '\n' + self._add_filler('PLAY RECAP ', LINE_LENGTH, '*')
- processed = packet['processed']
- ok = packet['ok']
- changed = packet['changed']
- unreachable = packet['unreachable']
- failures = packet['failures']
+ # each element is a dictionary with host as key
+ msg = '\n' + self._add_filler('PLAY RECAP ', LINE_LENGTH, '*')
+ processed = packet['processed']
+ ok = packet['ok']
+ changed = packet['changed']
+ unreachable = packet['unreachable']
+ failures = packet['failures']
for host in processed:
- hostline = '\n%s' % self._add_filler(host, 28, ' ')
- hostline += (': ok=%s'
- % self._add_filler('%s' % ok[host], 5, ' '))
- hostline += ('changed=%s'
- % self._add_filler('%s' % changed[host], 5, ' '))
- hostline += ('unreachable=%s'
- % self._add_filler('%s' % unreachable[host], 5, ' '))
- hostline += 'failed=%s' % failures[host]
+ hostline = '\n%s' % self._add_filler(host, 28, ' ')
+ hostline += (': ok=%s'
+ % self._add_filler('%s' % ok[host], 5, ' '))
+ hostline += ('changed=%s'
+ % self._add_filler('%s' % changed[host], 5, ' '))
+ hostline += ('unreachable=%s'
+ % self._add_filler('%s' % unreachable[host], 5, ' '))
+ hostline += 'failed=%s' % failures[host]
msg += hostline
return msg
def _format_task_end(self, packet):
- host = packet['host']
- status = packet['status']
- msg = '%s: [%s]' % (status, host)
- if status == 'failed' or status == 'unreachable':
- results_dict = packet['results']
- taskname = packet['task']['name']
+ host = packet['host']
+ status = packet['status']
+ msg = '%s: [%s]' % (status, host)
+ if status == 'failed' or status == 'unreachable':
+ results_dict = packet['results']
+ taskname = packet['task']['name']
- # update saved error messages
+ # update saved error messages
self._errors.append(self._format_error(taskname, host,
status, results_dict))
- # format log message
+ # format log message
results = json.dumps(results_dict)
- msg = 'fatal: [%s]: %s! => %s' % (host, status.upper(), results)
+ msg = 'fatal: [%s]: %s! => %s' % (host, status.upper(), results)
return msg
def _format_task_start(self, packet):
- taskname = packet['name']
- task_line = 'TASK [%s] ' % taskname
- msg = '\n' + self._add_filler(task_line, LINE_LENGTH, '*')
+ taskname = packet['name']
+ task_line = 'TASK [%s] ' % taskname
+ msg = '\n' + self._add_filler(task_line, LINE_LENGTH, '*')
return msg
def _format_error(self, taskname, host, status, results):
- # get the primary error message
- err_msg = results.get('msg', '')
+ # get the primary error message
+ err_msg = self._safe_get(results, 'msg')
- # there may be more detailed error msgs under results
- sub_results = results.get('results', None)
+ # there may be more detailed error msgs under results
+ sub_results = self._safe_get(results, 'results')
if sub_results:
- sub_errs = ''
- comma = ''
+ sub_errs = ''
+ comma = ''
for invocation in sub_results:
- is_failed = invocation.get('failed', False)
+ is_failed = invocation.get('failed', False)
if is_failed is True:
- sub_msg = invocation.get('msg', '')
- sub_errs = ''.join([sub_errs, comma, sub_msg])
+ sub_msg = self._safe_get(invocation, 'msg')
+ if not sub_msg:
+ sub_msg = self._safe_get(invocation, 'stderr')
+ if not sub_msg:
+ self._safe_get(invocation, 'stdout')
+ sub_errs = ''.join([sub_errs, comma, sub_msg])
if sub_msg:
- comma = ', '
+ comma = ', '
if sub_errs:
- err_msg = ''.join([err_msg, ' [', sub_errs, ']'])
+ err_msg = ''.join([err_msg, ' [', sub_errs, ']'])
if not err_msg or not err_msg.strip():
- # sometimes the error message is in std_out
- # eg- "stdout": 'localhost | FAILED! => {"changed": false,
- # "failed": true, "msg": "...msg..."}'
- stdout = results.get('stdout', '')
- if '"msg": "' in stdout:
- err_msg = stdout.split('"msg": "')[1]
- err_msg = err_msg.split('"')[0]
+ # sometimes the error message is in std_out
+ # eg- "stdout": 'localhost | FAILED! => {"changed": false,
+ # "failed": true, "msg": "...msg..."}'
+ stdout = self._safe_get(results, 'stdout')
+ if '"msg": "' in stdout:
+ err_msg = stdout.split('"msg": "')[1]
+ err_msg = err_msg.split('"')[0]
if not err_msg:
err_msg = stdout
if not err_msg or not err_msg.strip():
- # if still no err_msg, provide entire result
+ # if still no err_msg, provide entire result
try:
err_msg = json.dumps(results)
except Exception as e:
- LOG.debug('unable to convert results to string' % str(e))
- msg = ('Host: %s, Task: %s, Status: %s, Message: %s' %
+ LOG.debug('unable to convert results to string' % str(e))
+ msg = ('Host: %s, Task: %s, Status: %s, Message: %s' %
(host, taskname, status, err_msg))
return msg
+ def _safe_get(self, dictionary, key):
+ """get value, never return None"""
+ val = dictionary.get(key, '')
+ if val is None:
+ val = ''
+ return val
+
def _add_filler(self, msg, length, filler):
num_stars = max(length - len(msg), 0)
stars = num_stars * filler
@@ -421,29 +430,29 @@
"""
packets = []
has_fragment = True
- if data.endswith('\n'):
+ if data.endswith('\n'):
has_fragment = False
i = 0
- lines = data.split('\n')
+ lines = data.split('\n')
num_lines = len(lines)
for line in lines:
if not line:
- # ignore empty string lines
+ # ignore empty string lines
continue
i += 1
if i == 1:
- # first line
+ # first line
line = self._fragment + line
- self._fragment = ''
+ self._fragment = ''
elif i == num_lines - 1:
- # last line
+ # last line
if has_fragment:
self._fragment = line
continue
try:
packets.append(json.loads(line))
except Exception as e:
- LOG.error('invalid line for json encoding: %s' % line)
+ LOG.error('invalid line for json encoding: %s' % line)
raise e
return packets
@@ -479,7 +488,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/ansible/playbook.html b/doc/build/html/_modules/kollacli/common/ansible/playbook.html
index 25a4b58..1197faf 100644
--- a/doc/build/html/_modules/kollacli/common/ansible/playbook.html
+++ b/doc/build/html/_modules/kollacli/common/ansible/playbook.html
@@ -6,7 +6,7 @@
- kollacli.common.ansible.playbook — kollacli 1.0.0.dev396 documentation
+ kollacli.common.ansible.playbook — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.common.ansible.playbook
-# 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.
+# 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 os
import traceback
@@ -78,8 +78,8 @@
[docs]class AnsiblePlaybook(object):
- playbook_path = ''
- extra_vars = ''
+ playbook_path = ''
+ extra_vars = ''
include_passwords = True
flush_cache = True
print_output = True
@@ -98,7 +98,7 @@
cmd = self._get_playbook_cmd(inventory_path)
self._log_ansible_cmd(cmd, inventory_path)
- # create and run the job
+ # create and run the job
job = AnsibleJob(cmd, self.deploy_id,
self.print_output, inventory_path)
job.run()
@@ -108,46 +108,46 @@
raise Exception(traceback.format_exc())
def _get_playbook_cmd(self, inventory_path):
- flag = ''
- # verbose levels: 1=not verbose, 2=more verbose
+ flag = ''
+ # verbose levels: 1=not verbose, 2=more verbose
if self.verbose_level > 1:
- flag = '-vvv'
+ flag = '-vvv'
ansible_cmd = get_ansible_command(playbook=True)
admin_user = get_admin_user()
- cmd = '/usr/bin/sudo -u %s %s %s' % (admin_user, ansible_cmd, flag)
+ cmd = '/usr/bin/sudo -u %s %s %s' % (admin_user, ansible_cmd, flag)
- cmd += ' -i %s' % inventory_path
+ cmd += ' -i %s' % inventory_path
if self.include_passwords:
- cmd += ' %s' % self._get_password_path()
+ cmd += ' %s' % self._get_password_path()
- cmd += ' %s' % self.playbook_path
+ cmd += ' %s' % self.playbook_path
if self.extra_vars or self.serial:
- extra_vars = ''
+ extra_vars = ''
if self.extra_vars:
extra_vars = self.extra_vars
if self.serial:
- extra_vars += ' '
+ extra_vars += ' '
if self.serial:
- extra_vars += 'serial_var=1'
+ extra_vars += 'serial_var=1'
- cmd += ' --extra-vars \"%s\"' % extra_vars
+ cmd += ' --extra-vars \"%s\"' % extra_vars
if self.services:
- service_string = ''
+ service_string = ''
first = True
for service in self.services:
if not first:
- service_string = service_string + ','
+ service_string = service_string + ','
else:
first = False
service_string = service_string + service
- cmd += ' --tags %s' % service_string
+ cmd += ' --tags %s' % service_string
if self.flush_cache:
- cmd += ' --flush-cache'
+ cmd += ' --flush-cache'
return cmd
def _make_temp_inventory(self):
@@ -163,37 +163,37 @@
for hostname in self.hosts:
host = self.inventory.get_host(hostname)
if not host:
- raise NotInInventory(u._('Host'), hostname)
- inventory_filter['deploy_hosts'] = self.hosts
+ raise NotInInventory(u._('Host'), hostname)
+ inventory_filter['deploy_hosts'] = self.hosts
elif self.groups:
for groupname in self.groups:
group = self.inventory.get_group(groupname)
if not group:
- raise NotInInventory(u._('Group'), groupname)
- inventory_filter['deploy_groups'] = self.groups
+ raise NotInInventory(u._('Group'), groupname)
+ inventory_filter['deploy_groups'] = self.groups
inventory_path = \
self.inventory.create_json_gen_file(inventory_filter)
- # inv path = /tmp/kolla_UUID/temp_inventory.py
+ # inv path = /tmp/kolla_UUID/temp_inventory.py
deploy_id = os.path.dirname(inventory_path)
- self.deploy_id = deploy_id.split('kolla_')[1]
+ self.deploy_id = deploy_id.split('kolla_')[1]
return inventory_path
def _get_password_path(self):
kolla_etc = get_kolla_etc()
- return ('-e @' + os.path.join(kolla_etc, 'passwords.yml '))
+ return ('-e @' + os.path.join(kolla_etc, 'passwords.yml '))
def _log_ansible_cmd(self, cmd, inventory_path):
if self.verbose_level > 2:
- # log the ansible command
- LOG.debug('cmd:\n%s' % cmd)
+ # log the ansible command
+ LOG.debug('cmd:\n%s' % cmd)
if self.verbose_level > 3:
- # log the inventory
- with open(inventory_path, 'r') as inv_file:
+ # log the inventory
+ with open(inventory_path, 'r') as inv_file:
inv = inv_file.read()
- LOG.debug('\ninventory: \n%s' % inv)
+ LOG.debug('\ninventory: \n%s' % inv)
@@ -227,7 +227,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/inventory.html b/doc/build/html/_modules/kollacli/common/inventory.html
index fe22e69..abdb2b7 100644
--- a/doc/build/html/_modules/kollacli/common/inventory.html
+++ b/doc/build/html/_modules/kollacli/common/inventory.html
@@ -6,7 +6,7 @@
- kollacli.common.inventory — kollacli 1.0.0.dev396 documentation
+ kollacli.common.inventory — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.common.inventory
-# 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.
+# 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 json
import jsonpickle
import logging
@@ -86,17 +86,17 @@
from kollacli.common.utils import sync_read_file
from kollacli.common.utils import sync_write_file
-ANSIBLE_SSH_USER = 'ansible_ssh_user'
-ANSIBLE_CONNECTION = 'ansible_connection'
-ANSIBLE_BECOME = 'ansible_become'
+ANSIBLE_SSH_USER = 'ansible_ssh_user'
+ANSIBLE_CONNECTION = 'ansible_connection'
+ANSIBLE_BECOME = 'ansible_become'
-INVENTORY_PATH = 'ansible/inventory.json'
+INVENTORY_PATH = 'ansible/inventory.json'
-COMPUTE_GRP_NAME = 'compute'
-CONTROL_GRP_NAME = 'control'
-NETWORK_GRP_NAME = 'network'
-STORAGE_GRP_NAME = 'storage'
-DATABASE_GRP_NAME = 'database'
+COMPUTE_GRP_NAME = 'compute'
+CONTROL_GRP_NAME = 'control'
+NETWORK_GRP_NAME = 'network'
+STORAGE_GRP_NAME = 'storage'
+DATABASE_GRP_NAME = 'database'
DEPLOY_GROUPS = [
COMPUTE_GRP_NAME,
@@ -107,57 +107,57 @@
]
SERVICES = {
- 'ceilometer': ['ceilometer-alarm-evaluator', 'ceilometer-alarm-notifier',
- 'ceilometer-api', 'ceilometer-central',
- 'ceilometer-collector', 'ceilometer-notification'],
- 'cinder': ['cinder-api', 'cinder-scheduler', 'cinder-backup',
- 'cinder-volume'],
- 'glance': ['glance-api', 'glance-registry'],
- 'haproxy': [],
- 'heat': ['heat-api', 'heat-api-cfn', 'heat-engine'],
- 'horizon': [],
- 'keystone': [],
- 'memcached': [],
- 'murano': ['murano-api', 'murano-engine'],
- 'mysqlcluster': ['mysqlcluster-api', 'mysqlcluster-mgmt',
- 'mysqlcluster-ndb'],
- 'neutron': ['neutron-server', 'neutron-agents'],
- 'nova': ['nova-api', 'nova-conductor', 'nova-consoleauth',
- 'nova-novncproxy', 'nova-scheduler'],
- 'rabbitmq': [],
- 'swift': ['swift-proxy-server', 'swift-account-server',
- 'swift-container-server', 'swift-object-server'],
+ 'ceilometer': ['ceilometer-alarm-evaluator', 'ceilometer-alarm-notifier',
+ 'ceilometer-api', 'ceilometer-central',
+ 'ceilometer-collector', 'ceilometer-notification'],
+ 'cinder': ['cinder-api', 'cinder-scheduler', 'cinder-backup',
+ 'cinder-volume'],
+ 'glance': ['glance-api', 'glance-registry'],
+ 'haproxy': [],
+ 'heat': ['heat-api', 'heat-api-cfn', 'heat-engine'],
+ 'horizon': [],
+ 'keystone': [],
+ 'memcached': [],
+ 'murano': ['murano-api', 'murano-engine'],
+ 'mysqlcluster': ['mysqlcluster-api', 'mysqlcluster-mgmt',
+ 'mysqlcluster-ndb'],
+ 'neutron': ['neutron-server', 'neutron-agents'],
+ 'nova': ['nova-api', 'nova-conductor', 'nova-consoleauth',
+ 'nova-novncproxy', 'nova-scheduler'],
+ 'rabbitmq': [],
+ 'swift': ['swift-proxy-server', 'swift-account-server',
+ 'swift-container-server', 'swift-object-server'],
}
DEFAULT_GROUPS = {
- 'ceilometer': CONTROL_GRP_NAME,
- 'cinder': CONTROL_GRP_NAME,
- 'glance': CONTROL_GRP_NAME,
- 'haproxy': CONTROL_GRP_NAME,
- 'heat': CONTROL_GRP_NAME,
- 'horizon': CONTROL_GRP_NAME,
- 'keystone': CONTROL_GRP_NAME,
- 'memcached': CONTROL_GRP_NAME,
- 'murano': CONTROL_GRP_NAME,
- 'mysqlcluster': CONTROL_GRP_NAME,
- 'neutron': NETWORK_GRP_NAME,
- 'nova': CONTROL_GRP_NAME,
- 'rabbitmq': CONTROL_GRP_NAME,
- 'swift': CONTROL_GRP_NAME,
+ 'ceilometer': CONTROL_GRP_NAME,
+ 'cinder': CONTROL_GRP_NAME,
+ 'glance': CONTROL_GRP_NAME,
+ 'haproxy': CONTROL_GRP_NAME,
+ 'heat': CONTROL_GRP_NAME,
+ 'horizon': CONTROL_GRP_NAME,
+ 'keystone': CONTROL_GRP_NAME,
+ 'memcached': CONTROL_GRP_NAME,
+ 'murano': CONTROL_GRP_NAME,
+ 'mysqlcluster': CONTROL_GRP_NAME,
+ 'neutron': NETWORK_GRP_NAME,
+ 'nova': CONTROL_GRP_NAME,
+ 'rabbitmq': CONTROL_GRP_NAME,
+ 'swift': CONTROL_GRP_NAME,
}
DEFAULT_OVERRIDES = {
- 'cinder-backup': STORAGE_GRP_NAME,
- 'cinder-volume': STORAGE_GRP_NAME,
- 'mysqlcluster-ndb': DATABASE_GRP_NAME,
- 'neutron-server': CONTROL_GRP_NAME,
- 'swift-account-server': STORAGE_GRP_NAME,
- 'swift-container-server': STORAGE_GRP_NAME,
- 'swift-object-server': STORAGE_GRP_NAME,
+ 'cinder-backup': STORAGE_GRP_NAME,
+ 'cinder-volume': STORAGE_GRP_NAME,
+ 'mysqlcluster-ndb': DATABASE_GRP_NAME,
+ 'neutron-server': CONTROL_GRP_NAME,
+ 'swift-account-server': STORAGE_GRP_NAME,
+ 'swift-container-server': STORAGE_GRP_NAME,
+ 'swift-object-server': STORAGE_GRP_NAME,
}
-# these groups cannot be deleted, they are required by kolla
+# these groups cannot be deleted, they are required by kolla
PROTECTED_GROUPS = [COMPUTE_GRP_NAME]
LOG = logging.getLogger(__name__)
@@ -178,9 +178,9 @@
def __init__(self, hostname):
self.name = hostname
- self.alias = ''
+ self.alias = ''
self.is_mgmt = False
- self.hypervisor = ''
+ self.hypervisor = ''
self.vars = {}
self.version = self.__class__.class_version
@@ -228,14 +228,14 @@
del self.vars[name]
[docs] def set_remote(self, remote_flag):
- self.set_var(ANSIBLE_BECOME, 'yes')
+ self.set_var(ANSIBLE_BECOME, 'yes')
if remote_flag:
- # set the ssh info for all the servers in the group
+ # set the ssh info for all the servers in the group
self.set_var(ANSIBLE_SSH_USER, get_admin_user())
self.clear_var(ANSIBLE_CONNECTION)
else:
- # remove ssh info, add local connection type
- self.set_var(ANSIBLE_CONNECTION, 'local')
+ # remove ssh info, add local connection type
+ self.set_var(ANSIBLE_CONNECTION, 'local')
self.clear_var(ANSIBLE_SSH_USER)
@@ -280,7 +280,7 @@
def __init__(self, name):
self.name = name
- # groups and parent services are mutually exclusive
+ # groups and parent services are mutually exclusive
self._groupnames = []
self._parent_servicename = None
@@ -298,7 +298,7 @@
if groupname in self._groupnames:
self._groupnames.remove(groupname)
if not self._groupnames:
- # no groups left, re-associate to the parent
+ # no groups left, re-associate to the parent
for servicename in SERVICES:
if self.name in SERVICES[servicename]:
self.set_parent_servicename(servicename)
@@ -325,50 +325,50 @@
1: initial release
"""
def __init__(self):
- self._groups = {} # kv = name:object
- self._hosts = {} # kv = name:object
- self._services = {} # kv = name:object
- self._sub_services = {} # kv = name:object
+ self._groups = {} # kv = name:object
+ self._hosts = {} # kv = name:object
+ self._services = {} # kv = name:object
+ self._sub_services = {} # kv = name:object
self.vars = {}
self.version = self.__class__.class_version
self.remote_mode = True
- # initialize the inventory to its defaults
+ # initialize the inventory to its defaults
self._create_default_inventory()
[docs] def upgrade(self):
if self.version <= 1:
- # upgrade from inventory v1
+ # upgrade from inventory v1
- # add ceilometer to inventory
- svc_name = 'ceilometer'
+ # add ceilometer to inventory
+ svc_name = 'ceilometer'
svc = self.create_service(svc_name)
- # associate ceilometer with all groups that heat is in.
- clone_svc = self.get_service('heat')
+ # associate ceilometer with all groups that heat is in.
+ clone_svc = self.get_service('heat')
groups = clone_svc.get_groupnames()
for group in groups:
svc.add_groupname(group)
- # stitch sub-service to service and set override
- # groups
+ # stitch sub-service to service and set override
+ # groups
for sub_svc_name in SERVICES[svc_name]:
sub_svc = self.create_sub_service(sub_svc_name)
sub_svc.set_parent_servicename(svc_name)
svc.add_sub_servicename(sub_svc_name)
if self.version <= 2:
- # upgrade from inventory v2
+ # upgrade from inventory v2
- # some sub-services may be missing their parent associations.
- # they are now needed in v3.
+ # some sub-services may be missing their parent associations.
+ # they are now needed in v3.
for svc in self.get_services():
for sub_svcname in svc.get_sub_servicenames():
sub_svc = self.get_sub_service(sub_svcname)
if not sub_svc.get_parent_servicename():
sub_svc.set_parent_servicename(svc.name)
- # update the version and save upgraded inventory file
+ # update the version and save upgraded inventory file
self.version = self.__class__.class_version
Inventory.save(self)
@@ -376,30 +376,30 @@
[docs] def load():
"""load the inventory from a pickle file"""
inventory_path = os.path.join(get_kollacli_etc(), INVENTORY_PATH)
- data = ''
+ data = ''
try:
if os.path.exists(inventory_path):
data = sync_read_file(inventory_path)
- # The inventory path changed between v1 and v2. Need to change
- # path throughout the inventory. This has to be done before
- # the pickle decode.
- if 'kollacli.common.inventory' not in data:
+ # The inventory path changed between v1 and v2. Need to change
+ # path throughout the inventory. This has to be done before
+ # the pickle decode.
+ if 'kollacli.common.inventory' not in data:
data = data.replace(
- '"py/object": "kollacli.ansible.inventory.',
- '"py/object": "kollacli.common.inventory.')
+ '"py/object": "kollacli.ansible.inventory.',
+ '"py/object": "kollacli.common.inventory.')
if data.strip():
inventory = jsonpickle.decode(data)
- # upgrade version handling
+ # upgrade version handling
if inventory.version != inventory.class_version:
inventory.upgrade()
else:
inventory = Inventory()
except Exception:
raise FailedOperation(
- u._('Loading inventory failed. : {error}')
+ u._('Loading inventory failed. : {error}')
.format(error=traceback.format_exc()))
return inventory
@@ -408,7 +408,7 @@
"""Save the inventory in a pickle file"""
inventory_path = os.path.join(get_kollacli_etc(), INVENTORY_PATH)
try:
- # multiple trips thru json to render a readable inventory file
+ # multiple trips thru json to render a readable inventory file
data = jsonpickle.encode(inventory)
data_str = json.loads(data)
pretty_data = json.dumps(data_str, indent=4)
@@ -416,16 +416,16 @@
except Exception as e:
raise FailedOperation(
- u._('Saving inventory failed. : {error}')
+ u._('Saving inventory failed. : {error}')
.format(error=str(e)))
def _create_default_inventory(self):
- # create the default groups
+ # create the default groups
for groupname in DEPLOY_GROUPS:
self.add_group(groupname)
- # create the default services/sub_services & their default groups
+ # create the default services/sub_services & their default groups
for svcname in SERVICES:
svc = self.create_service(svcname)
default_grpname = DEFAULT_GROUPS[svcname]
@@ -433,7 +433,7 @@
sub_svcnames = SERVICES[svcname]
if sub_svcnames:
for sub_svcname in sub_svcnames:
- # create a subservice
+ # create a subservice
svc.add_sub_servicename(sub_svcname)
sub_svc = self.create_sub_service(sub_svcname)
sub_svc.set_parent_servicename(svc.name)
@@ -459,26 +459,26 @@
if group name is not none, add host to group
"""
if groupname and groupname not in self._groups:
- raise NotInInventory(u._('Group'), groupname)
+ raise NotInInventory(u._('Group'), groupname)
if groupname and hostname not in self._hosts:
- # if a groupname is specified, the host must already exist
- raise NotInInventory(u._('Host'), hostname)
+ # if a groupname is specified, the host must already exist
+ raise NotInInventory(u._('Host'), hostname)
if not groupname and not self.remote_mode and len(self._hosts) >= 1:
raise InvalidConfiguration(
- u._('Cannot have more than one host when in local deploy '
- 'mode.'))
+ u._('Cannot have more than one host when in local deploy '
+ 'mode.'))
changed = False
- # create new host if it doesn't exist
+ # create new host if it doesn't exist
host = Host(hostname)
if hostname not in self.get_hostnames():
- # a new host is being added to the inventory
+ # a new host is being added to the inventory
changed = True
self._hosts[hostname] = host
- # a host is to be added to an existing group
+ # a host is to be added to an existing group
elif groupname:
group = self._groups[groupname]
if hostname not in group.get_hostnames():
@@ -500,7 +500,7 @@
"""
changed = False
if groupname and groupname not in self._groups:
- raise NotInInventory(u._('Group'), groupname)
+ raise NotInInventory(u._('Group'), groupname)
if hostname not in self._hosts:
return changed
@@ -535,44 +535,44 @@
for hostname, host_info in hosts_info.items():
host = self.get_host(hostname)
if not host:
- failed_hosts[hostname] = u._("Host doesn't exist.")
+ failed_hosts[hostname] = u._("Host doesn't exist.")
continue
- if not host_info or 'password' not in host_info:
- failed_hosts[hostname] = u._('No password in yml file.')
+ if not host_info or 'password' not in host_info:
+ failed_hosts[hostname] = u._('No password in yml file.')
continue
- passwd = host_info['password']
+ passwd = host_info['password']
uname = None
- if 'uname' in host_info:
- uname = host_info['uname']
+ if 'uname' in host_info:
+ uname = host_info['uname']
try:
self.setup_host(hostname, passwd, uname)
except Exception as e:
- failed_hosts[hostname] = '%s' % e
+ failed_hosts[hostname] = '%s' % e
if failed_hosts:
- summary = '\n'
+ summary = '\n'
for hostname, err in failed_hosts.items():
- summary = summary + '- %s: %s\n' % (hostname, err)
+ summary = summary + '- %s: %s\n' % (hostname, err)
raise HostError(
- u._('Not all hosts were set up. : {reasons}')
+ u._('Not all hosts were set up. : {reasons}')
.format(reasons=summary))
else:
- LOG.info(u._LI('All hosts were successfully set up.'))
+ LOG.info(u._LI('All hosts were successfully set up.'))
[docs] def setup_host(self, hostname, password, uname=None):
try:
LOG.info(
- u._LI('Starting setup of host ({host}).')
+ u._LI('Starting setup of host ({host}).')
.format(host=hostname))
ssh_setup_host(hostname, password, uname)
check_ok, msg = self.ssh_check_host(hostname)
if not check_ok:
- raise Exception(u._('Post-setup ssh check failed. {err}')
+ raise Exception(u._('Post-setup ssh check failed. {err}')
.format(err=msg))
- LOG.info(u._LI('Host ({host}) setup succeeded.')
+ LOG.info(u._LI('Host ({host}) setup succeeded.')
.format(host=hostname))
except Exception as e:
raise HostError(
- u._('Host ({host}) setup failed : {error}')
+ u._('Host ({host}) setup failed : {error}')
.format(host=hostname, error=str(e)))
return True
@@ -586,29 +586,29 @@
for hostname in hostnames:
is_ok, msg = self.ssh_check_host(hostname)
summary[hostname] = {}
- summary[hostname]['success'] = is_ok
- summary[hostname]['msg'] = msg
+ summary[hostname]['success'] = is_ok
+ summary[hostname]['msg'] = msg
return summary
[docs] def ssh_check_host(self, hostname):
- err_msg, output = self.run_ansible_command('-m ping', hostname)
+ err_msg, output = self.run_ansible_command('-m ping', hostname)
is_ok = True
if err_msg:
is_ok = False
msg = (
- u._('Host ({host}) ssh check failed. : {error} {message}')
+ u._('Host ({host}) ssh check failed. : {error} {message}')
.format(host=hostname, error=err_msg, message=output))
else:
- msg = (u._LI('Host ({host}) ssh check succeeded.')
+ msg = (u._LI('Host ({host}) ssh check succeeded.')
.format(host=hostname))
return is_ok, msg
[docs] def run_ansible_command(self, ansible_command, hostname):
err_msg = None
- command_string = '/usr/bin/sudo -u %s %s -vvv' % \
+ command_string = '/usr/bin/sudo -u %s %s -vvv' % \
(get_admin_user(), get_ansible_command())
gen_file_path = self.create_json_gen_file()
- cmd = '%s %s -i %s %s' % (command_string, hostname, gen_file_path,
+ cmd = '%s %s -i %s %s' % (command_string, hostname, gen_file_path,
ansible_command)
try:
err_msg, output = run_cmd(cmd, False)
@@ -620,11 +620,11 @@
[docs] def add_group(self, groupname):
- # Group names cannot overlap with service names:
+ # Group names cannot overlap with service names:
if groupname in self._services or groupname in self._sub_services:
raise InvalidArgument(
- u._('Invalid group name. A service name '
- 'cannot be used for a group name.'))
+ u._('Invalid group name. A service name '
+ 'cannot be used for a group name.'))
if groupname not in self._groups:
self._groups[groupname] = HostGroup(groupname)
@@ -638,10 +638,10 @@
[docs] def remove_group(self, groupname):
if groupname in PROTECTED_GROUPS:
raise InvalidArgument(
- u._('Cannot remove {group} group. It is required by kolla.')
+ u._('Cannot remove {group} group. It is required by kolla.')
.format(group=groupname))
- # remove group from services & subservices
+ # remove group from services & subservices
for service in self._services.values():
service.remove_groupname(groupname)
@@ -649,7 +649,7 @@
subservice.remove_groupname(groupname)
group_vars = os.path.join(get_group_vars_dir(), groupname)
- if os.path.exists(group_vars) and groupname != '__GLOBAL__':
+ if os.path.exists(group_vars) and groupname != '__GLOBAL__':
os.remove(group_vars)
if groupname in self._groups:
@@ -739,7 +739,7 @@
[docs] def add_group_to_service(self, groupname, servicename):
if groupname not in self._groups:
- raise NotInInventory(u._('Group'), groupname)
+ raise NotInInventory(u._('Group'), groupname)
if servicename in self._services:
service = self.get_service(servicename)
service.add_groupname(groupname)
@@ -747,11 +747,11 @@
sub_service = self.get_sub_service(servicename)
sub_service.add_groupname(groupname)
else:
- raise NotInInventory(u._('Service'), servicename)
+ raise NotInInventory(u._('Service'), servicename)
[docs] def remove_group_from_service(self, groupname, servicename):
if groupname not in self._groups:
- raise NotInInventory(u._('Group'), groupname)
+ raise NotInInventory(u._('Group'), groupname)
if servicename in self._services:
service = self.get_service(servicename)
service.remove_groupname(groupname)
@@ -759,7 +759,7 @@
sub_service = self.get_sub_service(servicename)
sub_service.remove_groupname(groupname)
else:
- raise NotInInventory(u._('Service'), servicename)
+ raise NotInInventory(u._('Service'), servicename)
[docs] def create_sub_service(self, sub_servicename):
if sub_servicename not in self._sub_services:
@@ -794,7 +794,7 @@
[docs] def set_deploy_mode(self, remote_flag):
if not remote_flag and len(self._hosts) > 1:
raise InvalidConfiguration(
- u._('Cannot set local deploy mode when multiple hosts exist.'))
+ u._('Cannot set local deploy mode when multiple hosts exist.'))
self.remote_mode = remote_flag
for group in self.get_groups():
@@ -836,58 +836,58 @@
"""
jdict = {}
- # if no filter provided, use all groups, all hosts
+ # if no filter provided, use all groups, all hosts
deploy_hostnames = self.get_hostnames()
deploy_groupnames = self.get_groupnames()
if inventory_filter:
- if 'deploy_hosts' in inventory_filter:
- deploy_hostnames = inventory_filter['deploy_hosts']
- if 'deploy_groups' in inventory_filter:
- deploy_groupnames = inventory_filter['deploy_groups']
+ if 'deploy_hosts' in inventory_filter:
+ deploy_hostnames = inventory_filter['deploy_hosts']
+ if 'deploy_groups' in inventory_filter:
+ deploy_groupnames = inventory_filter['deploy_groups']
- # add hostgroups
+ # add hostgroups
for group in self.get_groups():
jdict[group.name] = {}
- jdict[group.name]['hosts'] = []
+ jdict[group.name]['hosts'] = []
if group.name in deploy_groupnames:
- jdict[group.name]['hosts'] = \
+ jdict[group.name]['hosts'] = \
self._filter_hosts(group.get_hostnames(), deploy_hostnames)
- jdict[group.name]['children'] = []
- jdict[group.name]['vars'] = group.get_vars()
+ jdict[group.name]['children'] = []
+ jdict[group.name]['vars'] = group.get_vars()
- # add top-level services and what groups they are in
+ # add top-level services and what groups they are in
for service in self.get_services():
jdict[service.name] = {}
- jdict[service.name]['children'] = service.get_groupnames()
+ jdict[service.name]['children'] = service.get_groupnames()
- # add sub-services and their groups
+ # add sub-services and their groups
for sub_svc in self.get_sub_services():
jdict[sub_svc.name] = {}
groupnames = sub_svc.get_groupnames()
if groupnames:
- # sub-service is associated with a group(s)
- jdict[sub_svc.name]['children'] = groupnames
+ # sub-service is associated with a group(s)
+ jdict[sub_svc.name]['children'] = groupnames
else:
- # sub-service is associated with parent service
- jdict[sub_svc.name]['children'] = \
+ # sub-service is associated with parent service
+ jdict[sub_svc.name]['children'] = \
[sub_svc.get_parent_servicename()]
- # temporarily create group containing all hosts. this is needed for
- # ansible commands that are performed on hosts not yet in groups.
- group = self.add_group('__GLOBAL__')
+ # temporarily create group containing all hosts. this is needed for
+ # ansible commands that are performed on hosts not yet in groups.
+ group = self.add_group('__GLOBAL__')
jdict[group.name] = {}
- jdict[group.name]['hosts'] = deploy_hostnames
- jdict[group.name]['vars'] = group.get_vars()
+ jdict[group.name]['hosts'] = deploy_hostnames
+ jdict[group.name]['vars'] = group.get_vars()
self.remove_group(group.name)
- # process hosts vars
- jdict['_meta'] = {}
- jdict['_meta']['hostvars'] = {}
+ # process hosts vars
+ jdict['_meta'] = {}
+ jdict['_meta']['hostvars'] = {}
for hostname in deploy_hostnames:
host = self.get_host(hostname)
if host:
- jdict['_meta']['hostvars'][hostname] = host.get_vars()
+ jdict['_meta']['hostvars'][hostname] = host.get_vars()
return json.dumps(jdict)
def _filter_hosts(self, initial_hostnames, deploy_hostnames):
@@ -913,19 +913,19 @@
json_out = self.get_ansible_json(inventory_filter)
deploy_id = str(uuid.uuid4())
- dirname = 'kolla_%s' % deploy_id
+ dirname = 'kolla_%s' % deploy_id
dirpath = os.path.join(tempfile.gettempdir(), dirname)
os.mkdir(dirpath)
- json_gen_path = os.path.join(dirpath, 'temp_inventory.py')
+ json_gen_path = os.path.join(dirpath, 'temp_inventory.py')
- with open(json_gen_path, 'w') as json_gen_file:
- json_gen_file.write('#!/usr/bin/env python\n')
- # the quotes here are significant. The json_out has double quotes
- # embedded in it so single quotes are needed to wrap it.
- json_gen_file.write("print('%s')" % json_out)
+ with open(json_gen_path, 'w') as json_gen_file:
+ json_gen_file.write('#!/usr/bin/env python\n')
+ # the quotes here are significant. The json_out has double quotes
+ # embedded in it so single quotes are needed to wrap it.
+ json_gen_file.write("print('%s')" % json_out)
- # set executable by group
- os.chmod(json_gen_path, 0o555) # nosec
+ # set executable by group
+ os.chmod(json_gen_path, 0o555) # nosec
return json_gen_path
[docs] def validate_hostnames(self, hostnames):
if not hostnames:
- raise MissingArgument(u._('Host name(s)'))
+ raise MissingArgument(u._('Host name(s)'))
invalid_hosts = []
for hostname in hostnames:
if hostname not in self._hosts:
invalid_hosts.append(hostname)
if invalid_hosts:
- raise NotInInventory(u._('Host'), invalid_hosts)
+ raise NotInInventory(u._('Host'), invalid_hosts)
[docs] def validate_groupnames(self, groupnames):
if not groupnames:
- raise MissingArgument(u._('Group name(s)'))
+ raise MissingArgument(u._('Group name(s)'))
invalid_groups = []
for groupname in groupnames:
if groupname not in self._groups:
invalid_groups.append(groupname)
if invalid_groups:
- raise NotInInventory(u._('Group'), invalid_groups)
+ raise NotInInventory(u._('Group'), invalid_groups)
[docs] def validate_servicenames(self, servicenames):
if not servicenames:
- raise MissingArgument(u._('Service name(s)'))
+ raise MissingArgument(u._('Service name(s)'))
invalid_services = []
for servicename in servicenames:
if (servicename not in self._services and
servicename not in self._sub_services):
invalid_services.append(servicename)
if invalid_services:
- raise NotInInventory(u._('Service'), invalid_services)
+ raise NotInInventory(u._('Service'), invalid_services)
@@ -994,7 +994,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/passwords.html b/doc/build/html/_modules/kollacli/common/passwords.html
index db1d5e3..5844ccd 100644
--- a/doc/build/html/_modules/kollacli/common/passwords.html
+++ b/doc/build/html/_modules/kollacli/common/passwords.html
@@ -6,7 +6,7 @@
- kollacli.common.passwords — kollacli 1.0.0.dev396 documentation
+ kollacli.common.passwords — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
@@ -47,19 +47,19 @@
Source code for kollacli.common.passwords
-# 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.
+# 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 os
import kollacli.i18n as u
@@ -67,7 +67,7 @@
from kollacli.api.exceptions import FailedOperation
from kollacli.common import utils
-PWDS_FILENAME = 'passwords.yml'
+PWDS_FILENAME = 'passwords.yml'
[docs]def set_password(pwd_key, pwd_value):
@@ -76,11 +76,11 @@
If the password name exists, it will be changed.
If it doesn't exist, a new password will be added.
"""
- cmd = '%s -k %s -v %s' % (_get_cmd_prefix(), pwd_key, pwd_value)
+ cmd = '%s -k %s -v %s' % (_get_cmd_prefix(), pwd_key, pwd_value)
err_msg, output = utils.run_cmd(cmd, print_output=False)
if err_msg:
raise FailedOperation(
- u._('Password set failed. {error} {message}')
+ u._('Password set failed. {error} {message}')
.format(error=err_msg, message=output))
@@ -89,22 +89,22 @@
if the password exists, it will be removed from the passwords file
"""
- cmd = '%s -k %s -c' % (_get_cmd_prefix(), pwd_key)
+ cmd = '%s -k %s -c' % (_get_cmd_prefix(), pwd_key)
err_msg, output = utils.run_cmd(cmd, print_output=False)
if err_msg:
- raise FailedOperation('%s %s' % (err_msg, output))
+ raise FailedOperation('%s %s' % (err_msg, output))
[docs]def get_password_names():
"""return a list of password names"""
- cmd = '%s -l' % (_get_cmd_prefix())
+ cmd = '%s -l' % (_get_cmd_prefix())
err_msg, output = utils.run_cmd(cmd, print_output=False)
if err_msg:
- raise FailedOperation('%s %s' % (err_msg, output))
+ raise FailedOperation('%s %s' % (err_msg, output))
pwd_names = []
- if output and ',' in output:
- pwd_names = output.strip().split(',')
+ if output and ',' in output:
+ pwd_names = output.strip().split(',')
return pwd_names
@@ -113,7 +113,7 @@
pwd_file_path = os.path.join(utils.get_kolla_etc(),
PWDS_FILENAME)
user = utils.get_admin_user()
- prefix = ('/usr/bin/sudo -u %s %s password -p %s '
+ prefix = ('/usr/bin/sudo -u %s %s password -p %s '
% (user, actions_path, pwd_file_path))
return prefix
@@ -149,7 +149,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/properties.html b/doc/build/html/_modules/kollacli/common/properties.html
index 77e1b0b..9b41c8e 100644
--- a/doc/build/html/_modules/kollacli/common/properties.html
+++ b/doc/build/html/_modules/kollacli/common/properties.html
@@ -6,7 +6,7 @@
- kollacli.common.properties — kollacli 1.0.0.dev396 documentation
+ kollacli.common.properties — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
-# 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.
+# 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 copy
import logging
import os
@@ -78,10 +78,10 @@
LOG = logging.getLogger(__name__)
-ALLVARS_PATH = 'ansible/group_vars/all.yml'
-GLOBALS_PATH = 'ansible/group_vars/__GLOBAL__'
-ANSIBLE_ROLES_PATH = 'ansible/roles'
-ANSIBLE_DEFAULTS_PATH = 'defaults/main.yml'
+ALLVARS_PATH = 'ansible/group_vars/all.yml'
+GLOBALS_PATH = 'ansible/group_vars/__GLOBAL__'
+ANSIBLE_ROLES_PATH = 'ansible/roles'
+ANSIBLE_DEFAULTS_PATH = 'defaults/main.yml'
[docs]class AnsibleProperties(object):
@@ -98,18 +98,22 @@
KOLLA_HOME/ansible/host_vars/*
KOLLA_ETC/passwords.yml
"""
- self.globals_path = ''
+ self.globals_path = os.path.join(get_kolla_home(), GLOBALS_PATH)
self.global_props = []
self.unique_global_props = {}
self.unique_override_flags = {}
self.group_props = {}
self.host_props = {}
+ self.properties_loaded = False
- self._load_properties_roles()
- self._load_properties_all()
- self._load_properties_global()
- self._load_properties_hostvars()
- self._load_properties_groupvars()
+ def _load_properties(self):
+ if not self.properties_loaded:
+ self._load_properties_roles()
+ self._load_properties_all()
+ self._load_properties_global()
+ self._load_properties_hostvars()
+ self._load_properties_groupvars()
+ self.properties_loaded = True
def _load_properties_roles(self):
start_dir = os.path.join(get_kolla_home(), ANSIBLE_ROLES_PATH)
@@ -120,7 +124,7 @@
if os.path.isfile(file_name):
with open(file_name) as service_file:
service_contents = yaml.safe_load(service_file)
- prop_file_name = service_name + ':main.yml'
+ prop_file_name = service_name + ':main.yml'
for key, value in service_contents.items():
ansible_prop = AnsibleProperty(key, value,
prop_file_name)
@@ -138,13 +142,12 @@
overrides = True
orig_value = self.unique_global_props[key].value
ansible_prop = AnsibleProperty(key, value,
- 'group_vars/all.yml',
+ 'group_vars/all.yml',
overrides, orig_value)
self.global_props.append(ansible_prop)
self.unique_global_props[key] = ansible_prop
def _load_properties_global(self):
- self.globals_path = os.path.join(get_kolla_home(), GLOBALS_PATH)
globals_data = sync_read_file(self.globals_path)
globals_contents = yaml.safe_load(globals_data)
if not globals_contents:
@@ -158,7 +161,7 @@
override_flags.ovr_global = True
orig_value = self.unique_global_props[key].value
ansible_prop = AnsibleProperty(key, value,
- 'group_vars/__GLOBAL',
+ 'group_vars/__GLOBAL',
overrides, orig_value)
ansible_prop.override_flags = override_flags
self.global_props.append(ansible_prop)
@@ -188,18 +191,18 @@
ansible_prop = AnsibleProperty(key, value,
hostfile,
overrides, orig_value,
- 'host', hostfile)
+ 'host', hostfile)
props.append(ansible_prop)
self.host_props[hostfile] = props
def _load_properties_groupvars(self):
group_dir = get_group_vars_dir()
for groupfile in os.listdir(group_dir):
- if (groupfile == 'all.yml'):
+ if (groupfile == 'all.yml'):
continue
self.group_props[groupfile] = []
- # don't load __GLOBAL__ as a group property list as it is globals
- if groupfile == '__GLOBAL__':
+ # don't load __GLOBAL__ as a group property list as it is globals
+ if groupfile == '__GLOBAL__':
continue
with open(os.path.join(group_dir, groupfile)) as group_data:
group_contents = yaml.safe_load(group_data)
@@ -220,21 +223,19 @@
ansible_prop = AnsibleProperty(key, value,
groupfile,
overrides, orig_value,
- 'group', groupfile)
+ 'group', groupfile)
props.append(ansible_prop)
self.group_props[groupfile] = props
-
[docs] def get_host_list(self, host_list):
+ self._load_properties()
prop_list = []
- inventory = Inventory.load()
+ inventory = Inventory.load() # nosec
if host_list is not None:
for host_name in host_list:
host = inventory.get_host(host_name)
if host is None:
- raise NotInInventory(u._('Host'), host_name)
+ raise NotInInventory(u._('Host'), host_name)
if host_name in self.host_props:
prop_list += self.host_props[host_name]
else:
@@ -245,13 +246,14 @@
return prop_list
[docs] def get_group_list(self, group_list):
+ self._load_properties()
prop_list = []
- inventory = Inventory.load()
+ inventory = Inventory.load() # nosec
if group_list is not None:
for group_name in group_list:
group = inventory.get_group(group_name)
if group is None:
- raise NotInInventory(u._('Group'), group_name)
+ raise NotInInventory(u._('Group'), group_name)
if group_name in self.group_props:
prop_list += self.group_props[group_name]
else:
@@ -262,6 +264,7 @@
return prop_list
[docs] def get_property(self, property_name):
+ self._load_properties()
prop_val = None
if property_name in self.unique_global_props:
prop = self.unique_global_props[property_name]
@@ -269,25 +272,27 @@
return prop_val
[docs] def get_all_unique(self):
+ self._load_properties()
unique_list = []
for _, value in self.unique_global_props.items():
unique_list.append(value)
return sorted(unique_list, key=lambda x: x.name)
[docs] def get_all_override_flags(self):
+ self._load_properties()
return self.unique_override_flags
- # TODO(bmace) -- if this isn't used for 2.1.x it should be removed
- # property listing is still being tweaked so leaving for
- # the time being in case we want to use it
+ # TODO(bmace) -- if this isn't used for 2.1.x it should be removed
+ # property listing is still being tweaked so leaving for
+ # the time being in case we want to use it
[docs] def filter_jinja2(self, contents):
new_contents = {}
for key, value in contents.items():
if not isinstance(value, six.string_types):
- LOG.debug('removing non-string: %s', value)
+ LOG.debug('removing non-string: %s', value)
continue
- if value and '{{' in value and '}}' in value:
- LOG.debug('removing jinja2 value: %s', value)
+ if value and '{{' in value and '}}' in value:
+ LOG.debug('removing jinja2 value: %s', value)
continue
new_contents[key] = value
return new_contents
@@ -300,8 +305,8 @@
raise e
[docs] def set_host_property(self, property_dict, hosts):
- # if hosts is None set the property on all hosts
- inventory = Inventory.load()
+ # if hosts is None set the property on all hosts
+ inventory = Inventory.load() # nosec
host_list = []
if hosts is None:
host_list = inventory.get_hosts()
@@ -309,7 +314,7 @@
for host_name in hosts:
host = inventory.get_host(host_name)
if host is None:
- raise NotInInventory(u._('Host'), host_name)
+ raise NotInInventory(u._('Host'), host_name)
host_list.append(host)
try:
for host in host_list:
@@ -320,8 +325,8 @@
raise e
[docs] def set_group_property(self, property_dict, groups):
- # if groups is None set the property on all hosts
- inventory = Inventory.load()
+ # if groups is None set the property on all hosts
+ inventory = Inventory.load() # nosec
group_list = []
if groups is None:
group_list = inventory.get_groups()
@@ -329,7 +334,7 @@
for group_name in groups:
group = inventory.get_group(group_name)
if group is None:
- raise NotInInventory(u._('Group'), group_name)
+ raise NotInInventory(u._('Group'), group_name)
group_list.append(group)
try:
for group in group_list:
@@ -349,8 +354,8 @@
raise e
[docs] def clear_host_property(self, property_list, hosts):
- # if hosts is None set the property on all hosts
- inventory = Inventory.load()
+ # if hosts is None set the property on all hosts
+ inventory = Inventory.load() # nosec
host_list = []
if hosts is None:
host_list = inventory.get_hosts()
@@ -358,7 +363,7 @@
for host_name in hosts:
host = inventory.get_host(host_name)
if host is None:
- raise NotInInventory(u._('Host'), host_name)
+ raise NotInInventory(u._('Host'), host_name)
host_list.append(host)
try:
for host in host_list:
@@ -369,8 +374,8 @@
raise e
[docs] def clear_group_property(self, property_list, groups):
- # if hosts is None set the property on all hosts
- inventory = Inventory.load()
+ # if hosts is None set the property on all hosts
+ inventory = Inventory.load() # nosec
group_list = []
if groups is None:
group_list = inventory.get_groups()
@@ -378,7 +383,7 @@
for group_name in groups:
group = inventory.get_group(group_name)
if group is None:
- raise NotInInventory(u._('Group'), group_name)
+ raise NotInInventory(u._('Group'), group_name)
group_list.append(group)
try:
for group in group_list:
@@ -391,14 +396,14 @@
def _list_to_dict(self, property_list):
property_dict = {}
for key in property_list:
- property_dict[key] = ''
+ property_dict[key] = ''
return property_dict
[docs]class AnsibleProperty(object):
def __init__(self, name, value, file_name, overrides=False,
- orig_value=None, prop_type='global', target=None):
+ orig_value=None, prop_type='global', target=None):
self.name = name
self.value = value
self.prop_type = prop_type
@@ -447,7 +452,7 @@
modules |
- kollacli 1.0.0.dev396 documentation »
+ kollacli 1.0.0.dev401 documentation »
Module code »
diff --git a/doc/build/html/_modules/kollacli/common/sshutils.html b/doc/build/html/_modules/kollacli/common/sshutils.html
index 97b174d..d3f4e7f 100644
--- a/doc/build/html/_modules/kollacli/common/sshutils.html
+++ b/doc/build/html/_modules/kollacli/common/sshutils.html
@@ -6,7 +6,7 @@
- kollacli.common.sshutils — kollacli 1.0.0.dev396 documentation
+ kollacli.common.sshutils — kollacli 1.0.0.dev401 documentation
@@ -14,7 +14,7 @@
-
+
@@ -36,7 +36,7 @@
-# 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.
+# 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 os.path
import paramiko
@@ -72,7 +72,7 @@
import kollacli.i18n as u
-MIN_DOCKER_VERSION = '1.8.1'
+MIN_DOCKER_VERSION = '1.8.1'
LOG = logging.getLogger(__name__)
@@ -99,17 +99,17 @@
try:
ssh_client = ssh_connect(net_addr, setup_user, password)
- # before modifying the host, check that it meets requirements
- # TODO(bmace) pre / post checks should be done with ansible
+ # before modifying the host, check that it meets requirements
+ # TODO(bmace) pre / post checks should be done with ansible
- # populate authorized keys file w/ public key
- key_dir = os.path.join(os.path.expanduser('~kolla'),
- '.ssh', 'authorized_keys')
- cmd = ('/usr/bin/sudo su - %s -c "echo \'%s\' >> %s"'
+ # populate authorized keys file w/ public key
+ key_dir = os.path.join(os.path.expanduser('~kolla'),
+ '.ssh', 'authorized_keys')
+ cmd = ('/usr/bin/sudo su - %s -c "echo \'%s\' >> %s"'
% (admin_user, public_key, key_dir))
_exec_ssh_cmd(cmd, ssh_client)
- # TODO(bmace) verify ssh connection to the new account
+ # TODO(bmace) verify ssh connection to the new account
except Exception as e:
raise e
finally:
@@ -120,26 +120,26 @@
if ssh_client:
try:
ssh_client.close()
- except Exception: # nosec
+ except Exception: # nosec
pass
def _exec_ssh_cmd(cmd, ssh_client):
LOG.debug(cmd)
- _, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True) # nosec
+ _, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True) # nosec
msg = stdout.read()
errmsg = stderr.read()
- LOG.debug('%s : %s' % (msg, errmsg))
+ LOG.debug('%s : %s' % (msg, errmsg))
if errmsg:
LOG.warn(
- u._LW('WARNING: command : {command})\nmessage : {message}')
+ u._LW('WARNING: command : {command})\nmessage : {message}')
.format(command=cmd, message=errmsg.strip()))
return msg, errmsg
[docs]def ssh_get_public_key():
- keyfile_path = os.path.join(get_kollacli_etc(), 'id_rsa.pub')
- with open(keyfile_path, "r") as public_key_file:
+ keyfile_path = os.path.join(get_kollacli_etc(), 'id_rsa.pub')
+ with open(keyfile_path, "r") as public_key_file:
public_key = public_key_file.read()
return public_key
return None
@@ -176,7 +176,7 @@
-# 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.
+# 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 os
import tarfile
@@ -83,48 +83,48 @@
self.hostname = hostname
self.inventory = inventory
self.servicenames = servicenames
- self.container_info = {} # container_id: container_img_name
+ self.container_info = {} # container_id: container_img_name
self.filtered_servicenames = {}
[docs] def load_container_info(self):
"""get the list of containers on the host"""
hostname = self.hostname
err_msg, output = \
- self.inventory.run_ansible_command('-a "docker ps -a"', hostname)
+ self.inventory.run_ansible_command('-a "docker ps -a"', hostname)
if err_msg:
- msg = 'Error accessing host %s : %s ' % (hostname, err_msg)
+ msg = 'Error accessing host %s : %s ' % (hostname, err_msg)
raise FailedOperation(msg)
if not output:
- msg = ('Host %s is not accessible.' % hostname)
+ msg = ('Host %s is not accessible.' % hostname)
raise FailedOperation(msg)
else:
- if '>>' not in output:
- msg = ('Host: %s. Invalid ansible return data: [%s].'
+ if '>>' not in output:
+ msg = ('Host: %s. Invalid ansible return data: [%s].'
% (hostname, output))
raise FailedOperation(msg)
- if 'NAMES' not in output:
- msg = ('Host: %s. Invalid docker ps return data: [%s].'
+ if 'NAMES' not in output:
+ msg = ('Host: %s. Invalid docker ps return data: [%s].'
% (hostname, output))
raise FailedOperation(msg)
ansible_properties = AnsibleProperties()
base_distro = \
- ansible_properties.get_property('kolla_base_distro')
+ ansible_properties.get_property('kolla_base_distro')
install_type = \
- ansible_properties.get_property('kolla_install_type')
- # typically this prefix will be "ol-openstack-"
- container_prefix = base_distro + '-' + install_type + '-'
+ ansible_properties.get_property('kolla_install_type')
+ # typically this prefix will be "ol-openstack-"
+ container_prefix = base_distro + '-' + install_type + '-'
- # process ps output
+ # process ps output
containers = {}
- # the ps output is after the '>>'
- output = output.split('>>', 1)[1]
- LOG.info('docker ps -a on host: %s:\n%s' % (hostname, output))
+ # the ps output is after the '>>'
+ output = output.split('>>', 1)[1]
+ LOG.info('docker ps -a on host: %s:\n%s' % (hostname, output))
- lines = output.split('\n')
+ lines = output.split('\n')
for line in lines:
tokens = line.split()
if len(tokens) < 2:
@@ -132,32 +132,32 @@
cid = tokens[0]
image = tokens[1]
if container_prefix not in image:
- # skip non-kolla containers
+ # skip non-kolla containers
continue
name = image.split(container_prefix)[1]
- name = name.split(':')[0]
+ name = name.split(':')[0]
containers[cid] = name
self.container_info = containers
[docs] def get_log(self, container_id):
"""read the container log"""
hostname = self.hostname
- cmd = '-a "docker logs %s"' % container_id
+ cmd = '-a "docker logs %s"' % container_id
err_msg, output = self.inventory.run_ansible_command(cmd, hostname)
if err_msg:
- msg = 'Error accessing host %s : %s ' % (hostname, err_msg)
+ msg = 'Error accessing host %s : %s ' % (hostname, err_msg)
raise FailedOperation(msg)
if not output:
- msg = ('Host %s is not accessible.' % hostname)
+ msg = ('Host %s is not accessible.' % hostname)
raise FailedOperation(msg)
- if '>>' not in output:
- msg = ('Host: %s. Invalid ansible return data: [%s].'
+ if '>>' not in output:
+ msg = ('Host: %s. Invalid ansible return data: [%s].'
% (hostname, output))
raise FailedOperation(msg)
- # the log info is after the '>>'
- output = output.split('>>', 1)[1]
+ # the log info is after the '>>'
+ output = output.split('>>', 1)[1]
return output
[docs] def write_logs(self, dirname):
@@ -165,10 +165,10 @@
for container_id, container_name in self.filtered_services.items():
logdata = self.get_log(container_id)
if logdata:
- logname = '%s_%s.log' % (container_name, container_id)
+ logname = '%s_%s.log' % (container_name, container_id)
self.write_logfile(dirname, logname, logdata)
else:
- LOG.warn('No log data found for service %s on host %s'
+ LOG.warn('No log data found for service %s on host %s'
% (container_name, self.hostname))
[docs] def write_logfile(self, dirpath, logname, logdata):
@@ -177,7 +177,7 @@
if not os.path.exists(hostdir):
os.mkdir(hostdir)
fpath = os.path.join(hostdir, logname)
- with open(fpath, 'w') as logfile:
+ with open(fpath, 'w') as logfile:
logfile.write(logdata)
[docs] def filter_services(self):
@@ -186,7 +186,7 @@
for host_svcid, host_svcname in self.container_info.items():
for servicename in self.servicenames:
if (host_svcname == servicename or
- host_svcname.startswith(servicename + '-')):
+ host_svcname.startswith(servicename + '-')):
services_subset[host_svcid] = host_svcname
self.filtered_services = services_subset
@@ -211,70 +211,70 @@
"""
kolla_home = get_kolla_home()
kolla_logs = get_kolla_log_dir()
- kolla_ansible = os.path.join(kolla_home, 'ansible')
- kolla_docs = os.path.join(kolla_home, 'docs')
+ kolla_ansible = os.path.join(kolla_home, 'ansible')
+ kolla_docs = os.path.join(kolla_home, 'docs')
kolla_etc = get_kolla_etc()
- kolla_config = os.path.join(kolla_etc, 'config')
- kollacli_etc = get_kollacli_etc().rstrip('/')
- ketc = 'kolla/etc/'
- kshare = 'kolla/share/'
- fd, dump_path = tempfile.mkstemp(dir=dirpath, prefix='kollacli_dump_',
- suffix='.tgz')
- os.close(fd) # avoid fd leak
- with tarfile.open(dump_path, 'w:gz') as tar:
- # Can't blanket add kolla_home because the .ssh dir is
- # accessible by the kolla user only (not kolla group)
+ kolla_config = os.path.join(kolla_etc, 'config')
+ kollacli_etc = get_kollacli_etc().rstrip('/')
+ ketc = 'kolla/etc/'
+ kshare = 'kolla/share/'
+ fd, dump_path = tempfile.mkstemp(dir=dirpath, prefix='kollacli_dump_',
+ suffix='.tgz')
+ os.close(fd) # avoid fd leak
+ with tarfile.open(dump_path, 'w:gz') as tar:
+ # Can't blanket add kolla_home because the .ssh dir is
+ # accessible by the kolla user only (not kolla group)
tar.add(kolla_ansible,
arcname=kshare + os.path.basename(kolla_ansible))
tar.add(kolla_docs,
arcname=kshare + os.path.basename(kolla_docs))
- # Can't blanket add kolla_etc because the passwords.yml
- # file is accessible by the kolla user only (not kolla group)
+ # Can't blanket add kolla_etc because the passwords.yml
+ # file is accessible by the kolla user only (not kolla group)
tar.add(kolla_config,
arcname=ketc + os.path.basename(kolla_config))
tar.add(kollacli_etc,
arcname=ketc + os.path.basename(kollacli_etc))
- # add kolla log files
+ # add kolla log files
if os.path.isdir(kolla_logs):
tar.add(kolla_logs)
- # add output of various commands
+ # add output of various commands
_add_cmd_info(tar)
return dump_path
def _add_cmd_info(tar):
- # run all the kollacli list commands
- cmds = ['kollacli --version',
- 'kollacli service listgroups',
- 'kollacli service list',
- 'kollacli group listservices',
- 'kollacli group listhosts',
- 'kollacli host list',
- 'kollacli property list',
- 'kollacli password list']
+ # run all the kollacli list commands
+ cmds = ['kollacli --version',
+ 'kollacli service listgroups',
+ 'kollacli service list',
+ 'kollacli group listservices',
+ 'kollacli group listhosts',
+ 'kollacli host list',
+ 'kollacli property list',
+ 'kollacli password list']
- # collect the json inventory output
+ # collect the json inventory output
inventory = Inventory.load()
inv_path = inventory.create_json_gen_file()
cmds.append(inv_path)
try:
- fd, path = tempfile.mkstemp(suffix='.tmp')
+ fd, path = tempfile.mkstemp(suffix='.tmp')
os.close(fd)
- with open(path, 'w') as tmp_file:
+ with open(path, 'w') as tmp_file:
for cmd in cmds:
err_msg, output = run_cmd(cmd, False)
- tmp_file.write('\n\n$ %s\n' % cmd)
+ tmp_file.write('\n\n$ %s\n' % cmd)
if err_msg:
- tmp_file.write('Error message: %s\n' % err_msg)
+ tmp_file.write('Error message: %s\n' % err_msg)
for line in output:
- tmp_file.write(line + '\n')
+ tmp_file.write(line + '\n')
- tar.add(path, arcname=os.path.join('kolla', 'cmds_output'))
+ tar.add(path, arcname=os.path.join('kolla', 'cmds_output'))
except Exception as e:
raise e
finally:
@@ -315,7 +315,7 @@
-# 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.
+# 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 copy
import fcntl
import grp
@@ -67,7 +67,7 @@
import os
import pwd
import six
-import subprocess # nosec
+import subprocess # nosec
import sys
import time
@@ -80,39 +80,39 @@
[docs]def get_kolla_home():
- return os.environ.get("KOLLA_HOME", "/usr/share/kolla/")
+ return os.environ.get("KOLLA_HOME", "/usr/share/kolla/")
[docs]def get_kolla_etc():
- return os.environ.get("KOLLA_ETC", "/etc/kolla/")
+ return os.environ.get("KOLLA_ETC", "/etc/kolla/")
[docs]def get_kollacli_home():
- return os.environ.get("KOLLA_CLI_HOME", "/usr/share/kolla/kollacli/")
+ return os.environ.get("KOLLA_CLI_HOME", "/usr/share/kolla/kollacli/")
[docs]def get_kollacli_etc():
- return os.environ.get("KOLLA_CLI_ETC", "/etc/kolla/kollacli/")
+ return os.environ.get("KOLLA_CLI_ETC", "/etc/kolla/kollacli/")
[docs]def get_group_vars_dir():
- return os.path.join(get_kolla_home(), 'ansible/group_vars')
+ return os.path.join(get_kolla_home(), 'ansible/group_vars')
[docs]def get_host_vars_dir():
- return os.path.join(get_kolla_home(), 'ansible/host_vars')
+ return os.path.join(get_kolla_home(), 'ansible/host_vars')
[docs]def get_ansible_lock_path():
- return os.path.join(get_kollacli_etc(), 'ansible/ansible.lock')
+ return os.path.join(get_kollacli_etc(), 'ansible/ansible.lock')
[docs]def get_kolla_actions_path():
- return os.path.join(get_kollacli_home(), 'tools', 'kolla_actions.py')
+ return os.path.join(get_kollacli_home(), 'tools', 'kolla_actions.py')
[docs]def get_kolla_log_file_size():
- envvar = 'KOLLA_LOG_FILE_SIZE'
- size_str = os.environ.get(envvar, '500000')
+ envvar = 'KOLLA_LOG_FILE_SIZE'
+ size_str = os.environ.get(envvar, '500000')
try:
size = int(size_str)
except Exception:
raise InvalidArgument(
- u._('Environmental variable ({env_var}) is not an '
- 'integer ({log_size}).')
+ u._('Environmental variable ({env_var}) is not an '
+ 'integer ({log_size}).')
.format(env_var=envvar, log_size=size_str))
return size
[docs]def get_property_list_length():
- envvar = 'KOLLA_PROP_LIST_LENGTH'
- length_str = os.environ.get(envvar, '50')
+ envvar = 'KOLLA_PROP_LIST_LENGTH'
+ length_str = os.environ.get(envvar, '50')
try:
length = int(length_str)
except Exception:
raise InvalidArgument(
- u._('Environmental variable ({env_var}) is not an '
- 'integer ({prop_length}).')
+ u._('Environmental variable ({env_var}) is not an '
+ 'integer ({prop_length}).')
.format(env_var=envvar, prop_length=length_str))
return length
[docs]def get_admin_user():
- return os.environ.get("KOLLA_CLI_ADMIN_USER", "kolla")
+ return os.environ.get("KOLLA_CLI_ADMIN_USER", "kolla")
[docs]def get_setup_user():
- return os.environ.get("KOLLA_CLI_SETUP_USER", "root")
+ return os.environ.get("KOLLA_CLI_SETUP_USER", "root")
[docs]def get_ansible_command(playbook=False):
@@ -164,26 +164,26 @@
python is py3, prefix the ansible command with a py2
interpreter.
"""
- cmd = 'ansible'
+ cmd = 'ansible'
if playbook:
- cmd = 'ansible-playbook'
+ cmd = 'ansible-playbook'
if sys.version_info[0] >= 3:
- # running with py3, find a py2 interpreter for ansible
+ # running with py3, find a py2 interpreter for ansible
py2_path = None
- usr_bin = os.path.join('/', 'usr', 'bin')
+ usr_bin = os.path.join('/', 'usr', 'bin')
for fname in os.listdir(usr_bin):
- if (fname.startswith('python2.') and
+ if (fname.startswith('python2.') and
os.path.isfile(os.path.join(usr_bin, fname))):
- suffix = fname.split('.')[1]
+ suffix = fname.split('.')[1]
if suffix.isdigit():
py2_path = os.path.join(usr_bin, fname)
break
if py2_path is None:
raise Exception(
- u._('ansible-playbook requires python2 and no '
- 'python2 interpreter found in {path}.')
+ u._('ansible-playbook requires python2 and no '
+ 'python2 interpreter found in {path}.')
.format(path=usr_bin))
- cmd = '%s %s' % (py2_path, os.path.join(usr_bin, cmd))
+ cmd = '%s %s' % (py2_path, os.path.join(usr_bin, cmd))
return cmd
@@ -209,7 +209,7 @@
err = None
output = None
try:
- process = subprocess.Popen(cmd, shell=True, # nosec
+ process = subprocess.Popen(cmd, shell=True, # nosec
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, err = process.communicate()
@@ -219,7 +219,7 @@
err = safe_decode(err)
output = safe_decode(output)
if process.returncode != 0:
- err = (u._('Command failed. : {error}')
+ err = (u._('Command failed. : {error}')
.format(error=err))
if print_output:
LOG.info(output)
@@ -240,20 +240,20 @@
"""
try:
cloned_dict = copy.copy(property_dict)
- group_info = grp.getgrnam('kolla')
+ group_info = grp.getgrnam('kolla')
if not os.path.exists(file_path):
- with open(file_path, 'a'):
+ with open(file_path, 'a'):
os.utime(file_path, None)
os.chown(file_path, -1, group_info.gr_gid)
new_contents = []
read_data = sync_read_file(file_path)
- lines = read_data.split('\n')
+ lines = read_data.split('\n')
last_line_empty = False
for line in lines:
line = line.rstrip()
- # yank spurious empty lines
+ # yank spurious empty lines
if line:
last_line_empty = False
else:
@@ -261,46 +261,46 @@
continue
last_line_empty = True
- split_line = line.split(':', 1)
+ split_line = line.split(':', 1)
if len(split_line) > 1:
split_key = split_line[0]
split_key.rstrip()
if split_key in cloned_dict:
if clear:
- # clear existing property
+ # clear existing property
continue
- # edit existing property
- line = '%s: "%s"' % (split_key, cloned_dict[split_key])
- # clear out the key after we are done, all existing keys
- # will be appended at the end (or for clear, ignored)
+ # edit existing property
+ line = '%s: "%s"' % (split_key, cloned_dict[split_key])
+ # clear out the key after we are done, all existing keys
+ # will be appended at the end (or for clear, ignored)
del cloned_dict[split_key]
new_contents.append(line)
if not clear:
- # add new properties to file
+ # add new properties to file
for key, value in cloned_dict.items():
- line = '%s: "%s"' % (key, value)
+ line = '%s: "%s"' % (key, value)
new_contents.append(line)
- write_data = '\n'.join(new_contents)
+ write_data = '\n'.join(new_contents)
sync_write_file(file_path, write_data)
except Exception as e:
raise e
-# 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.
+# 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.
"""Command-line interface to Kolla"""
import logging
import os
@@ -81,26 +81,26 @@
[docs]class KollaCli(App):
def __init__(self):
super(KollaCli, self).__init__(
- description=u._('Command-Line Client for OpenStack Kolla'),
- version='0.2',
- command_manager=CommandManager('kolla.cli'),
+ description=u._('Command-Line Client for OpenStack Kolla'),
+ version='0.2',
+ command_manager=CommandManager('kolla.cli'),
)
inventory_path = os.path.join(get_kollacli_etc(),
INVENTORY_PATH)
if os.path.isfile(inventory_path) is False:
err_string = u._(
- 'Required file ({inventory}) does not exist.\n'
- 'Please re-install the kollacli to '
- 'recreate the file.').format(inventory=inventory_path)
+ 'Required file ({inventory}) does not exist.\n'
+ 'Please re-install the kollacli to '
+ 'recreate the file.').format(inventory=inventory_path)
raise CommandError(err_string)
- # set up logging and test that user running shell is part
- # of kolla group
+ # set up logging and test that user running shell is part
+ # of kolla group
ClientApi()
- # paramiko log is very chatty, tune it down
- logging.getLogger('paramiko').setLevel(logging.WARNING)
+ # paramiko log is very chatty, tune it down
+ logging.getLogger('paramiko').setLevel(logging.WARNING)
self.dump_stack_trace = False
@@ -109,7 +109,7 @@
shell = KollaCli()
return shell.run(argv)
-if __name__ == "__main__":
+if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))