The cloud deployment configuration schema is an extension to the cloud config used by the os-client-config library:
cloud_config = {
'cloud_management': {
'driver': 'devstack',
'args': {
'address': 'devstack.local',
'username': 'root',
}
},
'power_managements': [
{
'driver': 'libvirt',
'args': {
'connection_uri': 'qemu+unix:///system',
}
}
]
}
Establish a connection to the cloud and verify it:
destructor = os_faults.connect(cloud_config)
destructor.verify()
The library can also read configuration from a file and the file can be in the following three formats: os-faults.{json,yaml,yml}. The configuration file can be specified in the OS_FAULTS_CONFIG environment variable or can be read from one of the default locations:
- current directory
- ~/.config/os-faults
- /etc/openstack
Make some destructive actions:
destructor.get_service(name='keystone').restart()
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 hardware server with a hostname
Simplified API is used to inject faults in a human-friendly form.
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])]
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]
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]
Get a service and restart it:
destructor = os_faults.connect(cloud_config)
service = destructor.get_service(name='glance-api')
service.restart()
Get all nodes in the cloud and reboot them:
nodes = destructor.get_nodes()
nodes.reboot()
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 = destructor.get_nodes(fqdns=fqdns)
nodes.disconnect(network_name='management')
Restart a service on a single node:
service = destructor.get_service(name='keystone')
nodes = service.get_nodes().pick()
service.restart(nodes)