blob: 804603f2bd740c022fcd705666ef4b0fed96d774 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/bin/bash
2
3# $1 is the IP address of the buscontroller
4# $2 is the IP address of the DRPS
5# $3 is the IP address of the MRC
6# $4 is the protocol (defaults to http)
7
8PROTO=${4:-http}
9if [ "$PROTO" = "http" ]
10then
11 PORT=8080
12 CURLOPT="-v"
13 MRPORT=3904
14 DRPORT=8080
15else
16 PORT=8443
17 CURLOPT="-v -k"
18 MRPORT=3905
19 DRPORT=8443
20fi
21
22# INITIALIZE: dmaap object
23JSON=/tmp/$$.dmaap
24cat << EOF > $JSON
25{
26 "version": "1",
27 "topicNsRoot": "org.onap.dmaap",
28 "drProvUrl": "${PROTO}://dmaap-dr-prov:${DRPORT}",
29 "dmaapName": "onapCSIT",
30 "bridgeAdminTopic": "MM_AGENT_PROV"
31
32}
33EOF
34
35echo "Initializing /dmaap endpoint"
36curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dmaap
37
38
39
40# INITIALIZE: dcaeLocation object
41JSON=/tmp/$$.loc
42cat << EOF > $JSON
43{
44 "dcaeLocationName": "csit-sanfrancisco",
45 "dcaeLayer": "central-cloud",
46 "clli": "CSIT12345",
47 "zone": "zoneA"
48
49}
50EOF
51
52echo "Initializing /dcaeLocations endpoint"
53curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dcaeLocations
54
55
56# INITIALIZE: MR object in 1 site
57# since MR is currently deployed via docker-compose, its IP doesn't seem
58# to be routable from DBCL. Fortunately, the MR port is mapped from the docker bridge IP address.
59# Found this article for how to deterine the docker bridge IP so using it as a workaround.
60# https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container
61# Used the following snippet found buried in a comment to an answer and then modified for only 1 value.
62DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+' | head -1 )
63# Perhaps there is a better way...
64JSON=/tmp/$$.mrc
65cat << EOF > $JSON
66{
67 "dcaeLocationName": "csit-sanfrancisco",
68 "fqdn": "$DOCKER_HOST",
69 "topicProtocol" : "http",
70 "topicPort": "${MRPORT}"
71
72}
73EOF
74
75echo "Initializing /mr_clusters endpoint"
76curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/mr_clusters