1*** Settings ***
2Documentation        Test to discover the BMC.
3
4Variables            ../../data/variables.py
5Library              SSHLibrary
6Library              ../../lib/external_intf/management_console_utils.py
7Library              ../../lib/gen_robot_print.py
8Library              ../../lib/gen_print.py
9Resource             ../../syslib/utils_os.robot
10
11Suite Setup          Suite Setup Execution
12
13*** Test Cases ***
14
15Discover BMC With Different Service Type
16    [Documentation]  Discover all the BMC with different service type support.
17    [Tags]  Discover_BMC_With_Different_Service_Type
18    [Template]  Discover BMC With Service Type
19
20    # Service type
21    _obmc_rest._tcp
22    _obmc_redfish._tcp
23
24
25*** Keywords ***
26
27Suite Setup Execution
28    [Documentation]  Do the suite setup.
29
30    Should Not Be Empty  ${AVAHI_CLIENT}
31    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
32    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
33    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
34    Check Avahi Package
35
36
37Check Avahi Package
38    [Documentation]  To check for avahi-tools package.
39
40    # Expected command output as below.
41    # avahi-tools-0.6.31-19.el7.x86_64
42
43    ${command}=  Set Variable  rpm -qa | grep avahi-tools
44    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
45    Should Be Empty  ${stderr}
46    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
47
48
49Discover BMC With Service Type
50    [Documentation]  To get the discoverd BMC list.
51    [Arguments]  ${service_type}
52
53    # Description of argument(s):
54    # service_type    BMC service type e.g.
55    #                 (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
56
57    # bmc_list:
58    # [1]:
59    #    [service]:          _obmc_XXXX._tcp
60    #    [hostname]:         System Name
61    #    [address]:          XXX.XXX.XXX.XXX
62    #    [port]:             XXX
63    #    [txt]:
64    # [2]:
65    #    [service]:          _obmc_XXXX._tcp
66    #    [hostname]:         System Name
67    #    [address]:          XXX.XXX.XXX.XXX
68    #    [port]:             XXX
69    #    [txt]:
70
71    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
72    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
73    Print Timen  Exception message is ${exc_msg}
74    Should Not Be Empty  ${bmc_list}
75    Rprint Vars  bmc_list
76