Browse Source

Merge "Refactor devstack-plugin"

Zuul 5 months ago
parent
commit
c40c777ae1

+ 1
- 0
.gitignore View File

@@ -15,6 +15,7 @@ ChangeLog
15 15
 MANIFEST
16 16
 monasca.log
17 17
 
18
+.vagrant
18 19
 *.log
19 20
 *.swp
20 21
 *.iml

+ 5
- 0
devstack/Vagrantfile View File

@@ -80,8 +80,13 @@ LOG_COLOR=False
80 80
 
81 81
 disable_all_services
82 82
 enable_service rabbit mysql key tempest horizon
83
+disable_service monasca-api monasca-thresh monasca-agent monasca-notification
84
+disable_service  monasca-log-persister monasca-log-agent monasca-log-metrics monasca-log-transformer monasca-log-api
83 85
 
86
+enable_plugin monasca-api https://git.openstack.org/openstack/monasca-api
87
+enable_plugin monasca-log-api https://git.openstack.org/openstack/monasca-log-api
84 88
 enable_plugin monasca-events-api https://git.openstack.org/openstack/monasca-events-api
89
+enable_plugin monasca-tempest-plugin https://git.openstack.org/openstack/monasca-tempest-plugin
85 90
 
86 91
 ' > local.conf
87 92
     ./stack.sh

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

@@ -0,0 +1,80 @@
1
+# Kibana is served by a back end server. This controls which port to use.
2
+server.port: %KIBANA_SERVICE_PORT%
3
+
4
+# The host to bind the server to.
5
+server.host: %KIBANA_SERVICE_HOST%
6
+
7
+# If you are running kibana behind a proxy, and want to mount it at a path,
8
+# specify that path here. The basePath can't end in a slash.
9
+server.basePath: /dashboard/monitoring/logs_proxy
10
+
11
+# The Elasticsearch instance to use for all your queries.
12
+elasticsearch.url: http://%ES_SERVICE_BIND_HOST%:%ES_SERVICE_BIND_PORT%
13
+
14
+# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
15
+# then the host you use to connect to *this* Kibana instance will be sent.
16
+elasticsearch.preserveHost: True
17
+
18
+# Kibana uses an index in Elasticsearch to store saved searches, visualizations
19
+# and dashboards. It will create a new index if it doesn't already exist.
20
+kibana.index: ".kibana"
21
+
22
+# The default application to load.
23
+kibana.defaultAppId: "discover"
24
+
25
+# If your Elasticsearch is protected with basic auth, these are the user credentials
26
+# used by the Kibana server to perform maintenance on the kibana_index at startup. Your Kibana
27
+# users will still need to authenticate with Elasticsearch (which is proxied through
28
+# the Kibana server)
29
+# elasticsearch.username: "user"
30
+# elasticsearch.password: "pass"
31
+
32
+# SSL for outgoing requests from the Kibana Server to the browser (PEM formatted)
33
+# server.ssl.cert: /path/to/your/server.crt
34
+# server.ssl.key: /path/to/your/server.key
35
+
36
+# Optional setting to validate that your Elasticsearch backend uses the same key files (PEM formatted)
37
+# elasticsearch.ssl.cert: /path/to/your/client.crt
38
+# elasticsearch.ssl.key: /path/to/your/client.key
39
+
40
+# If you need to provide a CA certificate for your Elasticsearch instance, put
41
+# the path of the pem file here.
42
+# elasticsearch.ssl.ca: /path/to/your/CA.pem
43
+
44
+# Set to false to have a complete disregard for the validity of the SSL
45
+# certificate.
46
+# elasticsearch.ssl.verify: true
47
+
48
+# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to
49
+# request_timeout setting
50
+elasticsearch.pingTimeout: 1500
51
+
52
+# Time in milliseconds to wait for responses from the back end or elasticsearch.
53
+# This must be > 0
54
+elasticsearch.requestTimeout: 300000
55
+
56
+# Time in milliseconds for Elasticsearch to wait for responses from shards.
57
+# Set to 0 to disable.
58
+elasticsearch.shardTimeout: 0
59
+
60
+# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying
61
+elasticsearch.startupTimeout: 5000
62
+
63
+# Set the path to where you would like the process id file to be created.
64
+# pid.file: /var/run/kibana.pid
65
+
66
+# Set this to true to suppress all logging output.
67
+logging.silent: false
68
+# Set this to true to suppress all logging output except for error messages.
69
+logging.quiet: false
70
+# Set this to true to log all events, including system usage information and all requests.
71
+logging.verbose: true
72
+
73
+# monasca-kibana-plugin configuration
74
+monasca-kibana-plugin.auth_uri: %KEYSTONE_AUTH_URI%
75
+monasca-kibana-plugin.enabled: True
76
+monasca-kibana-plugin.cookie.isSecure: False
77
+monasca-kibana-plugin.logs: %KIBANA_LOGS_ENABLE%
78
+monasca-kibana-plugin.events: True
79
+
80
+optimize.useBundleCache: False

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

@@ -1,6 +1,6 @@
1 1
 #!/bin/bash
2 2
 
3
-# Copyright 2017 FUJITSU LIMITED
3
+# Copyright 2018 FUJITSU LIMITED
4 4
 #
5 5
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 6
 # not use this file except in compliance with the License. You may obtain
@@ -14,7 +14,6 @@
14 14
 # License for the specific language governing permissions and limitations
15 15
 # under the License.
16 16
 
17
-
18 17
 _XTRACE_ELASTICSEARCH=$(set +o | grep xtrace)
19 18
 set +o xtrace
20 19
 
@@ -23,76 +22,16 @@ function is_elasticsearch_enabled {
23 22
     return 1
24 23
 }
25 24
 
26
-function install_elasticsearch {
27
-    if is_elasticsearch_enabled; then
28
-        echo_summary "Installing ElasticSearch ${ELASTICSEARCH_VERSION}"
29
-
30
-        local es_tarball=elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz
31
-        local es_url=http://download.elasticsearch.org/elasticsearch/elasticsearch/${es_tarball}
32
-        local es_dest=${FILES}/${es_tarball}
33
-
34
-        download_file ${es_url} ${es_dest}
35
-        tar xzf ${es_dest} -C $DEST
36
-
37
-        sudo chown -R $STACK_USER $DEST/elasticsearch-${ELASTICSEARCH_VERSION}
38
-        ln -sf $DEST/elasticsearch-${ELASTICSEARCH_VERSION} $ELASTICSEARCH_DIR
39
-    fi
40
-}
41
-
42 25
 function configure_elasticsearch {
43 26
     if is_elasticsearch_enabled; then
44
-        echo_summary "Configuring ElasticSearch ${ELASTICSEARCH_VERSION}"
45
-
46
-        local templateDir=$ELASTICSEARCH_CFG_DIR/templates
47
-
48
-        for dir in $ELASTICSEARCH_LOG_DIR $templateDir $ELASTICSEARCH_DATA_DIR; do
49
-            sudo install -m 755 -d -o $STACK_USER $dir
50
-        done
51
-
52
-        sudo cp -f "${PLUGIN_FILES}"/elasticsearch/elasticsearch.yml $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
53
-        sudo chown -R $STACK_USER $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
54
-        sudo chmod 0644 $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
55
-
56
-        sudo sed -e "
57
-            s|%ELASTICSEARCH_BIND_HOST%|$ELASTICSEARCH_BIND_HOST|g;
58
-            s|%ELASTICSEARCH_BIND_PORT%|$ELASTICSEARCH_BIND_PORT|g;
59
-            s|%ELASTICSEARCH_PUBLISH_HOST%|$ELASTICSEARCH_PUBLISH_HOST|g;
60
-            s|%ELASTICSEARCH_PUBLISH_PORT%|$ELASTICSEARCH_PUBLISH_PORT|g;
61
-            s|%ELASTICSEARCH_DATA_DIR%|$ELASTICSEARCH_DATA_DIR|g;
62
-            s|%ELASTICSEARCH_LOG_DIR%|$ELASTICSEARCH_LOG_DIR|g;
63
-        " -i $ELASTICSEARCH_CFG_DIR/elasticsearch.yml
64
-    fi
65
-}
66
-
67
-function start_elasticsearch {
68
-    if is_elasticsearch_enabled; then
69
-        echo_summary "Starting ElasticSearch ${ELASTICSEARCH_VERSION}"
70
-        # TODO(jwachowski) find some nicer solution for setting env variable
27
+        echo_summary "Configuring Elasticsearch for events handling"
71 28
         local service_file="/etc/systemd/system/devstack@elasticsearch.service"
29
+        # This property disable elasticsearch check for dots in filed name,
30
+        # Some event use dot in field name.
72 31
         local es_java_opts="ES_JAVA_OPTS=-Dmapper.allow_dots_in_name=true"
73 32
         iniset -sudo "$service_file" "Service" "Environment" "$es_java_opts"
74
-        run_process "elasticsearch" "$ELASTICSEARCH_DIR/bin/elasticsearch"
75
-    fi
76
-}
77
-
78
-function stop_elasticsearch {
79
-    if is_elasticsearch_enabled; then
80
-        echo_summary "Stopping ElasticSearch ${ELASTICSEARCH_VERSION}"
81
-        stop_process "elasticsearch" || true
82
-    fi
83
-}
84
-
85
-function clean_elasticsearch {
86
-    if is_elasticsearch_enabled; then
87
-        echo_summary "Cleaning Elasticsearch ${ELASTICSEARCH_VERSION}"
88
-
89
-        sudo rm -rf ELASTICSEARCH_DIR || true
90
-        sudo rm -rf ELASTICSEARCH_CFG_DIR || true
91
-        sudo rm -rf ELASTICSEARCH_LOG_DIR || true
92
-        sudo rm -rf ELASTICSEARCH_DATA_DIR || true
93
-        sudo rm -rf $FILES/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz || true
94
-        sudo rm -rf $DEST/elasticsearch-${ELASTICSEARCH_VERSION} || true
33
+        restart_process "elasticsearch" || true
95 34
     fi
96 35
 }
97 36
 
98
-$_XTRACE_ELASTICSEARCH
37
+$_XTRACE_ELASTICSEARCH

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

@@ -27,10 +27,17 @@ function install_events_api {
27 27
     if is_events_api_enabled; then
28 28
         echo_summary "Installing Events Api"
29 29
         git_clone $MONASCA_EVENTS_API_REPO $MONASCA_EVENTS_API_DIR $MONASCA_EVENTS_API_BRANCH
30
-        setup_develop ${MONASCA_EVENTS_API_DIR}
31
-
30
+        setup_develop $MONASCA_EVENTS_API_DIR
31
+        install_monasca_common
32 32
         install_keystonemiddleware
33
-        pip_install gunicorn
33
+        pip_install uwsgi
34
+    fi
35
+}
36
+
37
+function install_monasca_common {
38
+    if use_library_from_git "monasca-common"; then
39
+        git_clone_by_name "monasca-common"
40
+        setup_dev_lib "monasca-common"
34 41
     fi
35 42
 }
36 43
 
@@ -44,6 +51,7 @@ function configure_events_api {
44 51
 
45 52
         # Put config files in ``$MONASCA_EVENTS_API_CONF_DIR`` for everyone to find
46 53
         sudo install -d -o $STACK_USER $MONASCA_EVENTS_API_CONF_DIR
54
+        sudo install -d -o $STACK_USER $MONASCA_EVENTS_LOG_DIR
47 55
 
48 56
         create_monasca_events_cache_dir
49 57
 
@@ -67,17 +75,24 @@ function configure_events_api {
67 75
         iniset "$MONASCA_EVENTS_API_CONF" keystone_authtoken project_name "admin"
68 76
         iniset "$MONASCA_EVENTS_API_CONF" keystone_authtoken password $ADMIN_PASSWORD
69 77
 
70
-        # configure log-api-paste.ini
78
+        # configure events-api-paste.ini
71 79
         iniset "$MONASCA_EVENTS_API_PASTE" server:main bind $MONASCA_EVENTS_API_SERVICE_HOST:$MONASCA_EVENTS_API_SERVICE_PORT
72 80
         iniset "$MONASCA_EVENTS_API_PASTE" server:main chdir $MONASCA_EVENTS_API_DIR
73 81
         iniset "$MONASCA_EVENTS_API_PASTE" server:main workers $API_WORKERS
82
+
83
+        rm -rf $MONASCA_EVENTS_API_UWSGI_CONF
84
+        MONASCA_EVENTS_API_WSGI=/usr/local/bin/monasca-events-api-wsgi
85
+        install -m 600 $MONASCA_EVENTS_API_DIR/etc/monasca/events-api-uwsgi.ini $MONASCA_EVENTS_API_UWSGI_CONF
86
+        write_uwsgi_config "$MONASCA_EVENTS_API_UWSGI_CONF" "$MONASCA_EVENTS_API_WSGI" "/events"
87
+
74 88
     fi
75 89
 }
76 90
 
91
+
77 92
 function start_events_api {
78 93
     if is_events_api_enabled; then
79 94
         echo_summary "Starting Events Api"
80
-        run_process "monasca-events-api" "/usr/local/bin/gunicorn --paste $MONASCA_EVENTS_API_PASTE"
95
+        run_process "monasca-events-api" "/usr/local/bin/uwsgi --ini $MONASCA_EVENTS_API_UWSGI_CONF"
81 96
     fi
82 97
 }
83 98
 

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

@@ -25,9 +25,7 @@ function is_events_persister_enabled {
25 25
 
26 26
 function install_events_persister {
27 27
     if is_events_persister_enabled; then
28
-        echo_summary "Installing Events Persister"
29
-        git_clone $MONASCA_EVENTS_PERSISTER_REPO $MONASCA_EVENTS_PERSISTER_DIR $MONASCA_EVENTS_PERSISTER_BRANCH
30
-        setup_develop ${MONASCA_EVENTS_PERSISTER_DIR}
28
+        echo_summary "Installing Events Persister dependencies"
31 29
         pip_install "elasticsearch>=2.0.0,<3.0.0"
32 30
     fi
33 31
 }
@@ -50,6 +48,7 @@ function configure_events_persister {
50 48
         iniset "$MONASCA_EVENTS_PERSISTER_CONF" zookeeper partition_interval_recheck_seconds 15
51 49
         iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka num_processors 0
52 50
         iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events num_processors 1
51
+        iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events enabled True
53 52
         iniset "$MONASCA_EVENTS_PERSISTER_CONF" kafka_events uri 127.0.0.1:9092
54 53
         iniset "$MONASCA_EVENTS_PERSISTER_CONF" elasticsearch hosts ${ELASTICSEARCH_BIND_HOST}:${ELASTICSEARCH_BIND_PORT}
55 54
 

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

@@ -23,72 +23,6 @@ function is_kafka_enabled {
23 23
     return 1
24 24
 }
25 25
 
26
-function install_kafka {
27
-    if is_kafka_enabled; then
28
-        echo_summary "Installing kafka"
29
-
30
-        local kafka_tarball=kafka_${KAFKA_VERSION}.tgz
31
-        local kafka_tarball_url=${APACHE_ARCHIVES}kafka/${BASE_KAFKA_VERSION}/${kafka_tarball}
32
-        local kafka_tarball_dest=${FILES}/${kafka_tarball}
33
-
34
-        download_file ${kafka_tarball_url} ${kafka_tarball_dest}
35
-
36
-        sudo groupadd --system kafka || true
37
-        sudo useradd --system -g kafka kafka || true
38
-        sudo tar -xzf ${kafka_tarball_dest} -C /opt
39
-        sudo ln -sf /opt/kafka_${KAFKA_VERSION} /opt/kafka
40
-        sudo cp -f "${MONASCA_EVENTS_API_DIR}"/devstack/files/kafka/kafka-server-start.sh /opt/kafka_${KAFKA_VERSION}/bin/kafka-server-start.sh
41
-    fi
42
-}
43
-
44
-function configure_kafka {
45
-    if is_kafka_enabled; then
46
-        echo_summary "Configuring kafka"
47
-        sudo mkdir -p /var/kafka || true
48
-        sudo chown kafka:kafka /var/kafka
49
-        sudo chmod 755 /var/kafka
50
-        sudo rm -rf /var/kafka/lost+found
51
-        sudo mkdir -p /var/log/kafka || true
52
-        sudo chown kafka:kafka /var/log/kafka
53
-        sudo chmod 755 /var/log/kafka
54
-        sudo ln -sf /opt/kafka/config /etc/kafka
55
-        sudo ln -sf /var/log/kafka /opt/kafka/logs
56
-
57
-        sudo cp -f "${MONASCA_EVENTS_DEVSTACK_DIR}"/files/kafka/log4j.properties /etc/kafka/log4j.properties
58
-        sudo cp -f "${MONASCA_EVENTS_DEVSTACK_DIR}"/files/kafka/server.properties /etc/kafka/server.properties
59
-        sudo chown kafka:kafka /etc/kafka/*
60
-        sudo chmod 644 /etc/kafka/*
61
-    fi
62
-}
63
-
64
-function start_kafka {
65
-    if is_kafka_enabled; then
66
-        echo_summary "Starting Monasca Kafka"
67
-        run_process "kafka" "/opt/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties" "kafka" "kafka"
68
-    fi
69
-}
70
-
71
-function stop_kafka {
72
-    if is_kafka_enabled; then
73
-        echo_summary "Stopping Monasca Kafka"
74
-        stop_process "kafka" || true
75
-    fi
76
-}
77
-
78
-function clean_kafka {
79
-    if is_kafka_enabled; then
80
-        echo_summary "Clean Monasca Kafka"
81
-        sudo rm -rf /var/kafka
82
-        sudo rm -rf /var/log/kafka
83
-        sudo rm -rf /etc/kafka
84
-        sudo rm -rf /opt/kafka
85
-        sudo userdel kafka || true
86
-        sudo groupdel kafka || true
87
-        sudo rm -rf /opt/kafka_${KAFKA_VERSION}
88
-        sudo rm -rf ${FILES}/kafka_${KAFKA_VERSION}.tgz
89
-    fi
90
-}
91
-
92 26
 function create_kafka_topic {
93 27
     if is_kafka_enabled; then
94 28
         /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 @@
1
+#!/bin/bash
2
+
3
+# Copyright 2018 FUJITSU LIMITED
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#      http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+_XTRACE_KIBANA=$(set +o | grep xtrace)
19
+set +o xtrace
20
+
21
+function configure_kibana {
22
+    if is_service_enabled kibana; then
23
+        echo_summary "Configuring Kibana"
24
+
25
+        sudo install -m 755 -d -o $STACK_USER $KIBANA_CFG_DIR
26
+
27
+        sudo cp -f "${MONASCA_EVENTS_API_DIR}"/devstack/files/kibana/kibana.yml $KIBANA_CFG_DIR/kibana.yml
28
+        sudo chown -R $STACK_USER $KIBANA_CFG_DIR/kibana.yml
29
+        sudo chmod 0644 $KIBANA_CFG_DIR/kibana.yml
30
+
31
+        sudo sed -e "
32
+            s|%KIBANA_SERVICE_HOST%|$KIBANA_SERVICE_HOST|g;
33
+            s|%KIBANA_SERVICE_PORT%|$KIBANA_SERVICE_PORT|g;
34
+            s|%KIBANA_SERVER_BASE_PATH%|$KIBANA_SERVER_BASE_PATH|g;
35
+            s|%ES_SERVICE_BIND_HOST%|$ES_SERVICE_BIND_HOST|g;
36
+            s|%ES_SERVICE_BIND_PORT%|$ES_SERVICE_BIND_PORT|g;
37
+            s|%KEYSTONE_AUTH_URI%|$KEYSTONE_AUTH_URI|g;
38
+        " -i $KIBANA_CFG_DIR/kibana.yml
39
+        if is_service_enabled monasca-log-api; then
40
+            sudo sed -e "s|%KIBANA_LOGS_ENABLE%|True|g;" -i $KIBANA_CFG_DIR/kibana.yml
41
+        else
42
+            sudo sed -e "s|%KIBANA_LOGS_ENABLE%|False|g;" -i $KIBANA_CFG_DIR/kibana.yml
43
+        fi
44
+        ln -sf $KIBANA_CFG_DIR/kibana.yml $GATE_CONFIGURATION_DIR/kibana.yml
45
+    fi
46
+}
47
+
48
+$_XTRACE_KIBANA

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

@@ -0,0 +1,32 @@
1
+#!/bin/bash
2
+
3
+# Copyright 2018 FUJITSU LIMITED
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#      http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+_XTRACE_MONASCA_UI=$(set +o | grep xtrace)
19
+set +o xtrace
20
+
21
+function configure_monasca-ui {
22
+    if is_service_enabled horizon && is_service_enabled kibana; then
23
+        local localSettings=${DEST}/horizon/monitoring/config/local_settings.py
24
+        sudo sed -e "
25
+            s|'ENABLE_EVENT_MANAGEMENT_BUTTON', False|'ENABLE_EVENT_MANAGEMENT_BUTTON', True|g;
26
+        " -i ${localSettings}
27
+        restart_apache_server
28
+    fi
29
+}
30
+
31
+
32
+$_XTRACE_MONASCA_UI

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

@@ -18,14 +18,6 @@
18 18
 _XTRACE_UTILS=$(set +o | grep xtrace)
19 19
 set +o xtrace
20 20
 
21
-function find_nearest_apache_mirror {
22
-    if [ -z $APACHE_MIRROR ]; then
23
-        local mirror;
24
-        mirror=`curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq --raw-output '.preferred'`
25
-        APACHE_MIRROR=$mirror
26
-    fi
27
-}
28
-
29 21
 # download_file
30 22
 #  $1 - url to download
31 23
 #  $2 - location where to save url to
@@ -69,7 +61,6 @@ function configure_log_dir {
69 61
 
70 62
     sudo mkdir -p $logdir
71 63
     sudo chmod -R 0777 $logdir
72
-
73 64
 }
74 65
 
75 66
 $_XTRACE_UTILS

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

@@ -1,67 +0,0 @@
1
-#!/bin/bash
2
-
3
-# Copyright 2017 FUJITSU LIMITED
4
-#
5
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-# not use this file except in compliance with the License. You may obtain
7
-# a copy of the License at
8
-#
9
-#      http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-# Unless required by applicable law or agreed to in writing, software
12
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-# License for the specific language governing permissions and limitations
15
-# under the License.
16
-
17
-_XTRACE_ZOOKEEPER=$(set +o | grep xtrace)
18
-set +o xtrace
19
-
20
-# Set up default directories
21
-ZOOKEEPER_DATA_DIR=$DEST/data/zookeeper
22
-ZOOKEEPER_CONF_DIR=/etc/zookeeper
23
-
24
-function is_zookeeper_enabled {
25
-    is_service_enabled monasca-zookeeper && return 0
26
-    return 1
27
-}
28
-
29
-function install_zookeeper {
30
-    if is_zookeeper_enabled; then
31
-        if is_ubuntu; then
32
-            install_package zookeeperd
33
-        else
34
-            die $LINENO "Don't know how to install zookeeper on this platform"
35
-        fi
36
-    fi
37
-}
38
-
39
-function configure_zookeeper {
40
-    if is_zookeeper_enabled; then
41
-        sudo cp $MONASCA_EVENTS_API_DIR/devstack/files/zookeeper/* $ZOOKEEPER_CONF_DIR
42
-        sudo sed -i -e 's|.*dataDir.*|dataDir='$ZOOKEEPER_DATA_DIR'|' $ZOOKEEPER_CONF_DIR/zoo.cfg
43
-        sudo rm -rf $ZOOKEEPER_DATA_DIR || true
44
-        sudo mkdir -p $ZOOKEEPER_DATA_DIR || true
45
-    fi
46
-}
47
-
48
-function start_zookeeper {
49
-    if is_zookeeper_enabled; then
50
-        start_service zookeeper
51
-    fi
52
-}
53
-
54
-function stop_zookeeper {
55
-    if is_zookeeper_enabled; then
56
-        stop_service zookeeper
57
-    fi
58
-}
59
-
60
-function clean_zookeeper {
61
-    if is_zookeeper_enabled; then
62
-        sudo rm -rf $ZOOKEEPER_DATA_DIR
63
-        apt_get -y purge zookeeper
64
-    fi
65
-}
66
-
67
-$_XTRACE_ZOOKEEPER

+ 29
- 35
devstack/plugin.sh View File

@@ -24,21 +24,17 @@ set -o errexit
24 24
 
25 25
 # source lib/*
26 26
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/utils.sh
27
-source ${MONASCA_EVENTS_API_DIR}/devstack/lib/zookeeper.sh
28 27
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/kafka.sh
29 28
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/elasticsearch.sh
30 29
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-persister.sh
31 30
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-api.sh
32 31
 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-agent.sh
32
+source ${MONASCA_EVENTS_API_DIR}/devstack/lib/kibana.sh
33
+source ${MONASCA_EVENTS_API_DIR}/devstack/lib/monasca-ui.sh
33 34
 
34
-function pre_install_monasca_events {
35
-    echo_summary "Pre-Installing Monasca Events Dependency Components"
35
+PLUGIN_FILES=$MONASCA_LOG_API_DIR/devstack/files
36 36
 
37
-    find_nearest_apache_mirror
38
-    install_zookeeper
39
-    install_kafka
40
-    install_elasticsearch
41
-}
37
+MONASCA_EVENT_API_URI=${MONASCA_EVENTS_API_SERVICE_PROTOCOL}://${MONASCA_EVENTS_API_SERVICE_HOST}/events
42 38
 
43 39
 function install_monasca_events {
44 40
     echo_summary "Installing Core Monasca Events Components"
@@ -48,26 +44,36 @@ function install_monasca_events {
48 44
 }
49 45
 
50 46
 function configure_monasca_events {
51
-    echo_summary "Configuring Monasca Events Dependency Components"
52
-    configure_zookeeper
53
-    configure_kafka
54
-    configure_elasticsearch
55
-
56 47
     echo_summary "Configuring Monasca Events Core Components"
48
+
57 49
     configure_log_dir ${MONASCA_EVENTS_LOG_DIR}
58 50
     configure_events_persister
59 51
     configure_events_api
60 52
     configure_events_agent
61
-}
62
-
63
-function init_monasca_events {
64
-    echo_summary "Initializing Monasca Events Components"
65
-    start_zookeeper
66
-    start_kafka
67
-    start_elasticsearch
68
-    # wait for all services to start
69
-    sleep 10s
53
+    configure_elasticsearch
54
+    configure_kibana
55
+    echo_summary "Creating events topic"
70 56
     create_kafka_topic monevents
57
+    configure_monasca-ui
58
+
59
+    echo_summary "Creating events service and endpoint"
60
+    get_or_create_service "events" "events" "Monasca Events service"
61
+    get_or_create_endpoint \
62
+            "events" \
63
+            "${REGION_NAME}" \
64
+            "${MONASCA_EVENT_API_URI}" \
65
+            "${MONASCA_EVENT_API_URI}" \
66
+            "${MONASCA_EVENT_API_URI}"
67
+
68
+    local events_search_url="http://$KIBANA_SERVICE_HOST:$KIBANA_SERVICE_PORT/"
69
+    get_or_create_service "events-search" "events-search" "Monasca Events search service"
70
+    get_or_create_endpoint \
71
+        "events-search" \
72
+        "$REGION_NAME" \
73
+        "$events_search_url" \
74
+        "$events_search_url" \
75
+        "$events_search_url"
76
+
71 77
 }
72 78
 
73 79
 function start_monasca_events {
@@ -82,9 +88,6 @@ function unstack_monasca_events {
82 88
     stop_events_agent
83 89
     stop_events_api
84 90
     stop_events_persister
85
-    stop_elasticsearch
86
-    stop_kafka
87
-    stop_zookeeper
88 91
 }
89 92
 
90 93
 function clean_monasca_events {
@@ -92,20 +95,12 @@ function clean_monasca_events {
92 95
     clean_events_agent
93 96
     clean_events_api
94 97
     clean_events_persister
95
-    clean_elasticsearch
96
-    clean_kafka
97
-    clean_zookeeper
98 98
 }
99 99
 
100 100
 # check for service enabled
101 101
 if is_service_enabled monasca-events; then
102 102
 
103
-    if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
104
-        # Set up system services
105
-        echo_summary "Configuring Monasca Events system services"
106
-        pre_install_monasca_events
107
-
108
-    elif [[ "$1" == "stack" && "$2" == "install" ]]; then
103
+    if [[ "$1" == "stack" && "$2" == "install" ]]; then
109 104
         # Perform installation of service source
110 105
         echo_summary "Installing Monasca Events"
111 106
         install_monasca_events
@@ -118,7 +113,6 @@ if is_service_enabled monasca-events; then
118 113
     elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
119 114
         # Initialize and start the Monasca service
120 115
         echo_summary "Initializing Monasca Events"
121
-        init_monasca_events
122 116
         start_monasca_events
123 117
     fi
124 118
 

+ 1
- 0
devstack/settings View File

@@ -78,6 +78,7 @@ MONASCA_EVENTS_API_CACHE_DIR=${MONASCA_EVENTS_API_CACHE_DIR:-/var/cache/monasca-
78 78
 MONASCA_EVENTS_API_SERVICE_HOST=${MONASCA_EVENTS_API_SERVICE_HOST:-${SERVICE_HOST}}
79 79
 MONASCA_EVENTS_API_SERVICE_PORT=${MONASCA_EVENTS_API_SERVICE_PORT:-5656}
80 80
 MONASCA_EVENTS_API_SERVICE_PROTOCOL=${MONASCA_EVENTS_API_SERVICE_PROTOCOL:-${SERVICE_PROTOCOL}}
81
+MONASCA_EVENTS_API_UWSGI_CONF=${MONASCA_EVENTS_API_UWSGI_CONF:-$MONASCA_EVENTS_API_CONF_DIR/events-api-uwsgi.ini}
81 82
 
82 83
 MONASCA_EVENTS_PERSISTER_CONF_DIR=${MONASCA_EVENTS_PERSISTER_CONF_DIR:-/etc/monasca}
83 84
 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 @@
1
+[uwsgi]
2
+wsgi-file = /usr/local/bin/monasca-events-api-wsgi
3
+
4
+# Versions of mod_proxy_uwsgi>=2.0.6 should use a UNIX socket, see
5
+# http://uwsgi-docs.readthedocs.org/en/latest/Apache.html#mod-proxy-uwsgi
6
+uwsgi-socket = 127.0.0.1:5607
7
+
8
+# Override the default size for headers from the 4k default.
9
+buffer-size = 65535
10
+
11
+# This is running standalone
12
+master = true
13
+
14
+enable-threads = true
15
+
16
+# Tune this to your environment.
17
+processes = 4
18
+
19
+# uwsgi recommends this to prevent thundering herd on accept.
20
+thunder-lock = true
21
+
22
+plugins = python
23
+
24
+# This ensures that file descriptors aren't shared between keystone processes.
25
+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.
18 18
 
19 19
 from paste import deploy
20 20
 
21
-base_dir = '/etc/monasca/'
22
-conf = '{0}event-api-paste.ini'.format(base_dir)
23
-application = deploy.loadapp('config:{0}'.format(conf))
21
+application = None
22
+
23
+
24
+def main():
25
+    base_dir = '/etc/monasca/'
26
+    conf = '{0}events-api-paste.ini'.format(base_dir)
27
+    app = deploy.loadapp('config:{0}'.format(conf))
28
+    return app
29
+
30
+if __name__ == '__main__' or __name__.startswith('_mod_wsgi'):
31
+    application = main()

+ 3
- 3
setup.cfg View File

@@ -31,9 +31,6 @@ data_files =
31 31
         etc/monasca/events-api-paste.ini
32 32
         etc/monasca/events-api-logging.conf
33 33
 
34
-wsgi_scripts =
35
-    monasca-events-api-wsgi = monasca_events_api.app.wsgi:main
36
-
37 34
 [entry_points]
38 35
 
39 36
 oslo.config.opts =
@@ -42,6 +39,9 @@ oslo.config.opts =
42 39
 oslo.policy.policies =
43 40
     events.api = monasca_events_api.policies:list_rules
44 41
 
42
+wsgi_scripts =
43
+    monasca-events-api-wsgi = monasca_events_api.app.wsgi:main
44
+
45 45
 [build_sphinx]
46 46
 all_files = 1
47 47
 build-dir = doc/build

Loading…
Cancel
Save