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
17Test Teardown        FFDC On Test Case Fail
18
19*** Test Cases ***
20
21Discover BMC With Different Service Type
22    [Documentation]  Discover all the BMC with different service type support.
23    [Tags]  Discover_BMC_With_Different_Service_Type
24    [Template]  Discover BMC With Service Type
25
26    # Service type
27    _obmc_rest._tcp
28    _obmc_redfish._tcp
29
30
31Discover BMC Pre And Post Reboot
32    [Documentation]  Discover BMC before and after reboot.
33    [Tags]  Discover_BMC_Pre_And_Post_Reboot
34    [Template]  Set Daemon And Discover BMC After Reboot
35
36    # Service type
37    _obmc_rest._tcp
38    _obmc_redfish._tcp
39
40
41Disable AvahiDaemon And Discover BMC After Reboot
42    [Documentation]  BMC should be discoverable in next reboot even after disabling Avahi deamon.
43    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
44    [Template]  Set Daemon And Discover BMC After Reboot
45
46    # Service type       skip
47    _obmc_rest._tcp      True
48    _obmc_redfish._tcp   True
49
50
51Discover BMC Pre And Post Firmware Update Of Same Build
52    [Documentation]  Discover BMC, when code update occurs for same build.
53    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Build
54    [Template]  Discover BMC Pre And Post Firmware Update
55
56    # Service type   Service type
57    _obmc_rest._tcp  _obmc_redfish._tcp
58
59*** Keywords ***
60
61Suite Setup Execution
62    [Documentation]  Do the suite setup.
63
64    Should Not Be Empty  ${AVAHI_CLIENT}
65    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
66    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
67    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
68    Check Avahi Package
69
70
71Check Avahi Package
72    [Documentation]  To check for avahi-tools package.
73
74    # Expected command output as below.
75    # avahi-tools-0.6.31-19.el7.x86_64
76
77    ${command}=  Set Variable  rpm -qa | grep avahi-tools
78    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
79    Should Be Empty  ${stderr}
80    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
81
82
83Discover BMC With Service Type
84    [Documentation]  To get the discoverd BMC list.
85    [Arguments]  ${service_type}
86
87    # Description of argument(s):
88    # service_type  BMC service type e.g.
89    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
90
91    # bmc_list:
92    # [1]:
93    #    [service]:          _obmc_XXXX._tcp
94    #    [hostname]:         System Name
95    #    [address]:          XXX.XXX.XXX.XXX
96    #    [port]:             XXX
97    #    [txt]:
98    # [2]:
99    #    [service]:          _obmc_XXXX._tcp
100    #    [hostname]:         System Name
101    #    [address]:          XXX.XXX.XXX.XXX
102    #    [port]:             XXX
103    #    [txt]:
104
105    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
106    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
107    Print Timen  Exception message is ${exc_msg}
108    Should Not Be Empty  ${bmc_list}
109    Rprint Vars  bmc_list
110    [Return]  ${bmc_list}
111
112
113Verify Existence Of BMC Record From List
114    [Documentation]  Verify the existence of BMC record from list of BMC records.
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}=  Discover BMC With Service Type  ${service_type}
122    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
123    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
124    Should Be True  'True' == '${resp}'
125
126
127Set Daemon And Discover BMC After Reboot
128    [Documentation]  Discover BMC After reboot.
129    [Arguments]  ${service_type}  ${skip}=False
130
131    # Description of argument(s):
132    # service_type  BMC service type e.g.
133    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
134    # skip          Default value set to False.
135    #               If the value is True, Disable the AvahiDaemon.
136    #               If the value is False, skip the step to disable the AvahiDaemon.
137
138    Verify Existence Of BMC Record From List  ${service_type}
139    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
140    Redfish OBMC Reboot (off)
141    Verify AvahiDaemon Service Status  message=start
142    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
143    Wait Until Keyword Succeeds  2 min  30 sec
144    ...  Verify Existence Of BMC Record From List  ${service_type}
145
146
147Discover BMC Pre And Post Firmware Update
148    [Documentation]  Discover BMC, After code update.
149    [Arguments]  ${service_type1}  ${service_type2}
150
151    # Description of argument(s):
152    # service_type  BMC service type e.g.
153    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
154
155    Valid File Path  IMAGE_FILE_PATH
156    Verify Existence Of BMC Record From List  ${service_type1}
157    Verify Existence Of BMC Record From List  ${service_type2}
158    Redfish.Login
159    Redfish Update Firmware  apply_time=Immediate   image_type=BMC image
160    Verify Existence Of BMC Record From List  ${service_type1}
161    Verify Existence Of BMC Record From List  ${service_type2}
162