blob: 6ae6447109741adcf7ecdc622baad381812162f6 [file] [log] [blame]
Lusheng Ji37534a52020-08-02 21:25:26 -04001#!/bin/bash
2################################################################################
3# Copyright (c) 2020 AT&T Intellectual Property. #
4# #
5# Licensed under the Apache License, Version 2.0 (the "License"); #
6# you may not use this file except in compliance with the License. #
7# You may obtain 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, #
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14# See the License for the specific language governing permissions and #
15# limitations under the License. #
16################################################################################
17
18#set -x
19
20acknowledge() {
21 if [ ! -z "$1" ]; then echo "$1"; fi
22 read -n 1 -p "Press any key to continue, or CTRL-C to abort" mainmenuinput
23 echo
24}
25
26
27echo "This script sets up the IP address references for RIC and SMO clusters."
28echo
29echo "Reading RIC cluster IP address from envirronment variable \$RIC_IP."
30if [ -z $(echo ${RIC_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then
31 read -p "Not found or not in right format. Enter the external IP address of the RIC cluster: " RIC_IP
32 echo
33else
34 echo " Got ${RIC_IP}"
35fi
36
37echo "Reading SMO cluster IP address from envirronment variable \$SMO_IP."
38if [ -z $(echo ${SMO_IP} | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}") ]; then
39 read -p "Not found or not in right format. Enter the external IP address of the SMO cluster: " SMO_IP
40 echo
41else
42 echo " Got ${SMO_IP}"
43fi
44
45echo
46echo "Ready to configure demo scripts and Helm charts using RIC cluster at ${RIC_IP} and SMO cluster at ${SMO_IP}."
47echo "If not correct, abort from this script, then export the correct values for the RIC_IP and SMO_IP environment variables."
48acknowledge
49
50export RIC_IP="$RIC_IP"
51export SMO_IP="$SMO_IP"
52
53# run fixes from git clone's root directory
54PREVDIR="$PWD"
55cd $(git rev-parse --show-toplevel)
56
57if [ ! "$(ls -A ./ric-dep)" ]; then
58 echo "ric-dep directory empty, running submodule command to fetch"
59 git submodule update --init --recursive
60 echo
61fi
62
63echo "Inject the RIC cluster IP address (${RIC_IP}) into NONRTRIC recipe..."
64#./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml:137:192.168.130.80
65sed -i -e 's/"baseUrl":"http:\/\/192.168.130.80:32080\/a1mediator"/"baseUrl":"http:\/\/'"${RIC_IP}"':32080\/a1mediator"/g' ./nonrtric/RECIPE_EXAMPLE/example_recipe.yaml
66
67
68echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RICAUX recipe..."
69#./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:ricip: "10.0.0.1"
70#./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml:40:auxip: "10.0.0.1"
71sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml
72sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-aux/RECIPE_EXAMPLE/example_recipe.yaml
73
74echo "Inject the RIC and SMO cluster IP addresses (${RIC_IP} and ${SMO_IP}) into RIC recipe..."
75#ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:39: ricip: "10.0.0.1"
76#ric-dep/RECIPE_EXAMPLE/example_recipe.yaml:40: auxip: "10.0.0.1"
77sed -i -e 's/ricip: "10.0.0.1"/ricip: "'"${RIC_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml
78sed -i -e 's/auxip: "10.0.0.1"/auxip: "'"${SMO_IP}"'"/g' ./ric-dep/RECIPE_EXAMPLE/example_recipe.yaml
79
80
81echo
82echo "Completed."
83cd "$PREVDIR"