"Fossies" - the Fresh Open Source Software Archive

Member "monasca-events-api-2.0.0/devstack/plugin.sh" (14 Oct 2020, 4206 Bytes) of package /linux/misc/openstack/monasca-events-api-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "plugin.sh": 0.2.0_vs_0.3.0.

    1 #!/bin/bash
    2 
    3 #
    4 # Copyright 2017 FUJITSU LIMITED
    5 #
    6 # Licensed under the Apache License, Version 2.0 (the "License");
    7 # you may not use this file except in compliance with the License.
    8 # You may obtain a copy of the License at
    9 #
   10 #    http://www.apache.org/licenses/LICENSE-2.0
   11 #
   12 # Unless required by applicable law or agreed to in writing, software
   13 # distributed under the License is distributed on an "AS IS" BASIS,
   14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
   15 # implied.
   16 # See the License for the specific language governing permissions and
   17 # limitations under the License.
   18 
   19 # Save trace setting
   20 _EVENTS_XTRACE=$(set +o | grep xtrace)
   21 set -o xtrace
   22 _EVENTS_ERREXIT=$(set +o | grep errexit)
   23 set -o errexit
   24 
   25 # source lib/*
   26 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/utils.sh
   27 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/kafka.sh
   28 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/elasticsearch.sh
   29 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-persister.sh
   30 source ${MONASCA_EVENTS_API_DIR}/devstack/lib/events-api.sh
   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
   34 
   35 PLUGIN_FILES=$MONASCA_LOG_API_DIR/devstack/files
   36 
   37 MONASCA_EVENT_API_URI=${MONASCA_EVENTS_API_SERVICE_PROTOCOL}://${MONASCA_EVENTS_API_SERVICE_HOST}/events
   38 
   39 function install_monasca_events {
   40     echo_summary "Installing Core Monasca Events Components"
   41     install_events_persister
   42     install_events_api
   43     install_events_agent
   44 }
   45 
   46 function configure_monasca_events {
   47     echo_summary "Configuring Monasca Events Core Components"
   48 
   49     configure_log_dir ${MONASCA_EVENTS_LOG_DIR}
   50     configure_events_persister
   51     configure_events_api
   52     configure_events_agent
   53     configure_elasticsearch
   54     configure_kibana
   55     echo_summary "Creating events topic"
   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 
   77 }
   78 
   79 function start_monasca_events {
   80     echo_summary "Starting Monasca Events Components"
   81     start_events_persister
   82     start_events_api
   83     start_events_agent
   84 }
   85 
   86 function unstack_monasca_events {
   87     echo_summary "Unstacking Monasca Events Components"
   88     stop_events_agent
   89     stop_events_api
   90     stop_events_persister
   91 }
   92 
   93 function clean_monasca_events {
   94     echo_summary "Cleaning Monasca Events Components"
   95     clean_events_agent
   96     clean_events_api
   97     clean_events_persister
   98 }
   99 
  100 # check for service enabled
  101 if is_service_enabled monasca-events; then
  102 
  103     if [[ "$1" == "stack" && "$2" == "install" ]]; then
  104         # Perform installation of service source
  105         echo_summary "Installing Monasca Events"
  106         install_monasca_events
  107 
  108     elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
  109         # Configure after the other layer 1 and 2 services have been configured
  110         echo_summary "Configuring Monasca Events"
  111         configure_monasca_events
  112 
  113     elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
  114         # Initialize and start the Monasca service
  115         echo_summary "Initializing Monasca Events"
  116         start_monasca_events
  117     fi
  118 
  119     if [[ "$1" == "unstack" ]]; then
  120         # Shut down Monasca services
  121         echo_summary "Unstacking Monasca Events"
  122         unstack_monasca_events
  123     fi
  124 
  125     if [[ "$1" == "clean" ]]; then
  126         # Remove state and transient data
  127         # Remember clean.sh first calls unstack.sh
  128         echo_summary "Cleaning Monasca Events"
  129         clean_monasca_events
  130     fi
  131 fi
  132 
  133 # Restore errexit & xtrace
  134 ${_EVENTS_ERREXIT}
  135 ${_EVENTS_XTRACE}