kollacli.api package

Submodules

kollacli.api.client module

class kollacli.api.client.ClientApi[source]

Bases: kollacli.api.control_plane.ControlPlaneApi, kollacli.api.group.GroupApi, kollacli.api.host.HostApi, kollacli.api.password.PasswordApi, kollacli.api.properties.PropertyApi, kollacli.api.service.ServiceApi, kollacli.api.support.SupportApi

Client API Notes

Objects returned by the API contain a local copy of the information in the datastore. While changes made to the local copy will be reflected in the local object, changes made to the datastore from other objects will not be reflected in this local copy. The object will need to be re-fetched from the datastore to reflect the updates.

static base_call()[source]
static enable_console_logging(level, enable=True)[source]

enable/disable console logging for the api

enable: True/False level: logging.INFO, logging.DEBUG, logging.WARNING, logging.CRITICAL...

static get_version()[source]

kollacli.api.control_plane module

class kollacli.api.control_plane.ControlPlaneApi[source]

Bases: object

static deploy(hostnames=[], serial_flag=False, verbose_level=1, servicenames=[])[source]

Deploy.

Deploy containers to hosts.

Parameters:
  • hostnames (list of strings) – hosts to deploy to. If empty, then deploy to all.
  • serial_flag (boolean) – if true, deploy will be done one host at a time
  • verbose_level (integer) – the higher the number, the more verbose
  • servicenames (list of strings) – services to deploy. If empty, then deploy all.
Returns:

Job object

Return type:

Job

static pull(verbose_level=1)[source]

Pull.

Pull container images onto appropriate hosts.

Parameters:verbose_level (integer) – the higher the number, the more verbose
Returns:Job object
Return type:Job
static reconfigure(verbose_level=1)[source]

Reconfigure.

Reconfigure containers on hosts.

Parameters:verbose_level (integer) – the higher the number, the more verbose
Returns:Job object
Return type:Job
static set_deploy_mode(remote_mode)[source]

Set deploy mode.

Set deploy mode to either local or remote. Local indicates that the openstack deployment will be to the local host. Remote means that the deployment is executed via ssh.

NOTE: local mode is not supported and should never be used in production environments.

Parameters:remote_mode (bool) – if remote mode is True deployment is done via ssh
static upgrade(verbose_level=1, servicenames=[])[source]

Upgrade.

Parameters:
  • verbose_level (integer) – the higher the number, the more verbose
  • servicenames (list of strings) – services to upgrade. If empty, then upgrade all.
Returns:

Job object

Return type:

Job

Upgrade containers to new version specified by the property “openstack_release.”

kollacli.api.exceptions module

Exception definitions.

exception kollacli.api.exceptions.ClientException(message, *args)[source]

Bases: exceptions.Exception

KollaClient Base Class Exception

exception kollacli.api.exceptions.FailedOperation(message, *args)[source]

Bases: kollacli.api.exceptions.ClientException

exception kollacli.api.exceptions.HostError(message, *args)[source]

Bases: kollacli.api.exceptions.ClientException

exception kollacli.api.exceptions.HostsSshCheckError(hostnames, *args)[source]

Bases: kollacli.api.exceptions.ClientException

Host failed its ssh check

exception kollacli.api.exceptions.InvalidArgument(message, *args)[source]

Bases: kollacli.api.exceptions.ClientException

Invalid argument

exception kollacli.api.exceptions.InvalidConfiguration(message, *args)[source]

Bases: kollacli.api.exceptions.ClientException

Invalid configuration

exception kollacli.api.exceptions.MissingArgument(argname, *args)[source]

Bases: kollacli.api.exceptions.ClientException

Missing argument

exception kollacli.api.exceptions.NotInInventory(obj_type, obj_names, *args)[source]

Bases: kollacli.api.exceptions.ClientException

Not in inventory exception

kollacli.api.group module

class kollacli.api.group.Group(groupname, servicenames, hostnames)[source]

Bases: object

add_host(hostname)[source]

Add host to group

Parameters:hostname (string) – name of the host to add to the group
add_service(servicename)[source]

Add service to group

Parameters:servicename (string) – name of the service to add to the group
get_hosts()[source]

Get names of hosts associated with this group.

Returns:host names
Return type:list of strings
get_name()[source]

Get name

Returns:group name
Return type:string
get_services()[source]

Get names of services associated with this group.

Returns:service names
Return type:list of strings
remove_host(hostname)[source]

Remove host from group

Parameters:hostname (string) – name of the host to remove from the group
remove_service(servicename)[source]

Remove service from group

Parameters:servicename (string) – name of the service to remove from the group
class kollacli.api.group.GroupApi[source]

Bases: object

group_add(groupnames)[source]

Add groups to the inventory

Parameters:groupnames (list of strings) – names of the groups to add to the inventory
group_get(groupnames)[source]

Get selected groups in the inventory

Parameters:groupnames (list of strings) – names of groups to be read
Returns:groups
Return type:list of Group objects
group_get_all()[source]

Get all groups in the inventory

Returns:groups
Return type:list of Group objects
group_remove(groupnames)[source]

Remove groups from the inventory

Parameters:groupnames (list of strings) – names of the groups to remove from the inventory

kollacli.api.host module

class kollacli.api.host.Host(hostname, groupnames=[])[source]

Bases: object

get_groups()[source]

Get names of the groups associated with this host

Returns:group names
Return type:list of strings

Note: If the groups associated with this host change after this host is fetched, the host must be re-fetched to reflect those changes.

get_name()[source]

Get name

Returns:host name
Return type:string
class kollacli.api.host.HostApi[source]

Bases: object

static host_add(hostnames)[source]

Add hosts to the inventory

Parameters:hostnames – list of strings
static host_destroy(hostnames, destroy_type, verbose_level=1, include_data=False, remove_images=False)[source]

Destroy Hosts.

Stops and removes all kolla related docker containers on the specified hosts.

Parameters:
  • hostnames (list) – host names
  • destroy_type (string) – either ‘kill’ or ‘stop’
  • verbose_level (integer) – the higher the number, the more verbose
  • include_data (boolean) – if true, destroy data containers too.
  • remove_images (boolean) – if true, destroy will remove the docker images
Returns:

Job object

Return type:

Job

static host_get(hostnames)[source]

Get selected hosts in the inventory

Parameters:hostnames – list of strings
Returns:hosts
Return type:list of Host objects
static host_get_all()[source]

Get all hosts in the inventory

Returns:Hosts
Return type:list of Host objects
static host_precheck(hostnames, verbose_level=1)[source]

Check pre-deployment configuration of hosts.

Check if host is ready for a new deployment. This will fail if any of the hosts are not configured correctly or if they have already been deployed to. :param hostnames: host names :type hostnames: list :param verbose_level: the higher the number, the more verbose :type verbose_level: integer :return: Job object :rtype: Job

static host_remove(hostnames)[source]

Remove hosts from the inventory

Parameters:hostnames – list of strings
static host_setup(hosts_info)[source]

Setup multiple hosts for ssh access

hosts_info is a dictionary of form:
  • {hostname’: { ‘password’: password ‘uname’: user_name}, ... }

The uname entry is optional.

Parameters:hosts_info – dictionary
static host_ssh_check(hostnames)[source]

Check hosts for ssh connectivity

Check status is a dictionary of form:
  • {hostname: { ‘success’:<True|False>, ‘msg’:message_string}, ... }
Parameters:hostnames – list of strings
Returns:check status
Return type:dictionary
static host_stop(hostnames, verbose_level=1)[source]

Stop Hosts.

Stops all kolla related docker containers on the specified hosts.

Parameters:
  • hostnames (list) – host names
  • verbose_level (integer) – the higher the number, the more verbose
Returns:

Job object

Return type:

Job

kollacli.api.job module

class kollacli.api.job.Job(ansible_job)[source]

Bases: object

get_console_output()[source]

Get the console output from the job

Returns:console output useful for debugging failed jobs.
Return type:string
get_error_message()[source]

Get error message

Returns:if job failed, this will return the error message.
Return type:string
get_status()[source]

Get status of job

Returns:None: job is still running 0: job succeeded 1: job failed 2: job killed by user
Return type:int or None
kill()[source]

kill the job

wait()[source]

Wait for job to complete

Returns:0 if job succeeded, 1 if job failed
Return type:int

kollacli.api.password module

class kollacli.api.password.PasswordApi[source]

Bases: object

password_clear(name)[source]

Clear password

Parameters:name (string) – name of the password
password_get_names()[source]

Get password names

Returns:password names
Return type:list of strings
password_init()[source]

Init empty passwords

Init empty passwords and ssh keys in /etc/kolla/passwords.yml to auto-generated values

password_set(name, value)[source]

Set password

Parameters:
  • name (string) – name of the password
  • value (string) – value of the password
password_set_sshkey(name, private_key, public_key)[source]

Set password to an ssh key

Parameters:
  • name (string) – name of the password
  • private_key – ssh private key
  • public_key – ssh public key

kollacli.api.properties module

class kollacli.api.properties.Property(ansible_property, override_flags)[source]

Bases: object

Members:
  • name (str): key
  • value (Any): value
  • file_name (str): name of file property is from
  • overrides (bool): does the property override some other value
  • orig_value (str): the value which is overridden or None
  • target (str): group or host name for group or host properties
  • prop_type (str): one of ‘global’, ‘group’ or ‘host’
  • ovr_global (bool): true if property is overridden at global level
  • ovr_group (bool): true if property is overridden at group level
  • ovr_host (bool): true if property is overridden at host level
  • value_type (type): the python type of the value
class kollacli.api.properties.PropertyApi[source]

Bases: object

property_clear(property_list, property_type='global', change_set=None)[source]

Clear a property

Parameters:
  • property_list (list) – property list
  • property_type (string) – one of ‘global’, ‘group’ or ‘host’
  • change_set (list of strings) – for group or host clears this is the list of groups or hosts to clear the property for
property_get(property_type='global', get_set=None)[source]

Returns a list of Property objects

Parameters:
  • property_type (string) – one of ‘global’, ‘group’, or ‘host’
  • get_set (list of strings) – optional list of hosts or groups to be used when getting group or host related property lists
Returns:

properties

Return type:

list of Property objects

property_set(property_dict, property_type='global', change_set=None)[source]

Set a property

Parameters:
  • property_dict (dictionary) – property dictionary containing key / values
  • property_type (string) – one of ‘global’, ‘group’ or ‘host’
  • change_set (list of strings) – for group or host sets this is the list of groups or hosts to set the property for

kollacli.api.service module

class kollacli.api.service.Service(servicename, parentnames=[], childnames=[], groupnames=[])[source]

Bases: object

A service is one of the services available in openstack-kolla-ansible.

For example, this would be how the murano services would be represented:

  • murano
    • parentnames: []
    • childnames: [murano-api, murano-engine]
  • murano-api
    • parentnames: [murano]
    • childnames: []
  • murano-engine
    • parentnames: [murano]
    • childnames: []
get_children()[source]

Get names of the child services

Returns:child names
Return type:list of strings
get_groups()[source]

Get names of the groups

Returns:group names
Return type:list of strings

Note: If the groups associated with this service change after this service is fetched, the service must be re-fetched to reflect those changes.

get_name()[source]

Get name

Returns:service name
Return type:string
get_parents()[source]

Get name of parent services

Returns:parent service names
Return type:string
class kollacli.api.service.ServiceApi[source]

Bases: object

service_get(servicenames)[source]

Get selected services in the inventory

Parameters:servicenames (list of strings) – names of services to be read
Returns:services
Return type:list of Service objects
service_get_all()[source]

Get all services in the inventory

Returns:services
Return type:List of Service objects

kollacli.api.support module

class kollacli.api.support.SupportApi[source]

Bases: object

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.

Parameters:dirpath (string) – path to directory where dump will be placed
Returns:path to dump file
Return type:string
support_get_logs(servicenames, hostname, dirpath)[source]

get container logs

Fetch the container log files of services from the specified hosts. The log files will be placed in the named directory. All the containers for the host will be placed in a directory named hostname. The file names for each log will be servicename_id.log.

Parameters:
  • servicenames (list of strings) – names of services (ie nova, glance, etc)
  • hostname (string) – name of host to look for logs on
  • dirpath (string) – path of directory where log files will be written

Module contents