diff --git a/.zuul.yaml b/.zuul.yaml index 4b0b8626..6d59dadc 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -76,6 +76,27 @@ DEVSTACK_GATE_USE_PYTHON3: "True" USE_PYTHON3: "True" +- job: + name: cloudkitty-tempest-full-v2-storage-elasticsearch + parent: cloudkitty-tempest-full-v2-storage-influxdb + description: | + Job testing cloudkitty installation on devstack with python 2 and the + elasticsearch v2 storage driver and running tempest tests + vars: + devstack_localrc: + CLOUDKITTY_STORAGE_BACKEND: elasticsearch + CLOUDKITTY_STORAGE_VERSION: 2 + +- job: + name: cloudkitty-tempest-full-v2-storage-elasticsearch-py3 + parent: cloudkitty-tempest-full-v2-storage-elasticsearch + description: | + Job testing cloudkitty installation on devstack with python 3 and the + elasticsearch v2 storage driver and running tempest tests + vars: + devstack_localrc: + DEVSTACK_GATE_USE_PYTHON3: "True" + USE_PYTHON3: "True" - job: name: cloudkitty-tox-bandit @@ -113,6 +134,10 @@ jobs: - cloudkitty-tempest-full-v2-storage-influxdb - cloudkitty-tempest-full-v2-storage-influxdb-py3 + - cloudkitty-tempest-full-v2-storage-elasticsearch: + voting: false + - cloudkitty-tempest-full-v2-storage-elasticsearch-py3: + voting: false - cloudkitty-tempest-full-v1-storage-sqlalchemy - cloudkitty-tempest-full-v1-storage-sqlalchemy-py3 - cloudkitty-tempest-full-ipv6-only diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 54a35d01..8ee783ab 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -173,6 +173,11 @@ function configure_cloudkitty { iniset $CLOUDKITTY_CONF storage_${CLOUDKITTY_STORAGE_BACKEND} port ${CLOUDKITTY_INFLUXDB_PORT} fi + if [ "$CLOUDKITTY_STORAGE_BACKEND" == "elasticsearch" ]; then + iniset $CLOUDKITTY_CONF storage_${CLOUDKITTY_STORAGE_BACKEND} host ${CLOUDKITTY_ELASTICSEARCH_HOST} + iniset $CLOUDKITTY_CONF storage_${CLOUDKITTY_STORAGE_BACKEND} index_name ${CLOUDKITTY_ELASTICSEARCH_INDEX} + fi + # collect iniset $CLOUDKITTY_CONF collect collector $CLOUDKITTY_COLLECTOR iniset $CLOUDKITTY_CONF "collector_${CLOUDKITTY_COLLECTOR}" auth_section authinfos @@ -237,6 +242,12 @@ function create_influxdb_database { fi } +function create_elasticsearch_index { + if [ "$CLOUDKITTY_STORAGE_BACKEND" == "elasticsearch" ]; then + curl -XPUT "${CLOUDKITTY_ELASTICSEARCH_HOST}/${CLOUDKITTY_ELASTICSEARCH_INDEX}" + fi +} + # init_cloudkitty() - Initialize CloudKitty database function init_cloudkitty { # Delete existing cache @@ -253,6 +264,7 @@ function init_cloudkitty { recreate_database cloudkitty utf8 create_influxdb_database + create_elasticsearch_index # Migrate cloudkitty database $CLOUDKITTY_BIN_DIR/cloudkitty-dbsync upgrade @@ -289,6 +301,29 @@ function install_influx { sudo systemctl start influxdb || sudo systemctl restart influxdb } +function install_elasticsearch_ubuntu { + sudo apt install -qy openjdk-8-jre + local elasticsearch_file=$(get_extra_file https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.3.deb) + sudo dpkg -i --skip-same-version ${elasticsearch_file} +} + +function install_elasticsearch_fedora { + sudo yum install -y java-1.8.0-openjdk + local elasticsearch_file=$(get_extra_file https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.3.rpm) + sudo yum localinstall -y ${elasticsearch_file} +} + +function install_elasticsearch { + if is_ubuntu; then + install_elasticsearch_ubuntu + elif is_fedora; then + install_elasticsearch_fedora + else + die $LINENO "Distribution must be Debian or Fedora-based" + fi + sudo systemctl start elasticsearch || sudo systemctl restart elasticsearch +} + # install_cloudkitty() - Collect source and prepare function install_cloudkitty { git_clone $CLOUDKITTY_REPO $CLOUDKITTY_DIR $CLOUDKITTY_BRANCH @@ -296,6 +331,8 @@ function install_cloudkitty { if [ $CLOUDKITTY_STORAGE_BACKEND == 'influxdb' ]; then install_influx + elif [ $CLOUDKITTY_STORAGE_BACKEND == 'elasticsearch' ]; then + install_elasticsearch fi } diff --git a/devstack/settings b/devstack/settings index 968c3b5b..5afb2ba6 100644 --- a/devstack/settings +++ b/devstack/settings @@ -72,3 +72,7 @@ CLOUDKITTY_INFLUXDB_PASSWORD=${CLOUDKITTY_INFLUXDB_PASSWORD:-cloudkitty} CLOUDKITTY_INFLUXDB_HOST=${CLOUDKITTY_INFLUXDB_HOST:-"localhost"} CLOUDKITTY_INFLUXDB_PORT=${CLOUDKITTY_INFLUXDB_PORT:-"8086"} CLOUDKITTY_INFLUXDB_DATABASE=${CLOUDKITTY_INFLUXDB_DATABASE:-"cloudkitty"} + +# Set elasticsearch info +CLOUDKITTY_ELASTICSEARCH_HOST=${CLOUDKITTY_ELASTICSEARCH_HOST:-"http://localhost:9200"} +CLOUDKITTY_ELASTICSEARCH_INDEX=${CLOUDKITTY_ELASTICSEARCH_INDEX:-"cloudkitty"}