Merge "Minor improvement to log statements"
[multicloud/k8s.git] / deployments / _functions.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright 2019 © Samsung Electronics Co., Ltd.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 function stop_all {
12     docker-compose kill
13     docker-compose down
14 }
15
16 function start_mongo {
17     docker-compose up -d mongo
18     export DATABASE_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aqf "name=mongo"))
19     export no_proxy=${no_proxy:-},${DATABASE_IP}
20     export NO_PROXY=${NO_PROXY:-},${DATABASE_IP}
21 }
22
23 function generate_k8sconfig {
24     local ovn_address
25     if [ -n "${OVN_CENTRAL_ADDRESS:-}" ]; then
26         ovn_address="\"ovn-central-address\": \"${OVN_CENTRAL_ADDRESS}\","
27     fi
28 cat << EOF > k8sconfig.json
29 {
30     "database-address": "${DATABASE_IP}",
31     "database-type": "mongo",
32     "plugin-dir": "plugins",
33     ${ovn_address}
34     "service-port": "9015"
35 }
36 EOF
37 }
38
39 function start_all {
40     docker-compose up -d
41 }