1*** Settings ***
2Documentation        Test to discover the BMC. Before running suit,
3...                  check BMC and Avahi browse machine should be in same subnet.
4
5Variables            ../../data/variables.py
6Library              SSHLibrary
7Library              ../../lib/external_intf/management_console_utils.py
8Library              ../../lib/gen_robot_print.py
9Library              ../../lib/gen_print.py
10Library              ../../lib/gen_misc.py
11Resource             ../../lib/external_intf/management_console_utils.robot
12Resource             ../../lib/boot_utils.robot
13Resource             ../../syslib/utils_os.robot
14
15Suite Setup          Suite Setup Execution
16
17*** Test Cases ***
18
19Discover BMC With Different Service Type
20    [Documentation]  Discover all the BMC with different service type support.
21    [Tags]  Discover_BMC_With_Different_Service_Type
22    [Template]  Discover BMC With Service Type
23
24    # Service type
25    _obmc_rest._tcp
26    _obmc_redfish._tcp
27
28
29Disable AvahiDaemon And Discover BMC After Reboot
30    [Documentation]  Check the input BMC is discoverd and then disable the avahi daemon,
31    ...  in next reboot same input BMC should discoverable.
32    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
33    [Template]  Disable Daemon And Discover BMC After Reboot
34
35    # Service type
36    _obmc_rest._tcp
37    _obmc_redfish._tcp
38
39*** Keywords ***
40
41Suite Setup Execution
42    [Documentation]  Do the suite setup.
43
44    Should Not Be Empty  ${AVAHI_CLIENT}
45    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
46    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
47    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
48    Check Avahi Package
49
50
51Check Avahi Package
52    [Documentation]  To check for avahi-tools package.
53
54    # Expected command output as below.
55    # avahi-tools-0.6.31-19.el7.x86_64
56
57    ${command}=  Set Variable  rpm -qa | grep avahi-tools
58    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
59    Should Be Empty  ${stderr}
60    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
61
62
63Discover BMC With Service Type
64    [Documentation]  To get the discoverd BMC list.
65    [Arguments]  ${service_type}
66
67    # Description of argument(s):
68    # service_type  BMC service type e.g.
69    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
70
71    # bmc_list:
72    # [1]:
73    #    [service]:          _obmc_XXXX._tcp
74    #    [hostname]:         System Name
75    #    [address]:          XXX.XXX.XXX.XXX
76    #    [port]:             XXX
77    #    [txt]:
78    # [2]:
79    #    [service]:          _obmc_XXXX._tcp
80    #    [hostname]:         System Name
81    #    [address]:          XXX.XXX.XXX.XXX
82    #    [port]:             XXX
83    #    [txt]:
84
85    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
86    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
87    Print Timen  Exception message is ${exc_msg}
88    Should Not Be Empty  ${bmc_list}
89    Rprint Vars  bmc_list
90    [Return]  ${bmc_list}
91
92
93Verify Existence Of BMC Record From List
94    [Documentation]  Verify the existence of BMC record from list of BMC records.
95    [Arguments]  ${service_type}
96
97    # Description of argument(s):
98    # service_type  BMC service type e.g.
99    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
100
101    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
102    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
103    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
104    Should Be True  'True' == '${resp}'
105
106
107Disable Daemon And Discover BMC After Reboot
108    [Documentation]  Discover BMC After reboot.
109    [Arguments]  ${service_type}
110
111    # Description of argument(s):
112    # service_type  BMC service type e.g.
113    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
114
115    Set AvahiDaemon Service  command=stop
116    Redfish OBMC Reboot (off)
117    Verify AvahiDaemon Service Status  message=start
118    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
119    Wait Until Keyword Succeeds  2 min  30 sec
120    ...  Verify Existence Of BMC Record From List  ${service_type}
121