xref: /openbmc/openbmc-test-automation/redfish/managers/test_bmc_config_ipv6.robot (revision d95d917db7d7422c69a3c991a5bbda9d1a9cff2c)
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 Address And Verify Connectivity
34    [Documentation]  Fetch the SLAAC address and verify ping and SSH connection.
35    [Tags]  Get_SLAAC_Address_And_Verify_Connectivity
36
37    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
38    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
39    IF  '${SERVER_USERNAME}' != '${EMPTY}'
40        Check IPv6 Connectivity  ${ipv6_slaac_addr}
41    ELSE
42        Wait For IPv6 Host To Ping  ${ipv6_slaac_addr}
43    END
44    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
45
46
47Enable SSH Protocol Via IPv6 And Verify
48    [Documentation]  Enable SSH protocol via eth1 and verify.
49    [Tags]  Enable_SSH_Protocol_Via_IPv6_And_Verify
50
51    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
52    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
53    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
54    Set SSH Protocol Using IPv6 Session And Verify  ${True}
55    Verify SSH Login And Commands Work
56    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
57
58
59Disable SSH Protocol Via IPv6 And Verify
60    [Documentation]  Disable SSH protocol via IPv6 and verify.
61    [Tags]  Disable_SSH_Protocol_Via_IPv6_And_Verify
62    [Teardown]  Set SSH Protocol Using IPv6 Session And Verify  ${True}
63
64    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=
65    ...  Get Address Origin List And Address For Type  SLAAC  ${2}
66    Connect BMC Using IPv6 Address  ${ipv6_slaac_addr}
67
68    Set SSH Protocol Using IPv6 Session And Verify  ${False}
69
70    # Verify SSH Login And Commands Work.
71    ${status}=  Run Keyword And Return Status
72    ...    Verify SSH Connection Via IPv6  ${ipv6_slaac_addr}
73    Should Be Equal As Strings  ${status}  False
74    ...  msg=SSH Login and commands are working after disabling SSH via IPv6.
75
76    # Verify SSH Connection Via IPv6.
77    ${status}=  Run Keyword And Return Status
78    ...  Verify SSH Login And Commands Work
79    Should Be Equal As Strings  ${status}  False
80    ...  msg=SSH Login and commands are working after disabling SSH.
81
82
83*** Keywords ***
84
85Suite Setup Execution
86    [Documentation]  Do suite setup execution.
87
88    Redfish.Login
89    ${active_channel_config}=  Get Active Channel Config
90    Set Suite Variable  ${active_channel_config}
91    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
92    Set Suite variable  ${ethernet_interface}
93
94
95Test Teardown Execution
96    [Documentation]  Test teardown execution.
97
98    FFDC On Test Case Fail
99    Redfish.Logout
100    RedfishIPv6.Logout
101
102
103Wait For IPv6 Host To Ping
104    [Documentation]  Verify that the IPv6 host responds successfully to ping.
105    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}sec
106    ...          ${interval}=5 sec  ${expected_rc}=${0}
107    # Description of argument(s):
108    # host         The IPv6 address of the host to ping.
109    # timeout      Maximum time to wait for the host to respond to ping.
110    # interval     Time to wait between ping attempts.
111    # expected_rc  Expected return code of ping command.
112    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host Over IPv6  ${host}  ${expected_rc}
113
114
115Ping Host Over IPv6
116    [Documentation]  Ping6 the given host.
117    [Arguments]     ${host}  ${expected_rc}=${0}
118    # Description of argument(s):
119    # host           IPv6 address of the host to ping.
120    # expected_rc    Expected return code of ping command.
121    Should Not Be Empty    ${host}   msg=No host provided.
122    ${rc}   ${output}=     Run and return RC and Output    ping6 -c 4 ${host}
123    Log     RC: ${rc}\nOutput:\n${output}
124    Should Be Equal     ${rc}   ${expected_rc}
125
126
127Check IPv6 Connectivity
128    [Documentation]  Check ping6 status and verify.
129    [Arguments]  ${OPENBMC_HOST_IPv6}
130
131    # Description of argument(s):
132    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
133
134    Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}
135    Wait For IPv6 Host To Ping  ${OPENBMC_HOST_IPv6}  30 secs
136
137
138Verify SSH Connection Via IPv6
139    [Documentation]  Verify connectivity to the IPv6 host via SSH.
140    [Arguments]  ${OPENBMC_HOST_IPv6}
141
142    # Description of argument(s):
143    # OPENBMC_HOST_IPv6   IPv6 address to check connectivity.
144
145    IF  '${SERVER_USERNAME}' == '${EMPTY}'
146        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
147        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
148    ELSE
149        Open Connection And Log In  ${SERVER_USERNAME}  ${SERVER_PASSWORD}  host=${SERVER_IPv6}  alias=IPv6Conn
150        SSHLibrary.Open Connection  ${OPENBMC_HOST_IPv6}
151        SSHLibrary.Login  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  jumphost_index_or_alias=IPv6Conn
152    END
153
154
155Set SSH Protocol Using IPv6 Session And Verify
156    [Documentation]  Enable or disable SSH protocol via IPv6 and verify.
157    [Arguments]  ${enable_value}=${True}
158
159    # Description of argument(s}:
160    # enable_value  Enable or disable SSH, e.g. (true, false).
161
162    ${ssh_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
163    ${data}=  Create Dictionary  SSH=${ssh_state}
164
165    RedfishIPv6.Login
166    RedfishIPv6.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
167    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
168
169    # Wait for new values to take effect.
170    Sleep  30s
171
172    # Verify SSH Protocol State Via IPv6
173    ${resp}=  RedfishIPv6.Get  ${REDFISH_NW_PROTOCOL_URI}
174    Should Be Equal As Strings  ${resp.dict['SSH']['ProtocolEnabled']}  ${enable_value}
175    ...  msg=Protocol states are not matching.
176
177
178Connect BMC Using IPv6 Address
179    [Documentation]  Import bmc_redfish library with IPv6 configuration.
180    [Arguments]  ${OPENBMC_HOST_IPv6}
181
182    # Description of argument(s):
183    # OPENBMC_HOST_IPv6  IPv6 address of the BMC.
184
185    Import Library  ${CURDIR}/../../lib/bmc_redfish.py  https://[${OPENBMC_HOST_IPv6}]:${HTTPS_PORT}
186    ...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  AS  RedfishIPv6
187