common Package¶
ansible_inventory
Module¶
host
Module¶
host_group
Module¶
inventory
Module¶
-
class
kolla_cli.common.inventory.
Inventory
(inventory_path=None)¶ Bases:
object
-
add_group
(groupname)¶
-
add_group_to_service
(groupname, servicename)¶
-
add_host
(hostname, groupname=None)¶ 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)¶ 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)¶
-
delete_service
(servicename)¶
-
get_ansible_json
(inventory_filter=None)¶ 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)¶
-
get_group_hosts
()¶ return { groupname : [hostnames] }
-
get_group_services
()¶ get groups and their services
return { groupname: [servicenames] }
-
get_groupnames
()¶
-
get_groups
(host=None)¶ return all groups containing host
if hosts is none, return all groups in inventory
-
get_host
(hostname)¶
-
get_host_groups
()¶ return { hostname : [groupnames] }
-
get_hostnames
()¶
-
get_hosts
()¶
-
get_service
(servicename, client_filter=False)¶
-
get_services
(client_filter=False)¶
-
import_inventory
(inventory_path)¶
-
static
load
()¶ load the inventory from a pickle file
-
remove_all_hosts
()¶ remove all hosts.
-
remove_group
(groupname)¶
-
remove_group_from_service
(groupname, servicename)¶
-
remove_host
(hostname, groupname=None)¶ remove host
if groupname is none, delete host if group name is not none, remove host from group
-
remove_json_gen_file
(path)¶
-
run_ansible_command
(ansible_command, hostname)¶
-
static
save
(inventory)¶ Save the inventory in a pickle file
-
set_deploy_mode
(remote_flag)¶
-
setup_host
(hostname, password, uname=None)¶
-
setup_hosts
(hosts_info)¶ 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)¶
-
ssh_check_hosts
(hostnames)¶ ssh check for hosts
- return {hostname: {‘success’: True|False,
‘msg’: message}}
-
upgrade
()¶
-
validate_groupnames
(groupnames)¶
-
validate_hostnames
(hostnames)¶
-
validate_servicenames
(servicenames, client_filter=False)¶
-
-
kolla_cli.common.inventory.
remove_temp_inventory
(path)¶ remove temp inventory file and its parent directory
passwords
Module¶
-
kolla_cli.common.passwords.
clear_password
(pwd_key)¶ clear a password
if the password exists, it will be removed from the passwords file
-
kolla_cli.common.passwords.
get_empty_password_values
()¶
-
kolla_cli.common.passwords.
get_password_names
()¶ return a list of password names
-
kolla_cli.common.passwords.
init_passwords
()¶
-
kolla_cli.common.passwords.
set_password
(pwd_key, pwd_value)¶ set a password value
If the password name exists, it will be changed. If it doesn’t exist, a new password will be added.
-
kolla_cli.common.passwords.
set_password_sshkey
(pwd_key, private_key, public_key)¶
properties
Module¶
-
class
kolla_cli.common.properties.
AnsibleProperties
¶ Bases:
object
-
clear_group_property
(property_list, groups)¶
-
clear_host_property
(property_list, hosts)¶
-
clear_property
(property_list)¶
-
get_all_override_flags
()¶
-
get_all_unique
()¶
-
get_group_list
(group_list)¶
-
get_host_list
(host_list)¶
-
get_property
(property_name)¶
-
get_property_value
(property_name)¶
-
set_group_property
(property_dict, groups)¶
-
set_host_property
(property_dict, hosts)¶
-
set_property
(property_dict)¶
-
-
class
kolla_cli.common.properties.
AnsibleProperty
(name, value, file_name, overrides=False, orig_value=None, prop_type='global', target=None)¶ Bases:
object
-
class
kolla_cli.common.properties.
OverrideFlags
¶ Bases:
object
service
Module¶
-
class
kolla_cli.common.service.
Service
(name)¶ Bases:
object
-
add_childname
(childname)¶
-
add_groupname
(groupname)¶
-
add_parentname
(parentname)¶
-
class_version
= 1¶
-
get_childnames
()¶
-
get_groupnames
()¶
-
get_parentnames
()¶
-
get_vars
()¶
-
is_supported
()¶
-
remove_childname
(childname)¶
-
remove_groupname
(groupname)¶
-
remove_parentname
(parentname)¶
-
set_groupnames
(groupnames)¶
-
set_supported
(supported)¶
-
upgrade
()¶
-
sshutils
Module¶
-
kolla_cli.common.sshutils.
ssh_connect
(net_addr, username, password)¶
-
kolla_cli.common.sshutils.
ssh_get_public_key
()¶
-
kolla_cli.common.sshutils.
ssh_setup_host
(net_addr, password, setup_user=None)¶
subservice
Module¶
support
Module¶
-
class
kolla_cli.common.support.
HostLogs
(hostname, inventory, servicenames)¶ Bases:
object
-
filter_services
()¶ filter services to only those of interest
-
get_log
(container_id)¶ read the container log
-
load_container_info
()¶ get the list of containers on the host
-
write_logfile
(dirpath, logname, logdata)¶ write out one log file
-
write_logs
(dirname)¶ write out the log files for all containers
-
-
kolla_cli.common.support.
dump
(dirpath)¶ 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.
-
kolla_cli.common.support.
get_logs
(servicenames, hostname, dirname)¶
utils
Module¶
-
class
kolla_cli.common.utils.
Lock
(lockpath=None, owner='unknown owner', use_flock=True)¶ 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
()¶
-
get_lockpath
()¶
-
is_owned_by_me
()¶ Returns True if we own the lock or False otherwise
-
release
()¶
-
wait_acquire
(wait_duration=3, interval=0.1)¶
-
-
class
kolla_cli.common.utils.
PidManager
¶ Bases:
object
-
static
get_child_pids
(pid, child_pids=[])¶ get child pids of parent pid
-
static
-
kolla_cli.common.utils.
change_password
(file_path, pname, pvalue=None, public_key=None, private_key=None, clear=False)¶ 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 clear password
If key is not found, an error is returned. If clear, and password exists, remove password. If clear, and password is already empty, nothing is done. If not clear, edit password in place.
The passwords file contains both key-value pairs and key-dictionary pairs. Type is maintained so you cannot change a key-dictionary password to a key-value password or the other way around.
-
kolla_cli.common.utils.
change_property
(file_path, property_dict, clear=False)¶ 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.
-
kolla_cli.common.utils.
check_arg
(param, param_name, expected_type, none_ok=False, empty_ok=False, display_param=True)¶
-
kolla_cli.common.utils.
clear_all_passwords
()¶ clear all passwords in passwords.yml file
-
kolla_cli.common.utils.
convert_list_to_string
(alist)¶
-
kolla_cli.common.utils.
convert_lists_to_string
(tuples, parsed_args)¶ 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 (Декат). 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.
-
kolla_cli.common.utils.
convert_to_unicode
(the_string)¶ convert string to unicode.
This is used to fixup extended ascii chars in strings. these chars cause errors in json pickle/unpickle.
-
kolla_cli.common.utils.
disallow_chars
(param, param_name, chars)¶
-
kolla_cli.common.utils.
get_admin_uids
()¶ get uid and gid of admin user
-
kolla_cli.common.utils.
get_admin_user
()¶
-
kolla_cli.common.utils.
get_ansible_command
(playbook=False)¶ Get the ansible command
-
kolla_cli.common.utils.
get_group_vars_dir
()¶
-
kolla_cli.common.utils.
get_host_vars_dir
()¶
-
kolla_cli.common.utils.
get_kolla_actions_path
()¶
-
kolla_cli.common.utils.
get_kolla_ansible_home
()¶
-
kolla_cli.common.utils.
get_kolla_cli_etc
()¶
-
kolla_cli.common.utils.
get_kolla_cli_home
()¶
-
kolla_cli.common.utils.
get_kolla_etc
()¶
-
kolla_cli.common.utils.
get_lock_enabled
()¶
-
kolla_cli.common.utils.
get_log_level
()¶
-
kolla_cli.common.utils.
get_property_list_length
()¶
-
kolla_cli.common.utils.
get_setup_user
()¶
-
kolla_cli.common.utils.
get_tools_path
()¶
-
kolla_cli.common.utils.
handers_action_result
(job, status, verbose_level)¶
-
kolla_cli.common.utils.
is_ssh_password
(password)¶
-
kolla_cli.common.utils.
is_string_true
(string)¶ Return boolean True if string represents a true value (None is False)
-
kolla_cli.common.utils.
run_cmd
(cmd, print_output=True)¶ run a system command
- return:
- err_msg:
empty string=command succeeded not None=command failed
- output:
string: all the output of the run command
-
kolla_cli.common.utils.
safe_decode
(obj_to_decode)¶ Convert bytes or strings to unicode string
Converts strings, lists, or dictionaries to unicode.
-
kolla_cli.common.utils.
sync_read_file
(path, mode='r')¶ synchronously read file
return file data
-
kolla_cli.common.utils.
sync_write_file
(path, data, mode='w')¶ synchronously write file