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 Release
54    [Documentation]  Discover BMC, when firmware update occurs for same release.
55    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Release
56    [Template]  Discover BMC Pre And Post Firmware Update
57
58    # Service type   Service type        status
59    _obmc_rest._tcp  _obmc_redfish._tcp  True
60
61
62Discover BMC Pre And Post Firmware Update Of Different Release
63    [Documentation]  Discover BMC, when firmware update occurs for different release.
64    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Different_Release
65    [Template]  Discover BMC Pre And Post Firmware Update
66
67    # Service type   Service type        status
68    _obmc_rest._tcp  _obmc_redfish._tcp  True
69
70
71Discover BMC Fail After Firmware Update Of Different Release
72    [Documentation]  Discover BMC fail, when firmware update occurs for different release.
73    [Tags]  Discover_BMC_Fail_After_Firmware_Update_Of_Different_Release
74    [Template]  Discover BMC Pre And Post Firmware Update
75
76    # Service type   Service type        status
77    _obmc_rest._tcp  _obmc_redfish._tcp  False
78
79
80Discover BMC Pre And Post When Host Boot InProgress
81    [Documentation]  Discover BMC, when Host boot in progress.
82    [Tags]  Discover_BMC_Pre_And_Post_When_Host_Boot_InProgress
83    [Template]  Discover BMC Pre And Post When Host Boot
84
85    # Service type   Service type
86    _obmc_rest._tcp  _obmc_redfish._tcp
87
88*** Keywords ***
89
90Suite Setup Execution
91    [Documentation]  Do the suite setup.
92
93    Should Not Be Empty  ${AVAHI_CLIENT}
94    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
95    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
96    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
97    Check Avahi Package
98    Redfish.Login
99
100
101Check Avahi Package
102    [Documentation]  To check for avahi-tools package.
103
104    # Expected command output as below.
105    # avahi-tools-0.6.31-19.el7.x86_64
106
107    ${command}=  Set Variable  rpm -qa | grep avahi-tools
108    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
109    Should Be Empty  ${stderr}
110    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
111
112
113Discover BMC With Service Type
114    [Documentation]  To get the discoverd BMC list.
115    [Arguments]  ${service_type}
116
117    # Description of argument(s):
118    # service_type  BMC service type e.g.
119    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
120
121    # bmc_list:
122    # [1]:
123    #    [service]:          _obmc_XXXX._tcp
124    #    [hostname]:         System Name
125    #    [address]:          XXX.XXX.XXX.XXX
126    #    [port]:             XXX
127    #    [txt]:
128    # [2]:
129    #    [service]:          _obmc_XXXX._tcp
130    #    [hostname]:         System Name
131    #    [address]:          XXX.XXX.XXX.XXX
132    #    [port]:             XXX
133    #    [txt]:
134
135    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
136    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
137    Print Timen  Exception message is ${exc_msg}
138    Should Not Be Empty  ${bmc_list}
139    Rprint Vars  bmc_list
140    [Return]  ${bmc_list}
141
142
143Verify Existence Of BMC Record From List
144    [Documentation]  Verify the existence of BMC record from list of BMC records.
145    [Arguments]  ${service_type}
146
147    # Description of argument(s):
148    # service_type  BMC service type e.g.
149    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
150
151    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
152    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
153    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
154    Should Be True  'True' == '${resp}'
155
156
157Set Daemon And Discover BMC After Reboot
158    [Documentation]  Discover BMC After reboot.
159    [Arguments]  ${service_type}  ${skip}=False
160
161    # Description of argument(s):
162    # service_type  BMC service type e.g.
163    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
164    # skip          Default value set to False.
165    #               If the value is True, Disable the AvahiDaemon.
166    #               If the value is False, skip the step to disable the AvahiDaemon.
167
168    Verify Existence Of BMC Record From List  ${service_type}
169    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
170    Redfish OBMC Reboot (off)
171    Verify AvahiDaemon Service Status  message=start
172    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
173    Wait Until Keyword Succeeds  2 min  30 sec
174    ...  Verify Existence Of BMC Record From List  ${service_type}
175
176
177Discover BMC Pre And Post Firmware Update
178    [Documentation]  Discover BMC, After code update.
179    [Arguments]  ${service_type1}  ${service_type2}
180
181    # Description of argument(s):
182    # service_type     BMC service type e.g.
183    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
184
185    Valid File Path  IMAGE_FILE_PATH
186    Verify Existence Of BMC Record From List  ${service_type1}
187    Verify Existence Of BMC Record From List  ${service_type2}
188    Redfish Update Firmware  apply_time=Immediate   image_type=BMC image
189    ${keyword_status}=  Run Keyword And Return Status
190    ...  Verify Existence Of BMC Record From List  ${service_type1}
191    Should Be Equal  '${status}'  '${keyword_status}'
192    ${keyword_status}=  Run Keyword And Return Status
193    ...  Verify Existence Of BMC Record From List  ${service_type2}
194    Should Be Equal  '${status}'  '${keyword_status}'
195
196
197Discover BMC Pre And Post When Host Boot
198    [Documentation]  Discover BMC, when host boot progress.
199    [Arguments]  ${service_type1}  ${service_type2}
200
201    # Description of argument(s):
202    # service_type     BMC service type e.g.
203    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
204
205    Verify Existence Of BMC Record From List  ${service_type1}
206    Verify Existence Of BMC Record From List  ${service_type2}
207    Redfish Power Off  stack_mode=skip
208    Get Host Power State
209    Redfish Power Operation  reset_type=On
210    Sleep  15s
211    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
212    FOR  ${index}  IN RANGE  10
213        Sleep  3s
214        Verify Existence Of BMC Record From List  ${service_type1}
215        Verify Existence Of BMC Record From List  ${service_type2}
216    END
217    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Booted
218