huang.zhiping 11e2f8a7e2 fix tox python3 overrides
We want to default to running all tox environments under python 3, so
set the basepython value in each environment.

We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.

We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.

Change-Id: Ie0fd5165d9b65ec1fc443ad08eaf7b708bfe73d4
2018-06-09 19:08:34 +08:00
2016-09-14 17:46:33 +03:00
2016-09-14 17:46:33 +03:00
2018-02-01 07:18:39 -08:00
2016-09-27 16:03:01 +03:00
2016-08-08 12:06:17 +03:00
2017-11-03 11:40:32 +01:00
2016-10-17 19:04:49 +03:00
2017-10-18 15:26:41 +02:00
2016-10-17 19:04:49 +03:00
2017-04-25 11:08:27 +03:00
2017-03-02 11:47:36 +04:00
2018-06-09 19:08:34 +08:00

OS-Faults

OpenStack fault-injection library

The library does destructive actions inside an OpenStack cloud. It provides an abstraction layer over different types of cloud deployments. The actions are implemented as drivers (e.g. DevStack driver, Fuel driver, Libvirt driver, IPMI driver).

Installation

Regular installation:

pip install os-faults

The library contains optional libvirt driver, if you plan to use it, please use the following command to install os-faults with extra dependencies:

pip install os-faults[libvirt]

Configuration

The cloud deployment configuration is specified in JSON/YAML format or Python dictionary.

The library operates with 2 types of objects:
  • service - is a software that runs in the cloud, e.g. nova-api
  • nodes - nodes that host the cloud, e.g. a server with a hostname

Example 1. DevStack

Connection to DevStack can be specified using the following YAML file:

cloud_management:
  driver: devstack
  args:
    address: devstack.local
    username: stack
    private_key_file: cloud_key
    iface: enp0s8

OS-Faults library will connect to DevStack by address devstack.local with user stack and SSH key located in file cloud_key. Default networking interface is specified with parameter iface. Note that user should have sudo permissions (by default DevStack user has them).

DevStack driver is responsible for service discovery. For more details please refer to driver documentation: http://os-faults.readthedocs.io/en/latest/drivers.html#devstack-systemd-devstackmanagement

Example 2. An OpenStack with services and power management

An arbitrary OpenStack can be handled too with help of universal driver. In this example os-faults is used as Python library.

cloud_config = {
    'cloud_management': {
        'driver': 'universal',
    },
    'node_discover': {
        'driver': 'node_list',
        'args': [
            {
                'ip': '192.168.5.127',
                'auth': {
                    'username': 'root',
                    'private_key_file': 'openstack_key',
                }
            },
            {
                'ip': '192.168.5.128',
                'auth': {
                    'username': 'root',
                    'private_key_file': 'openstack_key',
                }
            }
        ]
    },
    'services': {
        'memcached': {
            'driver': 'system_service',
            'args': {
                'service_name': 'memcached',
                'grep': 'memcached',
            }
        }
    },
    'power_managements': [
        {
            'driver': 'libvirt',
            'args': {
                'connection_uri': 'qemu+unix:///system',
            }
        },
    ]
}

The config contains all OpenStack nodes with credentials and all services. OS-Faults will automatically figure out the mapping between services and nodes. Power management configuration is flexible and supports mixed bare-metal / virtualized deployments.

First let's establish a connection to the cloud and verify it:

cloud_management = os_faults.connect(cloud_config)
cloud_management.verify()

The library can also read configuration from a file in YAML or JSON format. The configuration file can be specified in the OS_FAULTS_CONFIG environment variable. By default the library searches for file os-faults.{json,yaml,yml} in one of locations: * current directory * ~/.config/os-faults * /etc/openstack

Now let's make some destructive action:

cloud_management.get_service(name='memcached').kill()

Human API

Human API is simplified and self-descriptive. It includes multiple commands that are written like normal English sentences.

Service-oriented command performs specified action against service on all, on one random node or on the node specified by FQDN:

<action> <service> service [on (random|one|single|<fqdn> node[s])]
Examples:
  • Restart Keystone service - restarts Keystone service on all nodes.
  • kill nova-api service on one node - kills Nova API on one randomly-picked node.

Node-oriented command performs specified action on node specified by FQDN or set of service's nodes:

<action> [random|one|single|<fqdn>] node[s] [with <service> service]
Examples:
  • Reboot one node with mysql - reboots one random node with MySQL.
  • Reset node-2.domain.tld node - resets node node-2.domain.tld.

Network-oriented command is a subset of node-oriented and performs network management operation on selected nodes:

<action> <network> network on [random|one|single|<fqdn>] node[s]
    [with <service> service]
Examples:
  • Disconnect management network on nodes with rabbitmq service - shuts down management network interface on all nodes where rabbitmq runs.
  • Connect storage network on node-1.domain.tld node - enables storage network interface on node-1.domain.tld.

Extended API

1. Service actions

Get a service and restart it:

cloud_management = os_faults.connect(cloud_config)
service = cloud_management.get_service(name='glance-api')
service.restart()
Available actions:
  • start - start Service
  • terminate - terminate Service gracefully
  • restart - restart Service
  • kill - terminate Service abruptly
  • unplug - unplug Service out of network
  • plug - plug Service into network

2. Node actions

Get all nodes in the cloud and reboot them:

nodes = cloud_management.get_nodes()
nodes.reboot()
Available actions:
  • reboot - reboot all nodes gracefully
  • poweroff - power off all nodes abruptly
  • reset - reset (cold restart) all nodes
  • disconnect - disable network with the specified name on all nodes
  • connect - enable network with the specified name on all nodes

3. Operate with nodes

Get all nodes where a service runs, pick one of them and reset:

nodes = service.get_nodes()
one = nodes.pick()
one.reset()

Get nodes where l3-agent runs and disable the management network on them:

fqdns = neutron.l3_agent_list_hosting_router(router_id)
nodes = cloud_management.get_nodes(fqdns=fqdns)
nodes.disconnect(network_name='management')

4. Operate with services

Restart a service on a single node:

service = cloud_management.get_service(name='keystone')
nodes = service.get_nodes().pick()
service.restart(nodes)
Description
An OpenStack fault injection library
Readme 1.9 MiB
Languages
Python 99.5%
Shell 0.5%