Browse Source

Refactor devstack-plugin

* Make monasca-event-api devstack plugin compatible
with monaca devstack metrics and logs plugins
* Add monasca-ui
* Enable events visualization in kibana
* By default metrics and logs pipelines are disabled
* Change deployment mode from gunicorn to uwsgi

Story: 2003815
Task: 26569

Depends-On: https://review.openstack.org/#/c/593602/
Change-Id: I7efb969d89f0733bf27517d393cd024750e278a7
tags/0.3.0
Adrian Czarnecki 1 year ago
parent
commit
3c5e504ede
16 changed files with 263 additions and 258 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -0
      devstack/Vagrantfile
  3. +80
    -0
      devstack/files/kibana/kibana.yml
  4. +6
    -67
      devstack/lib/elasticsearch.sh
  5. +20
    -5
      devstack/lib/events-api.sh
  6. +2
    -3
      devstack/lib/events-persister.sh
  7. +0
    -66
      devstack/lib/kafka.sh
  8. +48
    -0
      devstack/lib/kibana.sh
  9. +32
    -0
      devstack/lib/monasca-ui.sh
  10. +0
    -9
      devstack/lib/utils.sh
  11. +0
    -67
      devstack/lib/zookeeper.sh
  12. +29
    -35
      devstack/plugin.sh
  13. +1
    -0
      devstack/settings
  14. +25
    -0
      etc/monasca/events-api-uwsgi.ini
  15. +11
    -3
      monasca_events_api/app/wsgi.py
  16. +3
    -3
      setup.cfg

+ 1
- 0
.gitignore View File

@@ -15,6 +15,7 @@ ChangeLog
MANIFEST
monasca.log

.vagrant
*.log
*.swp
*.iml


+ 5
- 0
devstack/Vagrantfile View File

@@ -80,8 +80,13 @@ LOG_COLOR=False

disable_all_services
enable_service rabbit mysql key tempest horizon
disable_service monasca-api monasca-thresh monasca-agent monasca-notification
disable_service monasca-log-persister monasca-log-agent monasca-log-metrics monasca-log-transformer monasca-log-api

enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api
enable_plugin monasca-log-api https://git.openstack.org/openstack/monasca-log-api
enable_plugin monasca-events-api https://git.openstack.org/openstack/monasca-events-api
enable_plugin monasca-tempest-plugin https://git.openstack.org/openstack/monasca-tempest-plugin

' > local.conf
./stack.sh


+ 80
- 0
devstack/files/kibana/kibana.yml View File

@@ -0,0 +1,80 @@
# Kibana is served by a back end server. This controls which port to use.
server.port: %KIBANA_SERVICE_PORT%

# The host to bind the server to.
server.host: %KIBANA_SERVICE_HOST%

# If you are running kibana behind a proxy, and want to mount it at a path,
# specify that path here. The basePath can't end in a slash.
server.basePath: /dashboard/monitoring/logs_proxy

# The Elasticsearch instance to use for all your queries.
elasticsearch.url: http://%ES_SERVICE_BIND_HOST%:%ES_SERVICE_BIND_PORT%

# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
# then the host you use to connect to *this* Kibana instance will be sent.
elasticsearch.preserveHost: True

# Kibana uses an index in Elasticsearch to store saved searches, visualizations
# and dashboards. It will create a new index if it doesn't already exist.
kibana.index: ".kibana"

# The default application to load.
kibana.defaultAppId: "discover"

# If your Elasticsearch is protected with basic auth, these are the user credentials
# used by the Kibana server to perform maintenance on the kibana_index at startup. Your Kibana
# users will still need to authenticate with Elasticsearch (which is proxied through
# the Kibana server)
# elasticsearch.username: "user"
# elasticsearch.password: "pass"

# SSL for outgoing requests from the Kibana Server to the browser (PEM formatted)
# server.ssl.cert: /path/to/your/server.crt
# server.ssl.key: /path/to/your/server.key

# Optional setting to validate that your Elasticsearch backend uses the same key files (PEM formatted)
# elasticsearch.ssl.cert: /path/to/your/client.crt
# elasticsearch.ssl.key: /path/to/your/client.key

# If you need to provide a CA certificate for your Elasticsearch instance, put
# the path of the pem file here.
# elasticsearch.ssl.ca: /path/to/your/CA.pem

# Set to false to have a complete disregard for the validity of the SSL
# certificate.
# elasticsearch.ssl.verify: true

# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to
# request_timeout setting
elasticsearch.pingTimeout: 1500

# Time in milliseconds to wait for responses from the back end or elasticsearch.
# This must be > 0
elasticsearch.requestTimeout: 300000

# Time in milliseconds for Elasticsearch to wait for responses from shards.
# Set to 0 to disable.
elasticsearch.shardTimeout: 0

# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying
elasticsearch.startupTimeout: 5000

# Set the path to where you would like the process id file to be created.
# pid.file: /var/run/kibana.pid

# Set this to true to suppress all logging output.
logging.silent: false
# Set this to true to suppress all logging output except for error messages.
logging.quiet: false
# Set this to true to log all events, including system usage information and all requests.
logging.verbose: true

# monasca-kibana-plugin configuration
monasca-kibana-plugin.auth_uri: %KEYSTONE_AUTH_URI%
monasca-kibana-plugin.enabled: True
monasca-kibana-plugin.cookie.isSecure: False
monasca-kibana-plugin.logs: %KIBANA_LOGS_ENABLE%
monasca-kibana-plugin.events: True

optimize.useBundleCache: False

+ 6
- 67
devstack/lib/elasticsearch.sh View File

@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright 2017 FUJITSU LIMITED
# Copyright 2018 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.


_XTRACE_ELASTICSEARCH=$(set +o | grep xtrace)
set +o xtrace

@@ -23,76 +22,16 @@ function is_elasticsearch_enabled {
return 1
}

function install_elasticsearch {
if is_elasticsearch_enabled; then
echo_summary "Installing ElasticSearch ${ELASTICSEARCH_VERSION}"

local es_tarball=elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz
local es_url=http://download.elasticsearch.org/elasticsearch/elasticsearch/${es_tarball}
local es_dest=${FILES}/${es_tarball}

download_file ${es_url} ${es_dest}
tar xzf ${es_dest} -C $DEST

sudo chown -R $STACK_USER $DEST/elasticsearch-${ELASTICSEARCH_VERSION}
ln -sf $DEST/elasticsearch-${ELASTICSEARCH_VERSION} $ELASTICSEARCH_DIR
fi
}

function configure_elasticsearch {
if is_elasticsearch_enabled; then
echo_summary "Configuring ElasticSearch ${ELASTICSEARCH_VERSION}"

local templateDir=$ELASTICSEARCH_CFG_DIR/templates

for dir in $ELASTICSEARCH_LOG_DIR $templateDir $ELASTICSEARCH_DATA_DIR; do
sudo install -m 755 -d -o $STACK_USER $dir
done

sudo cp -f "${PLUGIN_FILES}"/elasticsearch/elasticsearch.yml $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
sudo chown -R $STACK_USER $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
sudo chmod 0644 $ELASTICSEARCH_CFG_DIR/elasticsearch.yml

sudo sed -e "
s|%ELASTICSEARCH_BIND_HOST%|$ELASTICSEARCH_BIND_HOST|g;
s|%ELASTICSEARCH_BIND_PORT%|$ELASTICSEARCH_BIND_PORT|g;
s|%ELASTICSEARCH_PUBLISH_HOST%|$ELASTICSEARCH_PUBLISH_HOST|g;
s|%ELASTICSEARCH_PUBLISH_PORT%|$ELASTICSEARCH_PUBLISH_PORT|g;
s|%ELASTICSEARCH_DATA_DIR%|$ELASTICSEARCH_DATA_DIR|g;
s|%ELASTICSEARCH_LOG_DIR%|$ELASTICSEARCH_LOG_DIR|g;
" -i $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
fi
}

function start_elasticsearch {
if is_elasticsearch_enabled; then
echo_summary "Starting ElasticSearch ${ELASTICSEARCH_VERSION}"
# TODO(jwachowski) find some nicer solution for setting env variable
echo_summary "Configuring Elasticsearch for events handling"
local service_file="/etc/systemd/system/devstack@elasticsearch.service"
# This property disable elasticsearch check for dots in filed name,
# Some event use dot in field name.
local es_java_opts="ES_JAVA_OPTS=-Dmapper.allow_dots_in_name=true"
iniset -sudo "$service_file" "Service" "Environment" "$es_java_opts"
run_process "elasticsearch" "$ELASTICSEARCH_DIR/bin/elasticsearch"
fi
}

function stop_elasticsearch {
if is_elasticsearch_enabled; then
echo_summary "Stopping ElasticSearch ${ELASTICSEARCH_VERSION}"
stop_process "elasticsearch" || true
fi
}

function clean_elasticsearch {
if is_elasticsearch_enabled; then
echo_summary "Cleaning Elasticsearch ${ELASTICSEARCH_VERSION}"

sudo rm -rf ELASTICSEARCH_DIR || true
sudo rm -rf ELASTICSEARCH_CFG_DIR || true
sudo rm -rf ELASTICSEARCH_LOG_DIR || true
sudo rm -rf ELASTICSEARCH_DATA_DIR || true
sudo rm -rf $FILES/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz || true
sudo rm -rf $DEST/elasticsearch-${ELASTICSEARCH_VERSION} || true
restart_process "elasticsearch" || true
fi
}

$_XTRACE_ELASTICSEARCH
$_XTRACE_ELASTICSEARCH

+ 20
- 5
devstack/lib/events-api.sh View File

@@ -27,10 +27,17 @@ function install_events_api {
if is_events_api_enabled; then
echo_summary "Installing Events Api"
git_clone $MONASCA_EVENTS_API_REPO $MONASCA_EVENTS_API_DIR $MONASCA_EVENTS_API_BRANCH
setup_develop ${MONASCA_EVENTS_API_DIR}
setup_develop $MONASCA_EVENTS_API_DIR
install_monasca_common
install_keystonemiddleware
pip_install gunicorn
pip_install uwsgi
fi
}

function install_monasca_common {
if use_library_from_git "monasca-common"; then
git_clone_by_name "monasca-common"
setup_dev_lib "monasca-common"
fi
}

@@ -44,6 +51,7 @@ function configure_events_api {

# Put config files in ``$MONASCA_EVENTS_API_CONF_DIR`` for everyone to find
sudo install -d -o $STACK_USER $MONASCA_EVENTS_API_CONF_DIR
sudo install -d -o $STACK_USER $MONASCA_EVENTS_LOG_DIR

create_monasca_events_cache_dir

@@ -67,17 +75,24 @@ function configure_events_api {
iniset "$MONASCA_EVENTS_API_CONF" keystone_authtoken project_name "admin"
iniset "$MONASCA_EVENTS_API_CONF" keystone_authtoken password $ADMIN_PASSWORD

# configure log-api-paste.ini
# configure events-api-paste.ini
iniset "$MONASCA_EVENTS_API_PASTE" server:main bind $MONASCA_EVENTS_API_SERVICE_HOST:$MONASCA_EVENTS_API_SERVICE_PORT
iniset "$MONASCA_EVENTS_API_PASTE" server:main chdir $MONASCA_EVENTS_API_DIR
iniset "$MONASCA_EVENTS_API_PASTE" server:main workers $API_WORKERS

rm -rf $MONASCA_EVENTS_API_UWSGI_CONF
MONASCA_EVENTS_API_WSGI=/usr/local/bin/monasca-events-api-wsgi
install -m 600 $MONASCA_EVENTS_API_DIR/etc/monasca/events-api-uwsgi.ini $MONASCA_EVENTS_API_UWSGI_CONF
write_uwsgi_config "$MONASCA_EVENTS_API_UWSGI_CONF" "$MONASCA_EVENTS_API_WSGI" "/events"

fi
}


function start_events_api {
if is_events_api_enabled; then
echo_summary "Starting Events Api"
run_process "monasca-events-api" "/usr/local/bin/gunicorn --paste $MONASCA_EVENTS_API_PASTE"
run_process "monasca-events-api" "/usr/local/bin/uwsgi --ini $MONASCA_EVENTS_API_UWSGI_CONF"
fi
}



+ 2
- 3
devstack/lib/events-persister.sh View File

@@ -25,9 +25,7 @@ function is_events_persister_enabled {

function install_events_persister {
if is_events_persister_enabled; then
echo_summary "Installing Events Persister"
git_clone $MONASCA_EVENTS_PERSISTER_REPO $MONASCA_EVENTS_PERSISTER_DIR $MONASCA_EVENTS_PERSISTER_BRANCH
setup_develop ${MONASCA_EVENTS_PERSISTER_DIR}
echo_summary "Installing Events Persister dependencies"
pip_install "elasticsearch>=2.0.0,<3.0.0"
fi
}
@@ -50,6 +48,7 @@ function configure_events_persister {
iniset "$MONASCA_EVENTS_PERSISTER_CONF" zookeeper partition_interval_recheck_seconds 15
iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka num_processors 0
iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events num_processors 1
iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events enabled True
iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events uri 127.0.0.1:9092
iniset "$MONASCA_EVENTS_PERSISTER_CONF" elasticsearch hosts ${ELASTICSEARCH_BIND_HOST}:${ELASTICSEARCH_BIND_PORT}



+ 0
- 66
devstack/lib/kafka.sh View File

@@ -23,72 +23,6 @@ function is_kafka_enabled {
return 1
}

function install_kafka {
if is_kafka_enabled; then
echo_summary "Installing kafka"

local kafka_tarball=kafka_${KAFKA_VERSION}.tgz
local kafka_tarball_url=${APACHE_ARCHIVES}kafka/${BASE_KAFKA_VERSION}/${kafka_tarball}
local kafka_tarball_dest=${FILES}/${kafka_tarball}

download_file ${kafka_tarball_url} ${kafka_tarball_dest}

sudo groupadd --system kafka || true
sudo useradd --system -g kafka kafka || true
sudo tar -xzf ${kafka_tarball_dest} -C /opt
sudo ln -sf /opt/kafka_${KAFKA_VERSION} /opt/kafka
sudo cp -f "${MONASCA_EVENTS_API_DIR}"/devstack/files/kafka/kafka-server-start.sh /opt/kafka_${KAFKA_VERSION}/bin/kafka-server-start.sh
fi
}

function configure_kafka {
if is_kafka_enabled; then
echo_summary "Configuring kafka"
sudo mkdir -p /var/kafka || true
sudo chown kafka:kafka /var/kafka
sudo chmod 755 /var/kafka
sudo rm -rf /var/kafka/lost+found
sudo mkdir -p /var/log/kafka || true
sudo chown kafka:kafka /var/log/kafka
sudo chmod 755 /var/log/kafka
sudo ln -sf /opt/kafka/config /etc/kafka
sudo ln -sf /var/log/kafka /opt/kafka/logs

sudo cp -f "${MONASCA_EVENTS_DEVSTACK_DIR}"/files/kafka/log4j.properties /etc/kafka/log4j.properties
sudo cp -f "${MONASCA_EVENTS_DEVSTACK_DIR}"/files/kafka/server.properties /etc/kafka/server.properties
sudo chown kafka:kafka /etc/kafka/*
sudo chmod 644 /etc/kafka/*
fi
}

function start_kafka {
if is_kafka_enabled; then
echo_summary "Starting Monasca Kafka"
run_process "kafka" "/opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties" "kafka" "kafka"
fi
}

function stop_kafka {
if is_kafka_enabled; then
echo_summary "Stopping Monasca Kafka"
stop_process "kafka" || true
fi
}

function clean_kafka {
if is_kafka_enabled; then
echo_summary "Clean Monasca Kafka"
sudo rm -rf /var/kafka
sudo rm -rf /var/log/kafka
sudo rm -rf /etc/kafka
sudo rm -rf /opt/kafka
sudo userdel kafka || true
sudo groupdel kafka || true
sudo rm -rf /opt/kafka_${KAFKA_VERSION}
sudo rm -rf ${FILES}/kafka_${KAFKA_VERSION}.tgz
fi
}

function create_kafka_topic {
if is_kafka_enabled; then
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 4 --topic $1


+ 48
- 0
devstack/lib/kibana.sh View File

@@ -0,0 +1,48 @@
#!/bin/bash

# Copyright 2018 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


_XTRACE_KIBANA=$(set +o | grep xtrace)
set +o xtrace

function configure_kibana {
if is_service_enabled kibana; then
echo_summary "Configuring Kibana"

sudo install -m 755 -d -o $STACK_USER $KIBANA_CFG_DIR

sudo cp -f "${MONASCA_EVENTS_API_DIR}"/devstack/files/kibana/kibana.yml $KIBANA_CFG_DIR/kibana.yml
sudo chown -R $STACK_USER $KIBANA_CFG_DIR/kibana.yml
sudo chmod 0644 $KIBANA_CFG_DIR/kibana.yml

sudo sed -e "
s|%KIBANA_SERVICE_HOST%|$KIBANA_SERVICE_HOST|g;
s|%KIBANA_SERVICE_PORT%|$KIBANA_SERVICE_PORT|g;
s|%KIBANA_SERVER_BASE_PATH%|$KIBANA_SERVER_BASE_PATH|g;
s|%ES_SERVICE_BIND_HOST%|$ES_SERVICE_BIND_HOST|g;
s|%ES_SERVICE_BIND_PORT%|$ES_SERVICE_BIND_PORT|g;
s|%KEYSTONE_AUTH_URI%|$KEYSTONE_AUTH_URI|g;
" -i $KIBANA_CFG_DIR/kibana.yml
if is_service_enabled monasca-log-api; then
sudo sed -e "s|%KIBANA_LOGS_ENABLE%|True|g;" -i $KIBANA_CFG_DIR/kibana.yml
else
sudo sed -e "s|%KIBANA_LOGS_ENABLE%|False|g;" -i $KIBANA_CFG_DIR/kibana.yml
fi
ln -sf $KIBANA_CFG_DIR/kibana.yml $GATE_CONFIGURATION_DIR/kibana.yml
fi
}

$_XTRACE_KIBANA

+ 32
- 0
devstack/lib/monasca-ui.sh View File

@@ -0,0 +1,32 @@
#!/bin/bash

# Copyright 2018 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


_XTRACE_MONASCA_UI=$(set +o | grep xtrace)
set +o xtrace

function configure_monasca-ui {
if is_service_enabled horizon && is_service_enabled kibana; then
local localSettings=${DEST}/horizon/monitoring/config/local_settings.py
sudo sed -e "
s|'ENABLE_EVENT_MANAGEMENT_BUTTON', False|'ENABLE_EVENT_MANAGEMENT_BUTTON', True|g;
" -i ${localSettings}
restart_apache_server
fi
}


$_XTRACE_MONASCA_UI

+ 0
- 9
devstack/lib/utils.sh View File

@@ -18,14 +18,6 @@
_XTRACE_UTILS=$(set +o | grep xtrace)
set +o xtrace

function find_nearest_apache_mirror {
if [ -z $APACHE_MIRROR ]; then
local mirror;
mirror=`curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq --raw-output '.preferred'`
APACHE_MIRROR=$mirror
fi
}

# download_file
# $1 - url to download
# $2 - location where to save url to
@@ -69,7 +61,6 @@ function configure_log_dir {

sudo mkdir -p $logdir
sudo chmod -R 0777 $logdir

}

$_XTRACE_UTILS

+ 0
- 67
devstack/lib/zookeeper.sh View File

@@ -1,67 +0,0 @@
#!/bin/bash

# Copyright 2017 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

_XTRACE_ZOOKEEPER=$(set +o | grep xtrace)
set +o xtrace

# Set up default directories
ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper
ZOOKEEPER_CONF_DIR=/etc/zookeeper

function is_zookeeper_enabled {
is_service_enabled monasca-zookeeper && return 0
return 1
}

function install_zookeeper {
if is_zookeeper_enabled; then
if is_ubuntu; then
install_package zookeeperd
else
die $LINENO "Don't know how to install zookeeper on this platform"
fi
fi
}

function configure_zookeeper {
if is_zookeeper_enabled; then
sudo cp $MONASCA_EVENTS_API_DIR/devstack/files/zookeeper/* $ZOOKEEPER_CONF_DIR
sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg
sudo rm -rf $ZOOKEEPER_DATA_DIR || true
sudo mkdir -p $ZOOKEEPER_DATA_DIR || true
fi
}

function start_zookeeper {
if is_zookeeper_enabled; then
start_service zookeeper
fi
}

function stop_zookeeper {
if is_zookeeper_enabled; then
stop_service zookeeper
fi
}

function clean_zookeeper {
if is_zookeeper_enabled; then
sudo rm -rf $ZOOKEEPER_DATA_DIR
apt_get -y purge zookeeper
fi
}

$_XTRACE_ZOOKEEPER

+ 29
- 35
devstack/plugin.sh View File

@@ -24,21 +24,17 @@ set -o errexit

# source lib/*
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/utils.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/zookeeper.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/kafka.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/elasticsearch.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-persister.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-api.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-agent.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/kibana.sh
source ${MONASCA_EVENTS_API_DIR}/devstack/lib/monasca-ui.sh

function pre_install_monasca_events {
echo_summary "Pre-Installing Monasca Events Dependency Components"
PLUGIN_FILES=$MONASCA_LOG_API_DIR/devstack/files

find_nearest_apache_mirror
install_zookeeper
install_kafka
install_elasticsearch
}
MONASCA_EVENT_API_URI=${MONASCA_EVENTS_API_SERVICE_PROTOCOL}://${MONASCA_EVENTS_API_SERVICE_HOST}/events

function install_monasca_events {
echo_summary "Installing Core Monasca Events Components"
@@ -48,26 +44,36 @@ function install_monasca_events {
}

function configure_monasca_events {
echo_summary "Configuring Monasca Events Dependency Components"
configure_zookeeper
configure_kafka
configure_elasticsearch

echo_summary "Configuring Monasca Events Core Components"

configure_log_dir ${MONASCA_EVENTS_LOG_DIR}
configure_events_persister
configure_events_api
configure_events_agent
}

function init_monasca_events {
echo_summary "Initializing Monasca Events Components"
start_zookeeper
start_kafka
start_elasticsearch
# wait for all services to start
sleep 10s
configure_elasticsearch
configure_kibana
echo_summary "Creating events topic"
create_kafka_topic monevents
configure_monasca-ui

echo_summary "Creating events service and endpoint"
get_or_create_service "events" "events" "Monasca Events service"
get_or_create_endpoint \
"events" \
"${REGION_NAME}" \
"${MONASCA_EVENT_API_URI}" \
"${MONASCA_EVENT_API_URI}" \
"${MONASCA_EVENT_API_URI}"

local events_search_url="http://$KIBANA_SERVICE_HOST:$KIBANA_SERVICE_PORT/"
get_or_create_service "events-search" "events-search" "Monasca Events search service"
get_or_create_endpoint \
"events-search" \
"$REGION_NAME" \
"$events_search_url" \
"$events_search_url" \
"$events_search_url"

}

function start_monasca_events {
@@ -82,9 +88,6 @@ function unstack_monasca_events {
stop_events_agent
stop_events_api
stop_events_persister
stop_elasticsearch
stop_kafka
stop_zookeeper
}

function clean_monasca_events {
@@ -92,20 +95,12 @@ function clean_monasca_events {
clean_events_agent
clean_events_api
clean_events_persister
clean_elasticsearch
clean_kafka
clean_zookeeper
}

# check for service enabled
if is_service_enabled monasca-events; then

if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
# Set up system services
echo_summary "Configuring Monasca Events system services"
pre_install_monasca_events

elif [[ "$1" == "stack" && "$2" == "install" ]]; then
if [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of service source
echo_summary "Installing Monasca Events"
install_monasca_events
@@ -118,7 +113,6 @@ if is_service_enabled monasca-events; then
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the Monasca service
echo_summary "Initializing Monasca Events"
init_monasca_events
start_monasca_events
fi



+ 1
- 0
devstack/settings View File

@@ -78,6 +78,7 @@ MONASCA_EVENTS_API_CACHE_DIR=${MONASCA_EVENTS_API_CACHE_DIR:-/var/cache/monasca-
MONASCA_EVENTS_API_SERVICE_HOST=${MONASCA_EVENTS_API_SERVICE_HOST:-${SERVICE_HOST}}
MONASCA_EVENTS_API_SERVICE_PORT=${MONASCA_EVENTS_API_SERVICE_PORT:-5656}
MONASCA_EVENTS_API_SERVICE_PROTOCOL=${MONASCA_EVENTS_API_SERVICE_PROTOCOL:-${SERVICE_PROTOCOL}}
MONASCA_EVENTS_API_UWSGI_CONF=${MONASCA_EVENTS_API_UWSGI_CONF:-$MONASCA_EVENTS_API_CONF_DIR/events-api-uwsgi.ini}

MONASCA_EVENTS_PERSISTER_CONF_DIR=${MONASCA_EVENTS_PERSISTER_CONF_DIR:-/etc/monasca}
MONASCA_EVENTS_PERSISTER_CONF=${MONASCA_EVENTS_PERSISTER_CONF:-${MONASCA_EVENTS_PERSISTER_CONF_DIR}/events-persister.conf}


+ 25
- 0
etc/monasca/events-api-uwsgi.ini View File

@@ -0,0 +1,25 @@
[uwsgi]
wsgi-file = /usr/local/bin/monasca-events-api-wsgi

# Versions of mod_proxy_uwsgi>=2.0.6 should use a UNIX socket, see
# http://uwsgi-docs.readthedocs.org/en/latest/Apache.html#mod-proxy-uwsgi
uwsgi-socket = 127.0.0.1:5607

# Override the default size for headers from the 4k default.
buffer-size = 65535

# This is running standalone
master = true

enable-threads = true

# Tune this to your environment.
processes = 4

# uwsgi recommends this to prevent thundering herd on accept.
thunder-lock = true

plugins = python

# This ensures that file descriptors aren't shared between keystone processes.
lazy-apps = true

+ 11
- 3
monasca_events_api/app/wsgi.py View File

@@ -18,6 +18,14 @@ Use this file for deploying the API under mod_wsgi.

from paste import deploy

base_dir = '/etc/monasca/'
conf = '{0}event-api-paste.ini'.format(base_dir)
application = deploy.loadapp('config:{0}'.format(conf))
application = None


def main():
base_dir = '/etc/monasca/'
conf = '{0}events-api-paste.ini'.format(base_dir)
app = deploy.loadapp('config:{0}'.format(conf))
return app

if __name__ == '__main__' or __name__.startswith('_mod_wsgi'):
application = main()

+ 3
- 3
setup.cfg View File

@@ -31,9 +31,6 @@ data_files =
etc/monasca/events-api-paste.ini
etc/monasca/events-api-logging.conf

wsgi_scripts =
monasca-events-api-wsgi = monasca_events_api.app.wsgi:main

[entry_points]

oslo.config.opts =
@@ -42,6 +39,9 @@ oslo.config.opts =
oslo.policy.policies =
events.api = monasca_events_api.policies:list_rules

wsgi_scripts =
monasca-events-api-wsgi = monasca_events_api.app.wsgi:main

[build_sphinx]
all_files = 1
build-dir = doc/build


Loading…
Cancel
Save