dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 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 |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 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 |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 21 | |
| 22 | # INITIALIZE: dmaap object |
| 23 | JSON=/tmp/$$.dmaap |
| 24 | cat << EOF > $JSON |
| 25 | { |
| 26 | "version": "1", |
| 27 | "topicNsRoot": "org.onap.dmaap", |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 28 | "drProvUrl": "http://${2}:${DRPORT}", |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 29 | "dmaapName": "onapCSIT", |
| 30 | "bridgeAdminTopic": "MM_AGENT_PROV" |
| 31 | |
| 32 | } |
| 33 | EOF |
| 34 | |
Dominic Lunanuova | db5f989 | 2018-04-20 18:54:47 +0000 | [diff] [blame] | 35 | echo "Initializing /dmaap endpoint" |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 36 | curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dmaap |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 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 | |
Dominic Lunanuova | db5f989 | 2018-04-20 18:54:47 +0000 | [diff] [blame] | 52 | echo "Initializing /dcaeLocations endpoint" |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 53 | curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/dcaeLocations |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 54 | |
| 55 | |
| 56 | # INITIALIZE: MR object in 1 site |
Dominic Lunanuova | db5f989 | 2018-04-20 18:54:47 +0000 | [diff] [blame] | 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... |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 64 | JSON=/tmp/$$.mrc |
| 65 | cat << EOF > $JSON |
| 66 | { |
| 67 | "dcaeLocationName": "csit-sanfrancisco", |
Dominic Lunanuova | db5f989 | 2018-04-20 18:54:47 +0000 | [diff] [blame] | 68 | "fqdn": "$DOCKER_HOST", |
| 69 | "topicProtocol" : "http", |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 70 | "topicPort": "${MRPORT}" |
dglFromAtt | 62b8b12 | 2018-03-03 11:57:29 -0500 | [diff] [blame] | 71 | |
| 72 | } |
| 73 | EOF |
| 74 | |
Dominic Lunanuova | db5f989 | 2018-04-20 18:54:47 +0000 | [diff] [blame] | 75 | echo "Initializing /mr_clusters endpoint" |
Dominic Lunanuova | bfb3ea4 | 2018-08-23 21:49:47 +0000 | [diff] [blame^] | 76 | curl ${CURLOPT} -X POST -d @${JSON} -H "Content-Type: application/json" ${PROTO}://$1:${PORT}/webapi/mr_clusters |