Skip to content

chaostoolkit-incubator/chaostoolkit-openstack

Repository files navigation

Chaos Toolkit Extension for OpenStack.

Python versions

This project is a collection of actions and probes, gathered as an extension to the Chaos Toolkit.

Install

This package requires Python 3.6+

To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.

$ pip install -U chaostoolkit-openstack

Usage

To use the probes and actions from this package, add the following to your experiment file:

{
  "title": "bastion-stop-start",
  "description": "Stop/Start a bastion instance randomly",
  "tags": [],
  "configuration": {
    "openstack_cloud": "prd",
    "openstack_regions": ["REGION1", "REGION2"]
  },
  "method": [
    {
      "type": "action",
      "name": "terminate-bastion-instance",
      "provider": {
        "type": "python",
        "module": "chaosopenstack.compute.actions",
        "func": "stop_instances",
        "arguments": {
          "rand": true,
          "filters": {
            "name": "prd-bastion-*"
          }
        }
      },
      "pauses": {
        "after": 120
      }
    }
  ],
  "rollbacks": [
    {
      "type": "action",
      "name": "start-bastion-instance",
      "provider": {
        "type": "python",
        "module": "chaosopenstack.compute.actions",
        "func": "start_instances",
        "arguments": {
          "filters": {
            "name": "prd-bastion-*"
          }
        }
      }
    }
  ]
}

That's it!

Please explore the code to see existing probes and actions.

Configuration

This extension uses the openstacksdk library under the hood. This library expects that you have properly configured your environment to connect and authenticate with the Openstack APIs.

Use default profile from ~/.config/openstack/clouds.yml or /etc/openstack

This is the most basic case, assuming your default profile is properly configured in ~/.config/openstack/clouds.yml (or /etc/openstack), then you do not need to pass any specific credentials to the experiment.

Use profile from a custom path

You can export the OS_CLIENT_CONFIG_FILE to target a specific Config File, in this case also you do not need to pass any specific credentials to the experiment.

Contribute

If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.

The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR.

Develop

If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.

$ pip install -r requirements-dev.txt -r requirements.txt

Then, point your environment to this directory:

$ pip install -e .

Now, you can edit the files and they will be automatically be seen by your environment, even when running from the chaos command locally.

Test

To run the tests for the project execute the following:

$ pytest

Releases

No releases published

Packages

No packages published