VOL-1147: ADTRAN OLT: Add support for host_and_port preprovisioning

Change-Id: I395640c0bc2b6b7fa8072deb17cbd40ccec9e544
diff --git a/voltha/adapters/adtran_olt/README.md b/voltha/adapters/adtran_olt/README.md
index 73fc9ed..e2aaeaf 100644
--- a/voltha/adapters/adtran_olt/README.md
+++ b/voltha/adapters/adtran_olt/README.md
@@ -29,6 +29,19 @@
     preprovision_olt -t adtran_olt -i 10.17.174.193 -- --nc_username admin --nc_password admin --rc_username ADMIN --rc_password ADMIN
 ```
 
+In addition to specifying the Adtran OLT by a single IP address, the host & port provisioning option
+is also supported. This allows you to configure the address of the Adtran OLT with the same command line
+option as the OpenOLT device adapter. For the port number, just specify the netconf port (default 830)
+as in:
+
+```bash
+    preprovision_olt -t adtran_olt -H 10.17.174.193:830
+```
+or
+```bash
+    preprovision_olt -t adtran_olt --host_and_port 10.17.174.193:830
+```
+
 Currently the Adtran Device Adapter supports xPON provisioning and to enable PON ports, or activate ONUs, you
 must use the appropriate commands. In the VOLTHA v2.0 release (Q4 2018?), the xPON provisioning will be removed
 from VOLTHA and replaced with Technology Profiles.
@@ -78,6 +91,9 @@
   "firmware_version": ""
 }
 ```
+Besides specifying the "ipv4_address" leaf, you can alternatively use the "host_and_port" leaf to
+provide the IP Host address and the NetCONF port as in "10.17.174.228:830"
+
 ## Enabling the Pre-Provisioned OLT
 To enable the OLT, you need the retrieve the OLT Device ID and issue a POST request to the proper URL as in:
 ```bash
diff --git a/voltha/adapters/adtran_olt/adtran_device_handler.py b/voltha/adapters/adtran_olt/adtran_device_handler.py
index 5fd5547..9cc0cdf 100644
--- a/voltha/adapters/adtran_olt/adtran_device_handler.py
+++ b/voltha/adapters/adtran_olt/adtran_device_handler.py
@@ -217,10 +217,17 @@
         from net.pon_zmq import DEFAULT_PON_AGENT_TCP_PORT
         from net.pio_zmq import DEFAULT_PIO_TCP_PORT
 
-        if not device.ipv4_address:
-            self.activate_failed(device, 'No ip_address field provided')
+        if device.ipv4_address:
+            self.ip_address = device.ipv4_address
 
-        self.ip_address = device.ipv4_address
+        elif device.host_and_port:
+            host_and_port = device.host_and_port.split(":")
+            self.ip_address = host_and_port[0]
+            self.netconf_port = int(host_and_port[1])
+            self.adapter_agent.update_device(device)
+
+        else:
+            self.activate_failed(device, 'No IP_address field provided')
 
         #############################################################
         # Now optional parameters
diff --git a/voltha/adapters/adtran_olt/adtran_olt.py b/voltha/adapters/adtran_olt/adtran_olt.py
index 6006755..3eef205 100644
--- a/voltha/adapters/adtran_olt/adtran_olt.py
+++ b/voltha/adapters/adtran_olt/adtran_olt.py
@@ -52,7 +52,7 @@
         self.descriptor = Adapter(
             id=self.name,
             vendor='Adtran Inc.',
-            version='0.17',
+            version='0.18',
             config=AdapterConfig(log_level=LogLevel.INFO)
         )
         log.debug('adtran_olt.__init__', adapter_agent=adapter_agent)