Multiple ponsimONU support - template updates

Change-Id: I1b4c79f61e0d0f9b566c09517c939bee890b41a3
diff --git a/ponsimv2/Chart.yaml b/ponsimv2/Chart.yaml
index 45bf595..567aac7 100644
--- a/ponsimv2/Chart.yaml
+++ b/ponsimv2/Chart.yaml
@@ -17,7 +17,7 @@
 description: PON Simulator
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 1.1.0
+version: 1.1.1
 
 # VOLTHA version
 appVersion: 1.6.0
diff --git a/ponsimv2/templates/onu.yaml b/ponsimv2/templates/onu.yaml
index debb013..f297546 100644
--- a/ponsimv2/templates/onu.yaml
+++ b/ponsimv2/templates/onu.yaml
@@ -13,36 +13,38 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- $onucount := (.Values.numOnus|int)}}
 {{- range $i, $junk := until (.Values.numOlts|int) }}
+{{- range $j, $junk1 := until ($onucount) }}
 ---
 apiVersion: v1
 kind: Service
 metadata:
-   name: onu{{ $i }}
+   name: onu{{ $i }}-{{ $j }}
    namespace: {{ $.Values.global.namespace }}
    labels:
-     name: onu{{ $i }}
+     name: onu{{ $i }}-{{ $j }}
 spec:
   ports:
     - name: grpc
       port: 50061
       targetPort: 50061
   selector:
-    app: onu{{ $i }}
+    app: onu{{ $i }}-{{ $j }}
 ---
 apiVersion: apps/v1beta1
 kind: Deployment
 metadata:
-  name: onu{{ $i }}
+  name: onu{{ $i }}-{{ $j }}
   namespace: {{ $.Values.global.namespace }}
 spec:
    replicas: 1
    template:
      metadata:
        labels:
-         app: onu{{ $i }}
+         app: onu{{ $i }}-{{ $j }}
        annotations:
-         cni: "calico,pon{{ $i }}"
+         cni: "calico,pon{{ $i }}.{{ $j }}"
      spec:
        affinity:
         podAffinity:
@@ -54,10 +56,10 @@
                 - key: app
                   operator: In
                   values:
-                  - rg{{ $i }}
+                  - rg{{ $i }}-{{ $j }}
               topologyKey: kubernetes.io/hostname
        containers:
-         - name: onu{{ $i }}
+         - name: onu{{ $i }}-{{ $j }}
            image: "{{ $.Values.global.registry }}{{ $.Values.images.onu.repository }}:{{ tpl $.Values.images.onu.tag $ }}"
            imagePullPolicy: {{ $.Values.images.onu.pullPolicy }}
            env:
@@ -84,10 +86,11 @@
              - "-promiscuous"
 {{- if not $.Values.legacyPonsim }}
              - "-serial_number"
-             - "PSMO{{ printf "%04d" $i }}0000"
+             - "PSMO{{ printf "%04d%04d" $i $j }}"
+{{- end }}
 {{- end }}
 
            ports:
             - containerPort: 50061
               name: grpc-port
-{{- end }}
\ No newline at end of file
+{{- end }}
diff --git a/ponsimv2/templates/rg.yaml b/ponsimv2/templates/rg.yaml
index ae3203c..44eb1e6 100644
--- a/ponsimv2/templates/rg.yaml
+++ b/ponsimv2/templates/rg.yaml
@@ -13,21 +13,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+{{- $rgcount := (.Values.numOnus|int) }}
 {{- range $i, $junk := until (.Values.numOlts|int) }}
+{{- range $j, $junk1 := until ($rgcount) }}
 ---
 apiVersion: apps/v1beta1
 kind: Deployment
 metadata:
-  name: rg{{ $i }}
+  name: rg{{ $i }}-{{ $j }}
   namespace: {{ $.Values.global.namespace }}
 spec:
    replicas: 1
    template:
      metadata:
        labels:
-         app: rg{{ $i }}
+         app: rg{{ $i }}-{{ $j }}
        annotations:
-         cni: "pon{{ $i }}"
+         cni: "pon{{ $i }}.{{ $j }}"
      spec:
        affinity:
         podAffinity:
@@ -39,10 +41,10 @@
                 - key: app
                   operator: In
                   values:
-                  - onu{{ $i }}
+                  - onu{{ $i }}-{{ $j }}
               topologyKey: kubernetes.io/hostname
        containers:
-         - name: rg{{ $i }}
+         - name: rg{{ $i }}-{{ $j }}
            image: "{{ $.Values.global.registry }}{{ $.Values.images.rg.repository }}:{{ tpl $.Values.images.rg.tag $ }}"
            imagePullPolicy: {{ $.Values.images.rg.pullPolicy }}
            env:
@@ -57,4 +59,5 @@
            command: [ "/bin/bash", "-c", "trap : TERM INT; sleep infinity & wait" ]
            securityContext:
              privileged: true
-{{- end }}
\ No newline at end of file
+{{- end }}
+{{- end }}
diff --git a/ponsimv2/values.yaml b/ponsimv2/values.yaml
index 42434b5..045644d 100644
--- a/ponsimv2/values.yaml
+++ b/ponsimv2/values.yaml
@@ -37,6 +37,6 @@
 
 # numOlts > 1 only works with voltha-1.7 or greater
 numOlts: 1
-
+numOnus: 1
 # legacyPonsim == true means that we are using voltha-1.6
 legacyPonsim: true