openstack-helm/monasca/templates/bin/_influxdb-init.sh.tpl
root fb16a11fef add monasca
- monasca-api
- monasca-thresh(storm based)
- monasca-notification
- monasca-persister
- monasca-agent(deployment&daemonset)
- influxdb init

Change-Id: I3ee56658a8ddcb95056f2893c4c5cce0ccc18804
2021-11-11 15:24:36 +01:00

54 lines
2.0 KiB
Smarty

#!/bin/bash
{{/*
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.
*/}}
set -ex
OPTIONS="-w "%{http_code}" --output /dev/stderr --silent -X POST -u ${INFLUXDB_USER}:${INFLUXDB_PASSWORD}"
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=CREATE DATABASE monasca")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=CREATE RETENTION POLICY persister_all ON monasca DURATION 90d REPLICATION 1 DEFAULT")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=CREATE USER \"${INFLUXDB_API_USER}\" WITH PASSWORD '${INFLUXDB_API_PASSWORD}'")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=GRANT ALL TO \"${INFLUXDB_API_USER}\"")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=CREATE USER \"${INFLUXDB_PERSISTER_USER}\" WITH PASSWORD '${INFLUXDB_PERSISTER_PASSWORD}'")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi
status_code=$(curl ${OPTIONS} ${INFLUXDB_URL}query --data-urlencode "q=GRANT ALL ON monasca TO \"${INFLUXDB_PERSISTER_USER}\"")
if [ $status_code -lt 200 ] || ([ $status_code -gt 299 ] && [ $status_code -ne 409 ])
then
exit 1
fi