kollacli.common package

Submodules

kollacli.common.allinone module

class kollacli.common.allinone.AllInOne[source]

Bases: object

AllInOne helper class

This class parses the kolla all-in-one file and provides an easier to use way to represent that file.

add_group(groupname)[source]
add_service(servicename)[source]

kollacli.common.host module

class kollacli.common.host.Host(hostname)[source]

Bases: object

class_version = 1
get_vars()[source]
set_var(name, value)[source]
upgrade()[source]

kollacli.common.host_group module

class kollacli.common.host_group.HostGroup(name)[source]

Bases: object

add_host(host)[source]
class_version = 1
clear_var(name)[source]
get_hostnames()[source]
get_vars()[source]
remove_host(host)[source]
set_remote(remote_flag)[source]
set_var(name, value)[source]
upgrade()[source]

kollacli.common.inventory module

class kollacli.common.inventory.Inventory[source]

Bases: object

add_group(groupname)[source]
add_group_to_service(groupname, servicename)[source]
add_host(hostname, groupname=None)[source]

add host

if groupname is none, create a new host if group name is not none, add host to group

class_version = 4

class version history

4: (v4.0.1):
  • removed concept of sub-services (not backward compatible)
3: (v3.0.1):
  • added aodh, ceph
  • fix to ensure all sub-services have service as parent

2: (v2.1.1) added ceilometer 1: (v2.0.1) initial release

create_json_gen_file(inventory_filter=None)[source]

create json inventory file using filter ({})

The inventory will be placed in a directory in /tmp, with the directory name of form kolla_uuid.py, where uuid is a unique deployment id.

return path to filtered json generator file

create_service(servicename)[source]
delete_service(servicename)[source]
get_ansible_json(inventory_filter=None)[source]

generate json inventory for ansible

The hosts and groups added to the json output for ansible will be filtered by the hostnames and groupnames in the deploy filters. This allows a more targeted deploy to a specific set of hosts or groups.

typical ansible json format: { ‘group’: {

‘hosts’: [
‘192.168.28.71’, ‘192.168.28.72’

], ‘vars’: {

‘ansible_ssh_user’: ‘johndoe’, ‘ansible_ssh_private_key_file’: ‘~/.ssh/mykey’, ‘example_variable’: ‘value’

} ‘children’: [ ‘marietta’, ‘5points’ ]

}, ‘_meta’: {

‘hostvars’: {
‘192.168.28.71’: {
‘host_specific_var’: ‘bar’

}, ‘192.168.28.72’: {

‘host_specific_var’: ‘foo’

}

}

}

}

get_group(groupname)[source]
get_group_hosts()[source]

return { groupname : [hostnames] }

get_group_services()[source]

get groups and their services

return { groupname: [servicenames] }

get_groupnames()[source]
get_groups(host=None)[source]

return all groups containing host

if hosts is none, return all groups in inventory

get_host(hostname)[source]
get_host_groups()[source]

return { hostname : [groupnames] }

get_hostnames()[source]
get_hosts()[source]
get_service(servicename, client_filter=False)[source]
get_services(client_filter=False)[source]
static load()[source]

load the inventory from a pickle file

remove_all_hosts()[source]

remove all hosts.

remove_group(groupname)[source]
remove_group_from_service(groupname, servicename)[source]
remove_host(hostname, groupname=None)[source]

remove host

if groupname is none, delete host if group name is not none, remove host from group

remove_json_gen_file(path)[source]
run_ansible_command(ansible_command, hostname)[source]
static save(inventory)[source]

Save the inventory in a pickle file

set_deploy_mode(remote_flag)[source]
setup_host(hostname, password, uname=None)[source]
setup_hosts(hosts_info)[source]

setup multiple hosts

hosts_info is a dict of format: {‘hostname1’: {

‘password’: password ‘uname’: user_name }

} The uname entry is optional.

ssh_check_host(hostname)[source]
ssh_check_hosts(hostnames)[source]

ssh check for hosts

return {hostname: {‘success’: True|False,
‘msg’: message}}
upgrade()[source]
validate_groupnames(groupnames)[source]
validate_hostnames(hostnames)[source]
validate_servicenames(servicenames, client_filter=False)[source]
kollacli.common.inventory.remove_temp_inventory(path)[source]

remove temp inventory file and its parent directory

kollacli.common.passwords module

kollacli.common.passwords.clear_password(pwd_key)[source]

clear a password

if the password exists, it will be removed from the passwords file

kollacli.common.passwords.get_empty_password_values()[source]
kollacli.common.passwords.get_password_names()[source]

return a list of password names

kollacli.common.passwords.init_passwords()[source]
kollacli.common.passwords.set_password(pwd_key, pwd_value)[source]

set a password value

If the password name exists, it will be changed. If it doesn’t exist, a new password will be added.

kollacli.common.passwords.set_password_sshkey(pwd_key, private_key, public_key)[source]

kollacli.common.properties module

class kollacli.common.properties.AnsibleProperties[source]

Bases: object

clear_group_property(property_list, groups)[source]
clear_host_property(property_list, hosts)[source]
clear_property(property_list)[source]
get_all_override_flags()[source]
get_all_unique()[source]
get_group_list(group_list)[source]
get_host_list(host_list)[source]
get_property(property_name)[source]
get_property_value(property_name)[source]
set_group_property(property_dict, groups)[source]
set_host_property(property_dict, hosts)[source]
set_property(property_dict)[source]
class kollacli.common.properties.AnsibleProperty(name, value, file_name, overrides=False, orig_value=None, prop_type='global', target=None)[source]

Bases: object

class kollacli.common.properties.OverrideFlags[source]

Bases: object

kollacli.common.service module

class kollacli.common.service.Service(name)[source]

Bases: object

add_childname(childname)[source]
add_groupname(groupname)[source]
add_parentname(parentname)[source]
class_version = 1
get_childnames()[source]
get_groupnames()[source]
get_parentnames()[source]
get_vars()[source]
is_supported()[source]
remove_childname(childname)[source]
remove_groupname(groupname)[source]
remove_parentname(parentname)[source]
set_supported(supported)[source]
upgrade()[source]

kollacli.common.sshutils module

kollacli.common.sshutils.ssh_connect(net_addr, username, password)[source]
kollacli.common.sshutils.ssh_get_public_key()[source]
kollacli.common.sshutils.ssh_setup_host(net_addr, password, setup_user=None)[source]

kollacli.common.subservice module

class kollacli.common.subservice.SubService(name)[source]

Bases: object

add_groupname(groupname)[source]
class_version = 1
get_groupnames()[source]
get_parent_servicename()[source]
get_vars()[source]
remove_groupname(groupname)[source]
set_parent_servicename(parent_svc_name)[source]
upgrade()[source]

kollacli.common.support module

class kollacli.common.support.HostLogs(hostname, inventory, servicenames)[source]

Bases: object

filter_services()[source]

filter services to only those of interest

get_log(container_id)[source]

read the container log

load_container_info()[source]

get the list of containers on the host

write_logfile(dirpath, logname, logdata)[source]

write out one log file

write_logs(dirname)[source]

write out the log files for all containers

kollacli.common.support.dump(dirpath)[source]

Dumps configuration data for debugging

Dumps most files in /etc/kolla and /usr/share/kolla into a tar file so be given to support / development to help with debugging problems.

kollacli.common.support.get_logs(servicenames, hostname, dirname)[source]

kollacli.common.utils module

class kollacli.common.utils.Lock(lockpath, owner='unknown owner', use_flock=True)[source]

Bases: object

Object which represents an exclusive resource lock

flock usage is the default behavior but a separate pidfile mechanism is also available. flock doesn’t have the same orphaned lock issue that pidfile usage does. both need to be tests on NFS. if flock works then it seems better / less complicated for our needs.

acquire()[source]
is_owned_by_me()[source]

Returns True if we own the lock or False otherwise

release()[source]
wait_acquire(wait_duration=3, interval=0.1)[source]
class kollacli.common.utils.PidManager[source]

Bases: object

static get_child_pids(pid, child_pids=[])[source]

get child pids of parent pid

kollacli.common.utils.change_password(file_path, pname, pvalue=None, public_key=None, private_key=None, clear=False)[source]

change password in passwords.yml file

file_path: path to passwords file pname: name of password pvalue: value of password when not ssh key public_key: public ssh key private_key: private ssh key clear: flag to remove password

If clear, and password exists, remove it from the password file. If clear, and password doesn’t exists, nothing is done. If not clear, and key is not found, the new password will be added. If not clear, and key is found, edit password in place.

The passwords file contains both key-value pairs and key-dictionary pairs.

kollacli.common.utils.change_property(file_path, property_dict, clear=False)[source]

change property with a file

file_path: path to property file property_dict: dictionary of property names and values clear: flag to remove property

If clear, and property exists, remove it from the property file. If clear, and property doesn’t exists, nothing is done. If not clear, and key is not found, the new property will be appended. If not clear, and key is found, edit property in place.

kollacli.common.utils.check_arg(param, param_name, expected_type, none_ok=False, empty_ok=False, display_param=True)[source]
kollacli.common.utils.convert_list_to_string(alist)[source]
kollacli.common.utils.convert_lists_to_string(tuples, parsed_args)[source]

convert lists to strings

Because of the way cliff processes strings for tables, if a list has non-ascii chars in it, they would display as unicode bytes (u0414u0435u043au0430u0442). By converting the list to string here, the proper non-ascii chars are displayed.

This will only change the lists when the output is to a user visible medium. It cannot be changed if the display output is json, yaml, etc.

kollacli.common.utils.convert_to_unicode(the_string)[source]

convert string to unicode.

This is used to fixup extended ascii chars in strings. these chars cause errors in json pickle/unpickle.

kollacli.common.utils.get_admin_uids()[source]

get uid and gid of admin user

kollacli.common.utils.get_admin_user()[source]
kollacli.common.utils.get_ansible_command(playbook=False)[source]

get a python2 ansible command

Ansible cannot run yet with python3. If the current default python is py3, prefix the ansible command with a py2 interpreter.

kollacli.common.utils.get_ansible_etc()[source]
kollacli.common.utils.get_ansible_lock_path()[source]
kollacli.common.utils.get_ansible_plugin_dir()[source]
kollacli.common.utils.get_group_vars_dir()[source]
kollacli.common.utils.get_host_vars_dir()[source]
kollacli.common.utils.get_kolla_actions_path()[source]
kollacli.common.utils.get_kolla_etc()[source]
kollacli.common.utils.get_kolla_ansible_home()[source]
kollacli.common.utils.get_kolla_ansible_log_dir()[source]
kollacli.common.utils.get_kolla_log_file_size()[source]
kollacli.common.utils.get_kolla_cli_etc()[source]
kollacli.common.utils.get_kolla_cli_home()[source]
kollacli.common.utils.get_lock_enabled()[source]
kollacli.common.utils.get_log_level()[source]
kollacli.common.utils.get_property_list_length()[source]
kollacli.common.utils.get_setup_user()[source]
kollacli.common.utils.is_string_true(string)[source]

Return boolean True if string represents a true value (None is False)

kollacli.common.utils.run_cmd(cmd, print_output=True)[source]

run a system command

return: - err_msg: empty string=command succeeded

not None=command failed
  • output: string: all the output of the run command
kollacli.common.utils.safe_decode(obj_to_decode)[source]

Convert bytes or strings to unicode string

Converts strings, lists, or dictionaries to unicode.

kollacli.common.utils.sync_read_file(path, mode='r')[source]

synchronously read file

return file data

kollacli.common.utils.sync_write_file(path, data, mode='w')[source]

synchronously write file

Module contents