ADTRAN OLT: Fix NETCONF interface name for flows

Change-Id: Id8366cc12f51a9cb4bcbf97e948ba4107573abc3
diff --git a/voltha/adapters/adtran_olt/adtran_olt.py b/voltha/adapters/adtran_olt/adtran_olt.py
index 421eb6b..9bbf497 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='1.26',
+            version='1.27',
             config=AdapterConfig(log_level=LogLevel.INFO)
         )
         log.debug('adtran_olt.__init__', adapter_agent=adapter_agent)
diff --git a/voltha/adapters/adtran_olt/adtran_olt_handler.py b/voltha/adapters/adtran_olt/adtran_olt_handler.py
index 788cb70..462db97 100644
--- a/voltha/adapters/adtran_olt/adtran_olt_handler.py
+++ b/voltha/adapters/adtran_olt/adtran_olt_handler.py
@@ -1065,26 +1065,31 @@
     def get_northbound_port(self, port):
         return self.northbound_ports.get(port, None)
 
-    def get_port_name(self, port):
+    def get_port_name(self, port, logical_name=False):
+        """
+        Get the name for a port
+
+        Port names are used in various ways within and outside of VOLTHA.
+        Typically, the physical port name will be used during device handler conversations
+        with the hardware (REST, NETCONF, ...) while the logical port name is what the
+        outside world (ONOS, SEBA, ...) uses.
+
+        All ports have a physical port name, but only ports exposed through VOLTHA
+        as a logical port will have a logical port name
+        """
         if self.is_nni_port(port):
-            return self.northbound_ports[port].name
+            port = self.get_northbound_port(port)
+            return port.logical_port_name if logical_name else port.physical_port_name
 
         if self.is_pon_port(port):
-            return self.get_southbound_port(port).name
+            port = self.get_southbound_port(port)
+            return port.logical_port_name if logical_name else port.physical_port_name
 
         if self.is_uni_port(port):
-            if self.xpon_support:
-                return self.northbound_ports[port].name
-            else:
-                # try:   TODO: Remove this crap
-                #     import voltha.protos.device_pb2 as dev_pb2
-                #     return dev_pb2._PORT_PORTTYPE.values_by_number[port].name
-                # except Exception as err:
-                #     pass
-                return 'uni-{}'.format(port)
+            return 'uni-{}'.format(port)
 
         if self.is_logical_port(port):
-            raise NotImplemented('TODO: Logical ports not yet supported')
+            raise NotImplemented('Logical OpenFlow ports are not supported')
 
     def _update_download_status(self, request, download):
         if download is not None:
diff --git a/voltha/adapters/adtran_olt/nni_port.py b/voltha/adapters/adtran_olt/nni_port.py
index 3ac974d..deee9c7 100644
--- a/voltha/adapters/adtran_olt/nni_port.py
+++ b/voltha/adapters/adtran_olt/nni_port.py
@@ -42,9 +42,11 @@
         self.log = structlog.get_logger(port_no=kwargs.get('port_no'))
         self.log.info('creating')
 
-        # self._name = kwargs.get('name', 'nni-{}'.format(self._port_no))
-        # SEBA wants 'nni-#', not 'hundred-gigabit-ethernet 0/1
-        self._name = 'nni-{}'.format(self._port_no)
+        # ONOS/SEBA wants 'nni-<port>' for port names, OLT NETCONF wants their
+        # name (something like  hundred-gigabit-ethernet 0/1) which is reported
+        # when we enumerated the ports
+        self._physical_port_name = kwargs.get('name', 'nni-{}'.format(self._port_no))
+        self._logical_port_name = 'nni-{}'.format(self._port_no)
 
         self._logical_port = None
 
@@ -64,8 +66,7 @@
         self._admin_state = AdminState.ENABLED
         self._oper_status = OperStatus.ACTIVE
 
-        # self._label = kwargs.pop('label', 'NNI port {}'.format(self._port_no))
-        self._label = 'nni-{}'.format(self._port_no)
+        self._label = self._physical_port_name
         self._mac_address = kwargs.pop('mac_address', '00:00:00:00:00:00')
         # TODO: Get with JOT and find out how to pull out MAC Address via NETCONF
         # TODO: May need to refine capabilities into current, advertised, and peer
@@ -145,7 +146,7 @@
         if self._logical_port is None:
             openflow_port = ofp_port(port_no=self._port_no,
                                      hw_addr=mac_str_to_tuple(self._mac_address),
-                                     name=self._name,
+                                     name=self._logical_port_name,
                                      config=0,
                                      state=self._ofp_state,
                                      curr=self._ofp_capabilities,
@@ -154,7 +155,7 @@
                                      curr_speed=self._current_speed,
                                      max_speed=self._max_speed)
 
-            self._logical_port = LogicalPort(id='nni{}'.format(self._port_no),
+            self._logical_port = LogicalPort(id=self._logical_port_name,
                                              ofp_port=openflow_port,
                                              device_id=self._parent.device_id,
                                              device_port_no=self._device_port_no,
@@ -225,7 +226,7 @@
 
         config = '<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">' + \
                  ' <interface>' + \
-                 '  <name>{}</name>'.format(self._name) + \
+                 '  <name>{}</name>'.format(self._physical_port_name) + \
                  '  {}'.format(self._ianatype) + \
                  '  <{}>{}</{}>'.format(leaf, value, leaf) + \
                  ' </interface>' + \
@@ -242,7 +243,7 @@
         config = '<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">' + \
                  ' <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">' + \
                  '  <interface>' + \
-                 '   <name>{}</name>'.format(self._name) + \
+                 '   <name>{}</name>'.format(self._physical_port_name) + \
                  '   <enabled/>' + \
                  '  </interface>' + \
                  ' </interfaces>' + \
@@ -253,7 +254,7 @@
         state = '<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">' + \
                  ' <interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">' + \
                  '  <interface>' + \
-                 '   <name>{}</name>'.format(self._name) + \
+                 '   <name>{}</name>'.format(self._physical_port_name) + \
                  '   <admin-status/>' + \
                  '   <oper-status/>' + \
                  '   <statistics/>' + \
diff --git a/voltha/adapters/adtran_olt/pon_port.py b/voltha/adapters/adtran_olt/pon_port.py
index eb1239f..dd1b7e3 100644
--- a/voltha/adapters/adtran_olt/pon_port.py
+++ b/voltha/adapters/adtran_olt/pon_port.py
@@ -59,7 +59,7 @@
         self._pon_id = kwargs['pon-id']
         self.log = structlog.get_logger(device_id=parent.device_id, pon_id=self._pon_id)
         self._port_no = kwargs['port_no']
-        self._name = 'xpon 0/{}'.format(self._pon_id+1)
+        self._physical_port_name = 'xpon 0/{}'.format(self._pon_id+1)
         self._label = 'pon-{}'.format(self._pon_id)
 
         self._in_sync = False
diff --git a/voltha/adapters/adtran_olt/port.py b/voltha/adapters/adtran_olt/port.py
index fd94c6d..1eb0a13 100644
--- a/voltha/adapters/adtran_olt/port.py
+++ b/voltha/adapters/adtran_olt/port.py
@@ -39,8 +39,15 @@
         self._parent = parent
         self._port_no = kwargs.get('port_no')
 
-        # Set the following in your derived class
-        self._name = None
+        # Set the following in your derived class.  These names are used in
+        # various ways.  Typically, the physical port name will be used during
+        # device handler conversations with the hardware (REST, NETCONF, ...)
+        # while the logical port name is what the outside world (ONOS, SEBA, ...)
+        # uses.  All ports have a physical port name, but only ports exposed through
+        # VOLTHA as a logical port will have a logical port name
+
+        self._physical_port_name = None
+        self._logical_port_name = None
         self._label = None
         self._port = None
 
@@ -87,8 +94,16 @@
         return self.port_no
 
     @property
+    def physical_port_name(self):
+        return self._physical_port_name
+
+    @property
+    def logical_port_name(self):
+        return self._logical_port_name
+
+    @property                           # For backwards compatibility
     def name(self):
-        return self._name
+        return self._logical_port_name
 
     @property
     def state(self):