logging logical device info in atests

Change-Id: I24ffedecc8a8b483817c21909f17cd7c13573bdc
diff --git a/tests/atests/common/auto_test.py b/tests/atests/common/auto_test.py
index 2721923..308ec04 100755
--- a/tests/atests/common/auto_test.py
+++ b/tests/atests/common/auto_test.py
@@ -74,7 +74,7 @@
 
     preprovisioning.runTest('olt.voltha.svc', 50060, 'ponsim_olt', 'ponsim_onu', LOG_DIR)
     
-    discovery.runTest('ponsim_olt', 'ponsim_onu', LOG_DIR)
+    discovery.runTest('olt.voltha.svc', 'ponsim_olt', 'ponsim_onu', LOG_DIR)
 
     authentication.runTest(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
 
diff --git a/tests/atests/common/discovery.py b/tests/atests/common/discovery.py
index 0015e5a..a0f3ef5 100755
--- a/tests/atests/common/discovery.py
+++ b/tests/atests/common/discovery.py
@@ -35,10 +35,12 @@
         self.dirs ['log'] = None
         self.dirs ['root'] = None
         self.dirs ['voltha'] = None
-        
+
+        self.__logicalDeviceType = None
         self.__oltType = None
         self.__onuType = None
         self.__fields = []
+        self.__logicalDeviceId = None
         self.__oltDeviceId = None
         self.__onuDeviceIds = []
         self.__peers = None
@@ -46,10 +48,22 @@
     def dSetLogDirs(self, logDir):
         testCaseUtils.configDirs(self, logDir)
 
-    def dConfigure(self, oltType, onuType):
+    def dConfigure(self, logicalDeviceType, oltType, onuType):
+        self.__logicalDeviceType = logicalDeviceType
         self.__oltType = oltType
         self.__onuType = onuType
 
+    def logicalDevice(self):
+        logging.info('Logical Device Info')
+        statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__logicalDeviceType, 'voltha_devices_after_enable.log')
+        assert statusLines, 'No Logical Devices listed under devices'
+        self.__fields = testCaseUtils.parseFields(statusLines)
+        self.__logicalDeviceId = self.__fields[4].strip()
+        testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
+            'voltha_logical_device.log', 'logical_device ' + self.__logicalDeviceId, 'voltha_logical_device_ports.log', 'ports', 'voltha_logical_device_flows.log', 'flows')
+        testCaseUtils.printLogFile (self, 'voltha_logical_device_ports.log')
+        testCaseUtils.printLogFile (self, 'voltha_logical_device_flows.log')
+
     def oltDiscovery(self):
         logging.info('Olt Discovery')
         statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_after_enable.log')
@@ -144,12 +158,13 @@
                 assert int(plainNumber) > 0, 'Zero number of flows for Onu %s' % onuDeviceId
                       
 
-def runTest(oltType, onuType, logDir):
+def runTest(logicalDeviceType, oltType, onuType, logDir):
     discovery = Discovery()
     discovery.dSetLogDirs(logDir)
-    discovery.dConfigure(oltType, onuType)
+    discovery.dConfigure(logicalDeviceType, oltType, onuType)
     discovery.oltDiscovery()
     discovery.onuDiscovery()
+    discovery.logicalDevice()
     discovery.olt_ports_should_be_enabled_and_active()                                      
     discovery.onu_ports_should_be_enabled_and_active()
     discovery.olt_should_have_at_least_one_flow()
diff --git a/tests/atests/robot/voltha_automated_test_suite.robot b/tests/atests/robot/voltha_automated_test_suite.robot
index d720321..e9d4e86 100755
--- a/tests/atests/robot/voltha_automated_test_suite.robot
+++ b/tests/atests/robot/voltha_automated_test_suite.robot
@@ -35,6 +35,7 @@
 ${ONOS_SSH_PORT}  8101
 ${OLT_IP_ADDR}    olt.voltha.svc
 ${OLT_PORT_ID}    50060
+${LOGICAL_TYPE}   olt.voltha.svc
 ${OLT_TYPE}       ponsim_olt
 ${ONU_TYPE}       ponsim_onu
 
@@ -65,9 +66,10 @@
     ...                 Olt or Onu device. Functionality to support multiple ONU accomodated
     ...                 The extent of the flow validation is limited to checking whether number of Flows is > 0
     DSet Log Dirs    ${LOG_DIR}
-    DConfigure      ${OLT_TYPE}    ${ONU_TYPE}
+    DConfigure      ${LOGICAL_TYPE}    ${OLT_TYPE}    ${ONU_TYPE}
     Olt Discovery
     Onu Discovery
+    Logical Device
     Olt Ports Should Be Enabled and Active
     Onu Ports Should Be Enabled and Active
     Olt Should Have At Least One Flow