Add DevStack plugin

The plugin configures DevStack to be used with os-faults
command-line tools.

Change-Id: I2febc154eb4d8a5aa038b9320d545c02b5f513ac
This commit is contained in:
Ilya Shakhat 2019-01-09 17:28:42 +01:00
parent cd747e50df
commit e1cc109486
8 changed files with 61 additions and 41 deletions

1
.gitignore vendored
View File

@ -15,7 +15,6 @@ var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs

View File

@ -25,3 +25,5 @@
- openstack/os-faults
vars:
tox_envlist: devstack
devstack_plugins:
os-faults: https://git.openstack.org/openstack/os-faults

14
devstack/README.rst Normal file
View File

@ -0,0 +1,14 @@
==============================
Enabling OS-Faults in DevStack
==============================
To configure DevStack and enable OS-Faults edit ``${DEVSTACK_DIR}/local.conf``
file and add the following to ``[[local|localrc]]`` section::
enable_plugin os-faults https://git.openstack.org/openstack/os-faults master
Run DevStack as normal::
$ ./stack.sh

20
devstack/lib/os-faults Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
CONF_DIR=/etc/openstack
SSH_DIR=~/.ssh
PROJECT_DIR=${DEST}/os-faults
function install_os_faults() {
setup_develop ${PROJECT_DIR}
install_package ansible
}
function configure_os_faults() {
mkdir -p ${SSH_DIR}
ssh-keygen -t rsa -f ${SSH_DIR}/os-faults-key -N ''
cat ${SSH_DIR}/os-faults-key.pub >> ${SSH_DIR}/authorized_keys
cp ${SSH_DIR}/os-faults-key* ${PROJECT_DIR}
ssh -vvv -i ${SSH_DIR}/os-faults-key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o IdentitiesOnly=yes stack@localhost hostname
cp ${PROJECT_DIR}/devstack/lib/os-faults.yaml ${CONF_DIR}
os-faults --debug verify
}

View File

@ -0,0 +1,8 @@
cloud_management:
driver: devstack
args:
address: localhost
auth:
username: stack
private_key_file: /opt/stack/.ssh/os-faults-key
iface: lo

14
devstack/plugin.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# DevStack plugin to install os-faults
LIBDIR=${DEST}/os-faults/devstack/lib
source ${LIBDIR}/os-faults
if [[ "$1" == "stack" && "$2" == "install" ]]; then
echo_summary "Installing OS-Faults"
install_os_faults
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
echo_summary "Configuring OS-Faults"
configure_os_faults
fi

3
devstack/settings Normal file
View File

@ -0,0 +1,3 @@
# Devstack settings
enable_service os-faults

View File

@ -5,49 +5,9 @@
- stack_home: "/opt/stack"
- os_faults_home: "/opt/stack/os-faults"
tasks:
- name: Create folder for SSH keys (as stack user)
file:
path: "{{ stack_home }}/.ssh"
state: directory
mode: 0755
become: yes
become_user: stack
- name: Generate SSH key pair
command: "ssh-keygen -t rsa -f {{ os_faults_home }}/os_faults_key -N ''"
become: yes
become_user: stack
- name: List os-faults folder
command: "ls -al {{ os_faults_home }}"
become: yes
become_user: stack
- name: Add os-faults key into authorized_keys for stack user
shell: |
cat {{ os_faults_home}}/os_faults_key.pub >> {{ stack_home }}/.ssh/authorized_keys
become: yes
become_user: stack
- name: Check SSH connection using os-faults key
command: "ssh -vvv -i os_faults_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o IdentitiesOnly=yes stack@localhost"
args:
chdir: "{{ os_faults_home }}"
become: yes
become_user: stack
- name: Run tests
command: "tox -e {{tox_envlist}}"
args:
chdir: "{{ os_faults_home }}"
become: yes
become_user: stack
- name: Check connectivity using command-line tool
shell: |
cd /opt/stack/os-faults
. .tox/devstack/bin/activate
os-inject-fault -c /opt/stack/os-faults/os_faults/tests/devstack/os-faults-universal.yaml -vd
become: yes
become_user: stack