Update roscore to have separate dns and use official ros

Change-Id: Ifb28800bfaba66907ab8178caad5e229d484d848
diff --git a/apps/ros-core/Chart.yaml b/apps/ros-core/Chart.yaml
index 5644e7b..4444a62 100644
--- a/apps/ros-core/Chart.yaml
+++ b/apps/ros-core/Chart.yaml
@@ -7,4 +7,4 @@
 name: ros-core
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.1.1
+version: 0.1.2
diff --git a/apps/ros-core/requirements.yaml b/apps/ros-core/requirements.yaml
new file mode 100644
index 0000000..98f7209
--- /dev/null
+++ b/apps/ros-core/requirements.yaml
@@ -0,0 +1,9 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+dependencies:
+  - name: coredns
+    version: 1.13.4
+    repository: https://charts.helm.sh/stable
+    condition: coredns.deploy
diff --git a/apps/ros-core/templates/bin/_net_listener.tpl b/apps/ros-core/templates/bin/_net_listener.tpl
new file mode 100644
index 0000000..5fd5f28
--- /dev/null
+++ b/apps/ros-core/templates/bin/_net_listener.tpl
@@ -0,0 +1,15 @@
+# Copyright 2019-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+import argparse, socket
+from socket import gethostbyaddr
+from datetime import datetime
+
+sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+sock.bind(('0.0.0.0', {{ .Values.config.droneNetListener.port }}))
+print('Listening at {}'.format(sock.getsockname()))
+while True:
+    data, address = sock.recvfrom(65535)
+    text = data.decode('ascii')
+    print('The client at {} says {!r}'.format(address, text))
diff --git a/apps/ros-core/templates/bin/_run_roscore.sh.tpl b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
index 66b3402..54eff77 100644
--- a/apps/ros-core/templates/bin/_run_roscore.sh.tpl
+++ b/apps/ros-core/templates/bin/_run_roscore.sh.tpl
@@ -5,10 +5,6 @@
 
 set -ex
 
-{{- range .Values.config.rosCore.droneList }}
-echo "{{ .ipAddr }} {{ .domain }}" >> /etc/hosts
-{{- end }}
-
 {{ if .Values.config.rosCore.debug }}
 while true; do sleep 3600; done;
 {{ else }}
diff --git a/apps/ros-core/templates/configmap-roscore.yaml b/apps/ros-core/templates/configmap-roscore.yaml
index a2cfa8f..5a7680f 100644
--- a/apps/ros-core/templates/configmap-roscore.yaml
+++ b/apps/ros-core/templates/configmap-roscore.yaml
@@ -12,3 +12,5 @@
 data:
   run_roscore.sh: |
 {{ tuple "bin/_run_roscore.sh.tpl" . | include "ros-core.template" | indent 4 }}
+  net_listener.py: |
+{{ tuple "bin/_net_listener.tpl" . | include "ros-core.template" | indent 4 }}
diff --git a/apps/ros-core/templates/statefulset-roscore.yaml b/apps/ros-core/templates/statefulset-roscore.yaml
index 58ac1cc..28cb41a 100644
--- a/apps/ros-core/templates/statefulset-roscore.yaml
+++ b/apps/ros-core/templates/statefulset-roscore.yaml
@@ -24,19 +24,39 @@
       nodeSelector:
         {{ .Values.nodeSelector.rosCore.label }}: {{ .Values.nodeSelector.rosCore.value }}
   {{- end }}
-      hostNetwork: {{ .Values.networks.hostNetwork }}
+  {{- if .Values.networks.hostNetwork }}
+      hostNetwork: true
+      dnsPolicy: None
+      dnsConfig:
+        nameservers:
+          - {{ .Values.coredns.service.clusterIP }}
+  {{- end }}
       containers:
       - name: ros-core
         image: {{ .Values.images.tags.rosCore }}
         imagePullPolicy: {{ .Values.images.pullPolicy }}
         securityContext:
           privileged: true
+        stdin: true
+        tty: true
         command:
         - /root/run_roscore.sh
         volumeMounts:
         - name: ros-core
           mountPath: /root/run_roscore.sh
           subPath: run_roscore.sh
+      - name: drone-net-listener
+        image: {{ .Values.images.tags.droneNetListener }}
+        imagePullPolicy: {{ .Values.images.pullPolicy }}
+        stdin: true
+        tty: true
+        command: ["bash", "-xc"]
+        args:
+        - python /opt/net_listener.py
+        volumeMounts:
+        - name: ros-core
+          mountPath: /opt/net_listener.py
+          subPath: net_listener.py
       volumes:
         - name: ros-core
           configMap:
diff --git a/apps/ros-core/values.yaml b/apps/ros-core/values.yaml
index 74386c0..8b73ea6 100644
--- a/apps/ros-core/values.yaml
+++ b/apps/ros-core/values.yaml
@@ -4,11 +4,12 @@
 
 images:
   tags:
-    rosCore:  registry.central.aetherproject.net/drone-ros:v0.1.0
+    rosCore: docker.io/ros:melodic
+    droneNetListener: docker.io/ros:melodic
   pullPolicy: IfNotPresent
 
 nodeSelector:
-  enabled: true
+  enabled: false
   rosCore:
     label: drone-ros-core
     value: enabled
@@ -19,14 +20,44 @@
 config:
   rosCore:
     debug: false
-    droneList:
-    - name: drone1
-      domain: "drone1"
-      ipAddr: 10.250.255.251
-    - name: drone2
-      domain: "drone2"
-      ipAddr: 10.250.255.250
+  droneNetListener:
+    port: 58080
 
 networks:
   hostNetwork: true
 
+coredns:
+  deploy: true
+  serviceType: ClusterIP
+  service:
+    clusterIP: 10.67.128.12
+  servers:
+  - zones:
+    - zone: .
+    port: 53
+    plugins:
+    - name: errors
+    - name: health
+      configBlock: |-
+        lameduck 5s
+    - name: ready
+    - name: forward
+      parameters: . 10.67.128.10
+    - name: cache
+      parameters: 30
+    - name: loop
+    - name: reload
+    - name: loadbalance
+  - zones:
+      - zone: local
+    port: 53
+    plugins:
+    - name: errors
+    - name: health
+      configBlock: |-
+        lameduck 5s
+    - name: ready
+    - name: hosts
+      configBlock: |-
+        192.168.251.4 aah.local
+        10.250.255.234 spirit-of-adventure.local
\ No newline at end of file