DRAFT: CBS and Consul simulator 99/1999/1
authorYongchaoWu <yongchao.wu@est.tech>
Wed, 11 Dec 2019 12:10:30 +0000 (13:10 +0100)
committeryongchao <yongchao.wu@est.tech>
Wed, 11 Dec 2019 12:12:40 +0000 (13:12 +0100)
Issue-ID: NONRTRIC-79
Signed-off-by: YongchaoWu <yongchao.wu@est.tech>
Change-Id: I8ef3e2a90a750a3842409b5beefeb4854f2ab09b

near-rt-ric-simulator/consul_cbs/config.json [new file with mode: 0644]
near-rt-ric-simulator/consul_cbs/consul/cbs_localhost_config.hcl [new file with mode: 0644]
near-rt-ric-simulator/consul_cbs/docker-compose-template.yml [new file with mode: 0644]
near-rt-ric-simulator/consul_cbs/docker-compose.yml [new file with mode: 0644]
near-rt-ric-simulator/consul_cbs/start.sh [new file with mode: 0755]

diff --git a/near-rt-ric-simulator/consul_cbs/config.json b/near-rt-ric-simulator/consul_cbs/config.json
new file mode 100644 (file)
index 0000000..f75b2c5
--- /dev/null
@@ -0,0 +1,13 @@
+ {
+    "//description": "Application configuration",
+    "ric": [
+      {
+        "name": "ric1",
+        "baseUrl": "http://localhost:8080/",
+        "managedElementIds": [
+          "kista_1",
+          "kista_2"
+        ]
+      }
+    ]
+  }
diff --git a/near-rt-ric-simulator/consul_cbs/consul/cbs_localhost_config.hcl b/near-rt-ric-simulator/consul_cbs/consul/cbs_localhost_config.hcl
new file mode 100644 (file)
index 0000000..c2d9839
--- /dev/null
@@ -0,0 +1,11 @@
+service {
+  # Name for CBS in consul, env var CONFIG_BINDING_SERVICE
+  # should be passed to dfc app with this value
+  # This is only to be used when contacting cbs via local host
+  # (typicall when dfc is executed as an application without a container)
+  Name = "config-binding-service-localhost"
+  # Host name where CBS is running
+  Address = "localhost"
+  # Port number where CBS is running
+  Port = 10000
+}
\ No newline at end of file
diff --git a/near-rt-ric-simulator/consul_cbs/docker-compose-template.yml b/near-rt-ric-simulator/consul_cbs/docker-compose-template.yml
new file mode 100644 (file)
index 0000000..1dcdb79
--- /dev/null
@@ -0,0 +1,30 @@
+version: '3'
+
+networks:
+  nonrtric-docker-net:
+    external:
+      name: nonrtric-docker-net
+
+services:
+
+  consul-server:
+    networks:
+      - nonrtric-docker-net
+    container_name: polman_consul
+    image: docker.io/consul:1.4.4
+    ports:
+      - "8500:8500"
+    volumes:
+      - ./consul/:/consul/config
+
+  config-binding-service:
+    networks:
+      - nonrtric-docker-net
+    container_name: polman_cbs
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.3.0
+    ports:
+      - "10000:10000"
+    environment:
+      - CONSUL_HOST=consul-server
+    depends_on:
+      - consul-server
\ No newline at end of file
diff --git a/near-rt-ric-simulator/consul_cbs/docker-compose.yml b/near-rt-ric-simulator/consul_cbs/docker-compose.yml
new file mode 100644 (file)
index 0000000..a01fbd9
--- /dev/null
@@ -0,0 +1,27 @@
+networks:
+  nonrtric-docker-net:
+    external:
+      name: nonrtric-docker-net
+services:
+  config-binding-service:
+    container_name: polman_cbs
+    depends_on:
+    - consul-server
+    environment:
+      CONSUL_HOST: consul-server
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.3.0
+    networks:
+      nonrtric-docker-net: null
+    ports:
+    - 10000:10000/tcp
+  consul-server:
+    container_name: polman_consul
+    image: docker.io/consul:1.4.4
+    networks:
+      nonrtric-docker-net: null
+    ports:
+    - 8500:8500/tcp
+    volumes:
+    - /Users/yonwu/ORAN/nonrtric/near-rt-ric-simulator/consul_cbs/consul:/consul/config:rw
+version: '3.0'
+
diff --git a/near-rt-ric-simulator/consul_cbs/start.sh b/near-rt-ric-simulator/consul_cbs/start.sh
new file mode 100755 (executable)
index 0000000..ed4f9e6
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+DOCKER_SIM_NWNAME="nonrtric-docker-net"
+echo "Creating docker network $DOCKER_SIM_NWNAME, if needed"
+docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
+
+docker-compose -f docker-compose-template.yml config > docker-compose.yml
+
+docker-compose up -d
+
+CONSUL_PORT=8500
+
+APP="policy-agent"
+JSON_FILE="config.json"
+
+curl -s -v  http://127.0.0.1:${CONSUL_PORT}/v1/kv/${APP}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$JSON_FILE
\ No newline at end of file