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/redfish_code_update_utils.robot
13Resource             ../../lib/boot_utils.robot
14Resource             ../../syslib/utils_os.robot
15
16Suite Setup          Suite Setup Execution
17Suite Teardown       Redfish.Logout
18Test Setup           Printn
19Test Teardown        FFDC On Test Case Fail
20
21*** Test Cases ***
22
23Discover BMC With Different Service Type
24    [Documentation]  Discover all the BMC with different service type support.
25    [Tags]  Discover_BMC_With_Different_Service_Type
26    [Template]  Discover BMC With Service Type
27
28    # Service type
29    _obmc_rest._tcp
30    _obmc_redfish._tcp
31
32
33Discover BMC Pre And Post Reboot
34    [Documentation]  Discover BMC before and after reboot.
35    [Tags]  Discover_BMC_Pre_And_Post_Reboot
36    [Template]  Set Daemon And Discover BMC After Reboot
37
38    # Service type
39    _obmc_rest._tcp
40    _obmc_redfish._tcp
41
42
43Disable AvahiDaemon And Discover BMC After Reboot
44    [Documentation]  BMC should be discoverable in next reboot even after disabling Avahi daemon.
45    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
46    [Template]  Set Daemon And Discover BMC After Reboot
47
48    # Service type       skip
49    _obmc_rest._tcp      True
50    _obmc_redfish._tcp   True
51
52
53Discover BMC Pre And Post Firmware Update Of Same Build
54    [Documentation]  Discover BMC, when code update occurs for same build.
55    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Build
56    [Template]  Discover BMC Pre And Post Firmware Update
57
58    # Service type   Service type
59    _obmc_rest._tcp  _obmc_redfish._tcp
60
61
62Discover BMC Pre And Post Firmware Update Of Different Build
63    [Documentation]  Discover BMC, when code update occurs for different release.
64    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Different_Build
65    [Template]  Discover BMC Pre And Post Firmware Update
66
67    # Service type   Service type
68    _obmc_rest._tcp  _obmc_redfish._tcp
69
70
71Discover BMC Pre And While Host Boot InProgress
72    [Documentation]  Discover BMC, while Host boot in progress.
73    [Tags]  Discover_BMC_Pre_And_While_Host_Boot_InProgress
74    [Template]  Discover BMC Before And During Host Boot
75
76    # Service type   Service type
77    _obmc_rest._tcp  _obmc_redfish._tcp
78
79*** Keywords ***
80
81Suite Setup Execution
82    [Documentation]  Do the suite setup.
83
84    Should Not Be Empty  ${AVAHI_CLIENT}
85    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
86    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
87    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
88    Check Avahi Package
89    Redfish.Login
90
91
92Check Avahi Package
93    [Documentation]  To check for avahi-tools package.
94
95    # Expected command output as below.
96    # avahi-tools-0.6.31-19.el7.x86_64
97
98    ${command}=  Set Variable  rpm -qa | grep avahi-tools
99    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
100    Should Be Empty  ${stderr}
101    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
102
103
104Discover BMC With Service Type
105    [Documentation]  To get the discoverd BMC list.
106    [Arguments]  ${service_type}
107
108    # Description of argument(s):
109    # service_type  BMC service type e.g.
110    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
111
112    # bmc_list:
113    # [1]:
114    #    [service]:          _obmc_XXXX._tcp
115    #    [hostname]:         System Name
116    #    [address]:          XXX.XXX.XXX.XXX
117    #    [port]:             XXX
118    #    [txt]:
119    # [2]:
120    #    [service]:          _obmc_XXXX._tcp
121    #    [hostname]:         System Name
122    #    [address]:          XXX.XXX.XXX.XXX
123    #    [port]:             XXX
124    #    [txt]:
125
126    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
127    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
128    Print Timen  Exception message is ${exc_msg}
129    Should Not Be Empty  ${bmc_list}
130    Rprint Vars  bmc_list
131    [Return]  ${bmc_list}
132
133
134Verify Existence Of BMC Record From List
135    [Documentation]  Verify the existence of BMC record from list of BMC records.
136    [Arguments]  ${service_type}
137
138    # Description of argument(s):
139    # service_type  BMC service type e.g.
140    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
141
142    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
143    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
144    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
145    Should Be True  'True' == '${resp}'
146
147
148Set Daemon And Discover BMC After Reboot
149    [Documentation]  Discover BMC After reboot.
150    [Arguments]  ${service_type}  ${skip}=False
151
152    # Description of argument(s):
153    # service_type  BMC service type e.g.
154    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
155    # skip          Default value set to False.
156    #               If the value is True, Disable the AvahiDaemon.
157    #               If the value is False, skip the step to disable the AvahiDaemon.
158
159    Verify Existence Of BMC Record From List  ${service_type}
160    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
161    Redfish OBMC Reboot (off)
162    Verify AvahiDaemon Service Status  message=start
163    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
164    Wait Until Keyword Succeeds  2 min  30 sec
165    ...  Verify Existence Of BMC Record From List  ${service_type}
166
167
168Discover BMC Pre And Post Firmware Update
169    [Documentation]  Discover BMC, After code update.
170    [Arguments]  ${service_type1}  ${service_type2}
171
172    # Description of argument(s):
173    # service_type     BMC service type e.g.
174    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
175
176    Valid File Path  IMAGE_FILE_PATH
177    Verify Existence Of BMC Record From List  ${service_type1}
178    Verify Existence Of BMC Record From List  ${service_type2}
179    Redfish Update Firmware  apply_time=Immediate   image_type=BMC image
180    Verify Existence Of BMC Record From List  ${service_type1}
181    Verify Existence Of BMC Record From List  ${service_type2}
182
183
184Discover BMC Before And During Host Boot
185    [Documentation]  Discover BMC, when host boot in progress.
186    [Arguments]  ${service_type1}  ${service_type2}
187
188    # Description of argument(s):
189    # service_type     BMC service type e.g.
190    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
191
192    Verify Existence Of BMC Record From List  ${service_type1}
193    Verify Existence Of BMC Record From List  ${service_type2}
194    Redfish Power Off  stack_mode=skip
195    Get Host Power State
196    Redfish Power Operation  reset_type=On
197    Sleep  15s
198    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
199    FOR  ${index}  IN RANGE  10
200        Sleep  3s
201        Verify Existence Of BMC Record From List  ${service_type1}
202        Verify Existence Of BMC Record From List  ${service_type2}
203    END
204    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Booted
205