Bases: object
add host
if groupname is none, create a new host if group name is not none, add host to group
class version history
2: (v2.1.1) added ceilometer 1: (v2.0.1) initial release
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
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’}
}
}
}
return all groups containing host
if hosts is none, return all groups in inventory
remove host
if groupname is none, delete host if group name is not none, remove host from group
setup multiple hosts
hosts_info is a dict of format: {‘hostname1’: {
‘password’: password ‘uname’: user_name }
} The uname entry is optional.
clear a password
if the password exists, it will be removed from the passwords file
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.
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.
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.
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.
convert string to unicode.
This is used to fixup extended ascii chars in strings. these chars cause errors in json pickle/unpickle.
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.
Return boolean True if string represents a true value (None is False)
run a system command
return: - err_msg: empty string=command succeeded
not None=command failed
Convert bytes or strings to unicode string
Converts strings, lists, or dictionaries to unicode.