SEBA-686 Enable multiple Ponsim OLTs

Change-Id: Ia8cc47492010bcd98f0a8800f70386cd5ca5342b
diff --git a/xos-profiles/ponsim-pod/Chart.yaml b/xos-profiles/ponsim-pod/Chart.yaml
index 7ef6105..6a714bb 100644
--- a/xos-profiles/ponsim-pod/Chart.yaml
+++ b/xos-profiles/ponsim-pod/Chart.yaml
@@ -17,7 +17,7 @@
 description: A Helm chart for loading the Ponsim pod's TOSCA files into XOS
 icon: https://guide.opencord.org/logos/xos.svg
 
-version: 1.2.1
+version: 1.3.0
 
 # xosproject/tosca-loader version
-appVersion: 1.1.5
+appVersion: 1.3.1
diff --git a/xos-profiles/ponsim-pod/templates/tosca-job.yaml b/xos-profiles/ponsim-pod/templates/tosca-job.yaml
index 92d4cd1..d2c37c7 100644
--- a/xos-profiles/ponsim-pod/templates/tosca-job.yaml
+++ b/xos-profiles/ponsim-pod/templates/tosca-job.yaml
@@ -37,8 +37,8 @@
       restartPolicy: OnFailure
       containers:
         - name: {{ .Chart.Name }}-ponsim-pod
-          image: {{ .Values.global.registry }}{{ .Values.image.repository }}:{{ tpl .Values.image.tag . }}
-          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          image: {{ .Values.global.registry }}{{ .Values.images.tosca_loader.repository }}:{{ tpl .Values.images.tosca_loader.tag . }}
+          imagePullPolicy: {{ .Values.images.tosca_loader.pullPolicy }}
           env:
             - name: XOS_USER
               value: {{ .Values.xosAdminUser }}
diff --git a/xos-profiles/ponsim-pod/tosca/020-pod-olt.yaml b/xos-profiles/ponsim-pod/tosca/020-pod-olt.yaml
index 724d56c..6d40563 100644
--- a/xos-profiles/ponsim-pod/tosca/020-pod-olt.yaml
+++ b/xos-profiles/ponsim-pod/tosca/020-pod-olt.yaml
@@ -29,29 +29,36 @@
         name: volt
         must-exist: true
 
-    olt_device:
+{{- range $i, $junk := until (.Values.numOlts|int) }}
+
+    olt{{ $i }}_device:
       type: tosca.nodes.OLTDevice
       properties:
-        name: PONSIM OLT
+        name: PONSIM OLT {{ $i }}
         device_type: ponsim_olt
-        host: olt.voltha.svc
+        host: olt{{ $i }}.voltha.svc
         port: 50060
         switch_datapath_id: of:0000000000000001
-        switch_port: "2"
+        switch_port: "{{ add 2 $i }}"
         outer_tpid: "0x8100"
+{{- if $.Values.legacyPonsim }}
         dp_id: of:0000aabbccddeeff
+{{- else }}
+        dp_id: {{ index $.Values.oltDpids $i }}
+{{- end }}
         uplink: "2"
       requirements:
         - volt_service:
             node: service#volt
             relationship: tosca.relationships.BelongsToOne
 
-    pon_port:
+    olt{{ $i }}_pon_port:
       type: tosca.nodes.PONPort
       properties:
-        name: pon0
+        name: olt{{ $i }}pon0
         port_no: 1
       requirements:
         - olt_device:
-            node: olt_device
+            node: olt{{ $i }}_device
             relationship: tosca.relationships.BelongsToOne
+{{- end }}
\ No newline at end of file
diff --git a/xos-profiles/ponsim-pod/tosca/030-fabric.yaml b/xos-profiles/ponsim-pod/tosca/030-fabric.yaml
index ce3dda8..950551e 100644
--- a/xos-profiles/ponsim-pod/tosca/030-fabric.yaml
+++ b/xos-profiles/ponsim-pod/tosca/030-fabric.yaml
@@ -38,16 +38,19 @@
         ofId: of:0000000000000001
         routerMac: 00:00:02:01:06:01
 
-    # Setup the OLT switch port
-    port#olt_port:
+    # Setup the OLT switch ports
+{{- range $i, $junk := until (.Values.numOlts|int) }}
+
+    port#olt{{ $i }}_port:
       type: tosca.nodes.SwitchPort
       properties:
-        portId: 2
+        portId: {{ add 2 $i }}
         host_learning: false
       requirements:
         - switch:
             node: switch#leaf_1
             relationship: tosca.relationships.BelongsToOne
+{{- end }}
 
     # Port connected to the BNG
     port#bng_port:
diff --git a/xos-profiles/ponsim-pod/tosca/040-subscriber.yaml b/xos-profiles/ponsim-pod/tosca/040-subscriber.yaml
index c806d2c..1263bd3 100644
--- a/xos-profiles/ponsim-pod/tosca/040-subscriber.yaml
+++ b/xos-profiles/ponsim-pod/tosca/040-subscriber.yaml
@@ -38,16 +38,22 @@
          name: Bronze
 {{- end }}
 
-    # Pre-provision the subscriber the subscriber
-    my_house:
+    # Pre-provision the subscribers
+{{- range $i, $junk := until (.Values.numOlts|int) }}
+
+    house_{{ $i }}:
       type: tosca.nodes.RCORDSubscriber
       properties:
-        name: QQClient
+        name: QQClient{{ $i }}
         status: pre-provisioned
         c_tag: 111
-        s_tag: 222
+        s_tag: {{ add 222 $i }}
+  {{- if $.Values.legacyPonsim }}
         onu_device: PSMO12345678
-{{- if .Values.bandwidthProfiles }}
+  {{- else }}
+        onu_device: PSMO{{ printf "%04d" $i }}0000
+  {{- end }}
+  {{- if $.Values.bandwidthProfiles }}
       requirements:
         - upstream_bps:
             node: bronze_bp
@@ -55,4 +61,5 @@
         - downstream_bps:
             node: bronze_bp
             relationship: tosca.relationships.BelongsToOne
+  {{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/xos-profiles/ponsim-pod/tosca/att-workflow/010-att-workflow.yaml b/xos-profiles/ponsim-pod/tosca/att-workflow/010-att-workflow.yaml
index 1af0eb2..419a51e 100644
--- a/xos-profiles/ponsim-pod/tosca/att-workflow/010-att-workflow.yaml
+++ b/xos-profiles/ponsim-pod/tosca/att-workflow/010-att-workflow.yaml
@@ -31,13 +31,21 @@
         name: att-workflow-driver
         must-exist: true
 
-    whitelist:
+{{- range $i, $junk := until (.Values.numOlts|int) }}
+
+    whitelist{{ $i }}:
       type: tosca.nodes.AttWorkflowDriverWhiteListEntry
       properties:
+{{- if $.Values.legacyPonsim }}
         serial_number: PSMO12345678
         device_id: of:0000aabbccddeeff
+{{- else }}
+        serial_number: PSMO{{ printf "%04d" $i }}0000
+        device_id: {{ index $.Values.oltDpids $i }}
+{{- end }}
         pon_port_id: 1
       requirements:
         - owner:
             node: service#att
             relationship: tosca.relationships.BelongsToOne
+{{- end }}
\ No newline at end of file
diff --git a/xos-profiles/ponsim-pod/values.yaml b/xos-profiles/ponsim-pod/values.yaml
index 7166ee4..bea12fb 100644
--- a/xos-profiles/ponsim-pod/values.yaml
+++ b/xos-profiles/ponsim-pod/values.yaml
@@ -22,10 +22,11 @@
 nameOverride: ""
 fullnameOverride: ""
 
-image:
-  repository: 'xosproject/tosca-loader'
-  tag: '{{ .Chart.AppVersion }}'
-  pullPolicy: 'Always'
+images:
+  tosca_loader:
+    repository: 'xosproject/tosca-loader'
+    tag: '{{ .Chart.AppVersion }}'
+    pullPolicy: 'Always'
 
 global:
   registry: ''
@@ -37,3 +38,20 @@
 workflow: att-workflow
 
 bandwidthProfiles: False
+
+# numOlts > 1 only works with voltha-1.7 or greater
+numOlts: 1
+
+# legacyPonsim == true means that we are using voltha-1.6
+legacyPonsim: true
+
+# For legaacyPonsim == false:
+# List of olt dpids that are generated by Ponsim adapter
+# Entry N is generated for oltN.voltha.svc
+# Generate the last 12 characters as follows:
+# $ echo -ne olt0.voltha.svc:50060 | md5sum | cut -c -12
+oltDpids:
+  - of:0000d0d3e158fede
+  - of:00000da7f2c143c7
+  - of:000032be2d4c2abc
+  - of:0000ae9b8dcd58c7