[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / csit / scripts / dmaap-buscontroller / dmaapbc-init.sh
1 #!/bin/bash
2
3 # $1 is the IP address of the buscontroller
4
5 # INITIALIZE: dmaap object
6 JSON=/tmp/$$.dmaap
7 cat << EOF > $JSON
8 {
9     "version": "1",
10     "topicNsRoot": "org.onap.dmaap",
11     "drProvUrl": "https://dmaap-dr-prov:8443",
12     "dmaapName": "onapCSIT",
13     "bridgeAdminTopic": "MM_AGENT_PROV"
14
15 }
16 EOF
17
18 echo "Initializing /dmaap endpoint"
19 curl -v -k  -X POST -d @${JSON} -H "Content-Type: application/json" https://$1:8443/webapi/dmaap
20
21
22 # INITIALIZE: dcaeLocation object
23 JSON=/tmp/$$.loc
24 cat << EOF > $JSON
25 {
26     "dcaeLocationName": "csit-sanfrancisco",
27     "dcaeLayer": "central-cloud",
28     "clli": "CSIT12345",
29     "zone": "zoneA"
30
31 }
32 EOF
33
34 echo "Initializing /dcaeLocations endpoint"
35 curl -v -k  -X POST -d @${JSON} -H "Content-Type: application/json" https://$1:8443/webapi/dcaeLocations
36
37
38 # INITIALIZE: MR object in 1 site
39 # since MR is currently deployed via docker-compose, its IP doesn't seem
40 # to be routable from DBCL. Fortunately, the MR port is mapped from the docker bridge IP address.
41 # Found this article for how to deterine the docker bridge IP so using it as a workaround.
42 # https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container
43 # Used the following snippet found buried in a comment to an answer and then modified for only 1 value.
44 DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+' | head -1 )
45 # Perhaps there is a better way...
46 JSON=/tmp/$$.mrc
47 cat << EOF > $JSON
48 {
49     "dcaeLocationName": "csit-sanfrancisco",
50     "fqdn": "message-router",
51     "topicProtocol" : "http",
52     "topicPort": "3904"
53
54 }
55 EOF
56
57 echo "Initializing /mr_clusters endpoint"
58 curl -v -k  -X POST -d @${JSON} -H "Content-Type: application/json" https://$1:8443/webapi/mr_clusters