freezer_dr.common package

Submodules

freezer_dr.common.config module

Manage all configuration the OpenStack way.

freezer_dr.common.config.build_os_options()[source]

Build oslo options related to OpenStack environment.

freezer_dr.common.config.configure()[source]

Register configuration.

freezer_dr.common.config.list_opts()[source]
freezer_dr.common.config.setup_logging()[source]

Set some oslo log defaults.

freezer_dr.common.daemon module

Generic deamon.

class freezer_dr.common.daemon.Daemon(pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')[source]

Bases: object

A generic daemon class.

Usage: subclass the Daemon class and override the run() method

daemonize()[source]

Do the UNIX double-fork magic.

See Stevens’ “Advanced Programming in the UNIX Environment” for details (ISBN 0201563177) http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16

delpid()[source]

Delete PID file.

restart()[source]

Restart the daemon.

run()[source]

You should override this method when you subclass Daemon.

It will be called after the process has been daemonized by start() or restart().

start()[source]

Start the daemon.

status()[source]

Check daemon status.

stop()[source]

Stop the daemon.

freezer_dr.common.osclient module

OpenStack client class.

class freezer_dr.common.osclient.OSClient(authurl, authmethod='password', **kwargs)[source]

Bases: object

Provide OpenStack credentials to initalize the connection.

auth()[source]

Create a session.

disable_node(node)[source]

Disable nova on the failing node.

evacuate(nodes, shared_storage=False)[source]

Will get the hypervisors and list all running VMs on it and then start Evacuating one by one … :param nodes: List of nodes to be evacuated ! :param shared_storage: Boolean, True if your compute nodes are running under shared storage and False otherwise :return: List of nodes with VMs that were running on that node

get_affected_tenants(node)[source]
get_hypervisor(node)[source]

Get an instance of the hypervisor.

Parameters

node – dict contains host index

Returns

Hypervisor

get_hypervisor_details(node)[source]

Get details about hypervisor running on the provided node.

get_hypervisor_instances(node)[source]

Get instances from an hypervisor.

get_hypervisors_stats()[source]

Get stats for all hypervisors.

get_instances_list(node)[source]

Get instances running on a node for all tenants.

get_neutronclient()[source]
get_node_status(node)[source]

Check the node nova-service status and if it’s disabled or not. :param node: dict contains node info :return: True or False. True => node disabled, False => node is enabled or unknow status !

get_novaclient()[source]
get_session()[source]

Get the authentication section.

list_tenants()[source]

List tenants.

neutronagents(hosts=[])[source]
novacomputes()[source]
novahypervisors()[source]
set_in_maintenance(nodes)[source]

Set compute nodes in maintenance mode.

users_on_tenant(tenant)[source]

List user per project.

freezer_dr.common.utils module

Utility functions shared from all modules into the project.

freezer_dr.common.utils.env(*env_vars, **kwargs)[source]

Get all environment variables.

freezer_dr.common.utils.get_admin_os_client()[source]

Return admin client data.

Loads credentials from [keystone_authtoken] section in the configuration file and initialize the client with admin privileges and return an instance of the client :return: Initialized instance of OS Client

freezer_dr.common.utils.get_os_client()[source]

Return the OpenStack client.

Loads credentials from [keystone_authtoken] section in the configuration file and initialize the client and return an instance of the client :return: Initialized instance of OS Client

freezer_dr.common.utils.load_jinja_templates(template_dir, template_name, template_vars)[source]

Load and render existing Jinja2 templates.

The main purpose of the function is to prepare the message to be sent and render it for the driver to send it directly.

Parameters
  • template_dir – Location where jinja2 templates are stored

  • template_name – name of the template to load it

  • template_vars – Dict to replace existing vars in the template with values.

Returns

String message

freezer_dr.common.yaml_parser module

class freezer_dr.common.yaml_parser.YamlParser(yml_file, index='servers')[source]

Bases: object

find_server(key, value)[source]

Generic function to query the .yml file to get server information by any key. :param key: :param value: :return:

find_server_by_hostname(hostname)[source]

get server information ilo username, password and ip :param hostname: hostname matches one of the ones in the .yml file :return: dict contains the server information

find_server_by_ip(ip)[source]

get server information ilo username, password and ip :param ip: mgmt ip address of the server, this should be the same like the ip in the .yml file :return: dict contains server information

parse()[source]

Module contents