Sending Voltha Adapter IP address to Device in BalApiInit() API
patch set 2 : Addressed review comments
Change-Id: I1e1ae36ffce16f0f499bd619fc75a1e7f267690b
diff --git a/compose/docker-compose-system-test.yml b/compose/docker-compose-system-test.yml
index 0ceee1d..e6407c0 100644
--- a/compose/docker-compose-system-test.yml
+++ b/compose/docker-compose-system-test.yml
@@ -144,6 +144,7 @@
       SERVICE_8880_CHECK_TIMEOUT: "1s"
       SERVICE_50555_NAME: "voltha-grpc"
       SERVICE_18880_NAME: "voltha-sim-rest"
+      SERVICE_HOST_IP: "${DOCKER_HOST_IP}"
     volumes:
     - "/var/run/docker.sock:/tmp/docker.sock"
     networks:
diff --git a/voltha/adapters/asfvolt16_olt/bal.py b/voltha/adapters/asfvolt16_olt/bal.py
index 0ddc3e8..878202f 100644
--- a/voltha/adapters/asfvolt16_olt/bal.py
+++ b/voltha/adapters/asfvolt16_olt/bal.py
@@ -18,7 +18,14 @@
 from voltha.adapters.asfvolt16_olt.protos import bal_pb2, \
     bal_model_types_pb2, bal_model_ids_pb2
 from voltha.adapters.asfvolt16_olt.grpc_client import GrpcClient
+from common.utils.nethelpers import get_my_primary_interface, \
+    get_my_primary_local_ipv4
+import os
 
+"""
+ASFVOLT Adapter port is 60001
+"""
+ADAPTER_PORT = 60001
 
 class Bal(object):
     def __init__(self, olt, log):
@@ -35,6 +42,20 @@
         self.grpc_client.connect(host_and_port)
         self.stub = bal_pb2.BalStub(self.grpc_client.channel)
         init = bal_pb2.BalInit()
+        try:
+            os.environ["SERVICE_HOST_IP"]
+            adapter_ip = os.environ["SERVICE_HOST_IP"]
+        except Exception as e:
+            self.log.info('voltha is running in non docker container environment')
+            adapter_ip = get_my_primary_local_ipv4()
+
+        ip_port = []
+        ip_port.append(str(adapter_ip))
+        ip_port.append(":")
+        ip_port.append(str(ADAPTER_PORT))
+        init.voltha_adapter_ip_port ="".join(ip_port)
+        self.log.info('Adapter port Ip', init.voltha_adapter_ip_port)
+
         '''
         TODO: Need to determine out what information
         needs to be sent to the OLT at this stage.
diff --git a/voltha/adapters/asfvolt16_olt/protos/bal.proto b/voltha/adapters/asfvolt16_olt/protos/bal.proto
index 885d0bf..d1b4048 100644
--- a/voltha/adapters/asfvolt16_olt/protos/bal.proto
+++ b/voltha/adapters/asfvolt16_olt/protos/bal.proto
@@ -44,8 +44,7 @@
 }
 
 message BalInit {
-    string balapi_mgmt_ip_port = 1;     // IP:port of the BAL API management queue
-    string core_mgmt_ip_port = 2;       // IP:port of the core management queue
+    string voltha_adapter_ip_port = 1;  // IP:port of the VOLTHA Adapter
 }
 
 message BalKey {
diff --git a/voltha/adapters/asfvolt16_olt/protos/bal_model_types.proto b/voltha/adapters/asfvolt16_olt/protos/bal_model_types.proto
index 792518c..3c7a618 100644
--- a/voltha/adapters/asfvolt16_olt/protos/bal_model_types.proto
+++ b/voltha/adapters/asfvolt16_olt/protos/bal_model_types.proto
@@ -202,11 +202,10 @@
 /** Interface type.
  */
 enum BalIntfType {
-    BAL_INTF_TYPE_INVALID                    = 0;    /**< INVALID.*/
-    BAL_INTF_TYPE_NNI                        = 1;    /**< NNI Interface. */
-    BAL_INTF_TYPE_PON                        = 2;    /**< POIN Interface. */
-    BAL_INTF_TYPE_EPON_1G_PATH               = 3;    /**< EPON 1G Path. */
-    BAL_INTF_TYPE_EPON_10G_PATH              = 4;    /**< EPON 10G Path. */
+    BAL_INTF_TYPE_NNI                        = 0;    /**< NNI Interface. */
+    BAL_INTF_TYPE_PON                        = 1;    /**< POIN Interface. */
+    BAL_INTF_TYPE_EPON_1G_PATH               = 2;    /**< EPON 1G Path. */
+    BAL_INTF_TYPE_EPON_10G_PATH              = 3;    /**< EPON 10G Path. */
 }
 
 /** Interworking Function Mode.