Disable avahi daemon and next reboot discover BMC

Change-Id: I8c163d4fba5ba55d02f1582f9a0eb591f2f5dd14
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/openpower/ext_interfaces/test_discovery.robot b/openpower/ext_interfaces/test_discovery.robot
index 20410f8..b8ff2fc 100644
--- a/openpower/ext_interfaces/test_discovery.robot
+++ b/openpower/ext_interfaces/test_discovery.robot
@@ -1,11 +1,15 @@
 *** Settings ***
-Documentation        Test to discover the BMC.
+Documentation        Test to discover the BMC. Before running suit,
+...                  check BMC and Avahi browse machine should be in same subnet.
 
 Variables            ../../data/variables.py
 Library              SSHLibrary
 Library              ../../lib/external_intf/management_console_utils.py
 Library              ../../lib/gen_robot_print.py
 Library              ../../lib/gen_print.py
+Library              ../../lib/gen_misc.py
+Resource             ../../lib/external_intf/management_console_utils.robot
+Resource             ../../lib/boot_utils.robot
 Resource             ../../syslib/utils_os.robot
 
 Suite Setup          Suite Setup Execution
@@ -22,6 +26,16 @@
     _obmc_redfish._tcp
 
 
+Disable AvahiDaemon And Discover BMC After Reboot
+    [Documentation]  Check the input BMC is discoverd and then disable the avahi daemon,
+    ...  in next reboot same input BMC should discoverable.
+    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
+    [Template]  Disable Daemon And Discover BMC After Reboot
+
+    # Service type
+    _obmc_rest._tcp
+    _obmc_redfish._tcp
+
 *** Keywords ***
 
 Suite Setup Execution
@@ -51,8 +65,8 @@
     [Arguments]  ${service_type}
 
     # Description of argument(s):
-    # service_type    BMC service type e.g.
-    #                 (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
+    # service_type  BMC service type e.g.
+    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
 
     # bmc_list:
     # [1]:
@@ -73,3 +87,34 @@
     Print Timen  Exception message is ${exc_msg}
     Should Not Be Empty  ${bmc_list}
     Rprint Vars  bmc_list
+    [Return]  ${bmc_list}
+
+
+Verify Existence Of BMC Record From List
+    [Documentation]  Verify the existence of BMC record from list of BMC records.
+    [Arguments]  ${service_type}
+
+    # Description of argument(s):
+    # service_type  BMC service type e.g.
+    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
+
+    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
+    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
+    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
+    Should Be True  'True' == '${resp}'
+
+
+Disable Daemon And Discover BMC After Reboot
+    [Documentation]  Discover BMC After reboot.
+    [Arguments]  ${service_type}
+
+    # Description of argument(s):
+    # service_type  BMC service type e.g.
+    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
+
+    Set AvahiDaemon Service  command=stop
+    Redfish OBMC Reboot (off)
+    Verify AvahiDaemon Service Status  message=start
+    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
+    Wait Until Keyword Succeeds  2 min  30 sec
+    ...  Verify Existence Of BMC Record From List  ${service_type}