[VOL-2833]  Reporting total number of instances and current adapter instance during Adapter Registration (needs VOL-2834)

Change-Id: I322065b9e01925a9fd30a38e7f24bf7082ce39a0
diff --git a/VERSION b/VERSION
index eef2640..197c4d5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.0-dev0
+2.4.0
diff --git a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_adapter.py b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_adapter.py
index fba1f68..1761156 100644
--- a/python/adapters/brcm_openomci_onu/brcm_openomci_onu_adapter.py
+++ b/python/adapters/brcm_openomci_onu/brcm_openomci_onu_adapter.py
@@ -58,7 +58,7 @@
         )
     ]
 
-    def __init__(self, core_proxy, adapter_proxy, config, build_info):
+    def __init__(self, id, core_proxy, adapter_proxy, config, build_info, current_replica, total_replicas, endpoint):
         self.log = structlog.get_logger()
         self.log.debug('starting-adapter', config=config)
 
@@ -66,10 +66,14 @@
         self.adapter_proxy = adapter_proxy
         self.config = config
         self.descriptor = Adapter(
-            id=self.name,
+            id=id,
             vendor='VOLTHA OpenONU',
             version=build_info.version,
-            config=AdapterConfig()
+            config=AdapterConfig(),
+            currentReplica=current_replica,
+            totalReplicas=total_replicas,
+            endpoint=endpoint,
+            type=self.name
         )
         self.devices_handlers = dict()
         self.device_handler_class = BrcmOpenomciOnuHandler
diff --git a/python/adapters/brcm_openomci_onu/main.py b/python/adapters/brcm_openomci_onu/main.py
index b7867bb..54161ec 100755
--- a/python/adapters/brcm_openomci_onu/main.py
+++ b/python/adapters/brcm_openomci_onu/main.py
@@ -59,7 +59,7 @@
     container_name_regex=os.environ.get('CONTAINER_NUMBER_EXTRACTOR', '^.*\.(['
                                                                       '0-9]+)\..*$'),
     consul=os.environ.get('CONSUL', 'localhost:8500'),
-    name=os.environ.get('NAME', 'openonu'),
+    name=os.environ.get('NAME', 'brcm_openomci_onu'),
     vendor=os.environ.get('VENDOR', 'Voltha Project'),
     device_type=os.environ.get('DEVICE_TYPE', 'openonu'),
     accept_bulk_flow=os.environ.get('ACCEPT_BULK_FLOW', True),
@@ -76,6 +76,8 @@
     heartbeat_topic=os.environ.get('HEARTBEAT_TOPIC', "adapters.heartbeat"),
     probe=os.environ.get('PROBE', ':8080'),
     log_level=os.environ.get('LOG_LEVEL', 'WARN'),
+    current_replica=1,
+    total_replicas=1,
     component_name=os.environ.get('COMPONENT_NAME', "adapter-open-onu")
 )
 
@@ -107,6 +109,7 @@
                         default=defs['consul'],
                         help=_help)
 
+    # NOTE this is really the adapter type
     _help = 'name of this adapter (default: %s)' % defs['name']
     parser.add_argument('-na', '--name',
                         dest='name',
@@ -248,6 +251,20 @@
         default=defs['probe'],
         help=_help)
 
+    _help = 'Replica number of this particular instance (default: %s)' % defs['current_replica']
+    parser.add_argument(
+        '--currentReplica', dest='current_replica', action='store',
+        default=defs['current_replica'],
+        type=int,
+        help=_help)
+
+    _help = 'Total number of instances for this adapter (default: %s)' % defs['total_replicas']
+    parser.add_argument(
+        '--totalReplicas', dest='total_replicas', action='store',
+        default=defs['total_replicas'],
+        type=int,
+        help=_help)
+
     args = parser.parse_args()
 
     # post-processing
@@ -342,7 +359,8 @@
 
         self.core_topic = str(args.core_topic)
         self.event_topic = str(args.event_topic)
-        self.listening_topic = str(args.name)
+        self.listening_topic = "%s_%s" % (args.name, args.current_replica)
+        self.id = "%s_%s" % (args.name, args.current_replica)
         self.startup_components()
 
         if not args.no_heartbeat:
@@ -400,9 +418,15 @@
                 my_listening_topic=self.listening_topic)
 
             self.adapter = BrcmOpenomciOnuAdapter(
-                core_proxy=self.core_proxy, adapter_proxy=self.adapter_proxy,
+                id=self.id,
+                core_proxy=self.core_proxy,
+                adapter_proxy=self.adapter_proxy,
                 config=config,
-                build_info=self.build_info)
+                build_info=self.build_info,
+                current_replica=self.args.current_replica,
+                total_replicas=self.args.total_replicas,
+                endpoint=self.listening_topic
+            )
 
             self.adapter.start()
 
@@ -415,7 +439,7 @@
                     kafka_host_port=self.args.kafka_adapter,
                     # TODO: Add KV Store object reference
                     kv_store=self.args.backend,
-                    default_topic=self.args.name,
+                    default_topic=self.listening_topic,
                     group_id_prefix=self.args.instance_id,
                     target_cls=openonu_request_handler
                 )
diff --git a/python/requirements.txt b/python/requirements.txt
index 7be20c6..a7f2337 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -1,2 +1,2 @@
-voltha-protos==3.2.8
-pyvoltha==2.4.0
+voltha-protos==3.3.0
+pyvoltha==2.4.1