804603f2bd740c022fcd705666ef4b0fed96d774
[integration/csit.git] / scripts / dmaap-buscontroller / dmaapbc-init.sh
1 #!/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
8 PROTO=${4:-http}
9 if [ "$PROTO" = "http" ]
10 then
11         PORT=8080
12         CURLOPT="-v"
13         MRPORT=3904
14         DRPORT=8080
15 else
16         PORT=8443
17         CURLOPT="-v -k"
18         MRPORT=3905
19         DRPORT=8443
20 fi
21
22 # INITIALIZE: dmaap object
23 JSON=/tmp/$$.dmaap
24 cat << 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 }
33 EOF
34
35 echo "Initializing /dmaap endpoint"
36 curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dmaap 
37
38
39
40 # INITIALIZE: dcaeLocation object
41 JSON=/tmp/$$.loc
42 cat << EOF > $JSON
43 {
44         "dcaeLocationName": "csit-sanfrancisco",
45         "dcaeLayer": "central-cloud",
46         "clli": "CSIT12345",
47         "zone": "zoneA"
48
49 }
50 EOF
51
52 echo "Initializing /dcaeLocations endpoint"
53 curl ${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.
62 DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+' | head -1 )
63 # Perhaps there is a better way...
64 JSON=/tmp/$$.mrc
65 cat << EOF > $JSON
66 {
67         "dcaeLocationName": "csit-sanfrancisco",
68         "fqdn": "$DOCKER_HOST",
69         "topicProtocol" : "http",
70         "topicPort": "${MRPORT}"
71
72 }
73 EOF
74
75 echo "Initializing /mr_clusters endpoint"
76 curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/mr_clusters