fuel-plugin-openstack-telem.../deployment_scripts/puppet/modules/telemetry/templates/create_db.sh.erb

35 lines
1.4 KiB
Plaintext

#!/bin/bash
# Copyright 2016 Mirantis, Inc.
#
# 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 -eux
# Create the database
curl -G "<%= @influxdb_url %>/query" \
--data-urlencode "u=<%= @admin_user %>" \
--data-urlencode "p=<%= @admin_password %>" \
--data-urlencode "q=CREATE DATABASE <%= @db_name %>"
# Give all privileges to user for the DB
curl -G "<%= @influxdb_url %>/query" \
--data-urlencode "u=<%= @admin_user %>" \
--data-urlencode "p=<%= @admin_password %>" \
--data-urlencode "q=GRANT ALL ON <%= @db_name %> TO <%= @db_user %>"
# Define the retentation policy
curl -G "<%= @influxdb_url %>/query" \
--data-urlencode "u=<%= @admin_user %>" \
--data-urlencode "p=<%= @admin_password %>" \
--data-urlencode "q=ALTER RETENTION POLICY default ON <%= @db_name %> DURATION <%= @real_retention_period %> REPLICATION <%= @replication_factor %>"