xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision 7a7ae5c53e5283d8b6d688f7320f47bf3d8ab265)
1*** Settings ***
2Documentation  Network interface IPv6 configuration connected to DHCP server
3               ...   and verification tests.
4
5Resource       ../../lib/bmc_redfish_resource.robot
6Resource       ../../lib/openbmc_ffdc.robot
7Resource       ../../lib/bmc_ipv6_utils.robot
8Resource       ../../lib/bmc_network_utils.robot
9Resource       ../../lib/protocol_setting_utils.robot
10
11Library        Collections
12Library        Process
13Library        OperatingSystem
14Suite Setup     Suite Setup Execution
15Test Teardown   Test Teardown Execution
16
17Test Tags     BMC_IPv6_Config
18
19*** Variables ***
20# Remote DHCP test bed server. Leave variables EMPTY if server is configured local
21# to the test where it is running else if remote pass the server credentials
22# -v SERVER_IPv6:xx.xx.xx.xx
23# -v SERVER_USERNAME:root
24# -v SERVER_PASSWORD:*********
25
26${SERVER_USERNAME}      ${EMPTY}
27${SERVER_PASSWORD}      ${EMPTY}
28${SERVER_IPv6}          ${EMPTY}
29
30
31*** Test Cases ***
32
33Get SLAAC And Static IPv6 Address And Verify Connectivity
34    [Documentation]  Fetch the SLAAC and Static IPv6 address
35    ...    and verify ping and SSH connection.
36    [Tags]  Get_SLAAC_And_Static_IPv6_Address_And_Verify_Connectivity
37    [Template]  Get IPv6 Address And Verify Connectivity
38
39    # Address_type  channel_number
40    SLAAC           ${1}
41    Static          ${1}
42    SLAAC           ${2}
43    Static          ${2}
44
45
46Enable SSH Protocol Via IPv6 And Verify
47    [Documentation]  Enable SSH protocol via eth1 and verify.
48    [Tags]  Enable_SSH_Protocol_Via_IPv6_And_Verify
49
50    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
51    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
52    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
53    Set SSH Protocol Using IPv6 Session And Verify  ${True}
54    Verify SSH Login And Commands Work
55    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
56
57
58Disable SSH Protocol Via IPv6 And Verify
59    [Documentation]  Disable SSH protocol via IPv6 and verify.
60    [Tags]  Disable_SSH_Protocol_Via_IPv6_And_Verify
61    [Teardown]  Set SSH Protocol Using IPv6 Session And Verify  ${True}
62
63    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
64    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
65    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
66
67    Set SSH Protocol Using IPv6 Session And Verify  ${False}
68
69    # Verify SSH Login And Commands Work.
70    ${status}=  Run Keyword And Return Status
71    ...    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
72    Should Be Equal As Strings  ${status}  False
73    ...  msg=SSH Login and commands are working after disabling SSH via IPv6.
74
75    # Verify SSH Connection Via IPv6.
76    ${status}=  Run Keyword And Return Status
77    ...  Verify SSH Login And Commands Work
78    Should Be Equal As Strings  ${status}  False
79    ...  msg=SSH Login and commands are working after disabling SSH.
80
81
82*** Keywords ***
83
84Suite Setup Execution
85    [Documentation]  Do suite setup execution.
86
87    Redfish.Login
88    ${active_channel_config}=  Get Active Channel Config
89    Set Suite Variable  ${active_channel_config}
90    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
91    Set Suite variable  ${ethernet_interface}
92
93
94Test Teardown Execution
95    [Documentation]  Test teardown execution.
96
97    FFDC On Test Case Fail
98    Redfish.Logout
99    RedfishIPv6.Logout
100
101
102Wait For IPv6 Host To Ping
103    [Documentation]  Verify that the IPv6 host responds successfully to ping.
104    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
105    ...          ${interval}=5 sec  ${expected_rc}=${0}
106    # Description of argument(s):
107    # host         The IPv6 address of the host to ping.
108    # timeout      Maximum time to wait for the host to respond to ping.
109    # interval     Time to wait between ping attempts.
110    # expected_rc  Expected return code of ping command.
111    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
112
113
114Ping Host Over IPv6
115    [Documentation]  Ping6 the given host.
116    [Arguments]     ${host}  ${expected_rc}=${0}
117    # Description of argument(s):
118    # host           IPv6 address of the host to ping.
119    # expected_rc    Expected return code of ping command.
120    Should Not Be Empty    ${host}   msg=No host provided.
121    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
122    Log     RC: ${rc}\nOutput:\n${output}
123    Should Be Equal     ${rc}   ${expected_rc}
124
125
126Check IPv6 Connectivity
127    [Documentation]  Check ping6 status and verify.
128    [Arguments]  ${OPENBMC_HOST_IPv6}
129
130    # Description of argument(s):
131    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
132
133    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
134    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
135
136
137Verify SSH Connection Via IPv6
138    [Documentation]  Verify connectivity to the IPv6 host via SSH.
139    [Arguments]  ${OPENBMC_HOST_IPv6}
140
141    # Description of argument(s):
142    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
143
144    IF  '${SERVER_USERNAME}' == '${EMPTY}'
145        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
146        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
147    ELSE
148        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
149        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
150        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
151    END
152
153
154Set SSH Protocol Using IPv6 Session And Verify
155    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
156    [Arguments]  ${enable_value}=${True}
157
158    # Description of argument(s}:
159    # enable_value  Enable or disable SSH, e.g. (true, false).
160
161    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
162    ${data}=  Create Dictionary  SSH=${ssh_state}
163
164    RedfishIPv6.Login
165    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
166    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
167
168    # Wait for new values to take effect.
169    Sleep  30s
170
171    # Verify SSH Protocol State Via IPv6
172    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
173    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
174    ...  msg=Protocol states are not matching.
175
176
177Connect BMC Using IPv6 Address
178    [Documentation]  Import bmc_redfish library with IPv6 configuration.
179    [Arguments]  ${OPENBMC_HOST_IPv6}
180
181    # Description of argument(s):
182    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
183
184    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
185    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
186
187
188Get IPv6 Address And Verify Connectivity
189    [Documentation]  Get IPv6 address and verify connectivity.
190    [Arguments]  ${ipv6_adress_type}  ${channel_number}
191
192    # Description of argument(s):
193    # ipv6_adress_type   Type of IPv6 address(slaac/static).
194    # channel_number     Ethernet channel number, 1(eth0) or 2(eth1).
195
196    @{ipv6_addressorigin_list}  ${ipv6_addr}=
197    ...  Get Address Origin List And Address For Type  ${ipv6_adress_type}  ${channel_number}
198    IF  '${SERVER_USERNAME}' != '${EMPTY}'
199        Check IPv6 Connectivity  ${ipv6_addr}
200    ELSE
201        Wait For IPv6 Host To Ping  ${ipv6_addr}
202    END
203    Verify SSH Connection Via IPv6  ${ipv6_addr}
204