blob: 6891e6e857af5fc84df2aabcc879e86e14dfb793 [file] [log] [blame]
Prashanth Kattif58cce02019-02-06 03:05:14 -06001*** Settings ***
2Documentation Network interface configuration and verification
3 ... tests.
4
George Keishing5d467552019-02-08 23:30:48 -06005Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/bmc_network_utils.robot
7Resource ../../lib/openbmc_ffdc.robot
Prashanth Katti747ce9d2019-02-07 07:23:48 -06008Library ../../lib/bmc_network_utils.py
Prashanth Kattif58cce02019-02-06 03:05:14 -06009
10Test Setup Test Setup Execution
11Test Teardown Test Teardown Execution
12
13*** Test Cases ***
14
15Get IP Address And Verify
16 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060017 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060018
19 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060020 \ Verify IP On BMC ${network_configuration['Address']}
21
Prashanth Kattif58cce02019-02-06 03:05:14 -060022Get Netmask And Verify
23 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060024 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060025
26 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060027 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
28
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060029Get Gateway And Verify
30 [Documentation] Get gateway and verify it's existence on the BMC.
31 [Tags] Get_Gateway_And_Verify
32
33 : FOR ${network_configuration} IN @{network_configurations}
34 \ Verify Gateway On BMC ${network_configuration['Gateway']}
35
36Get MAC Address And Verify
37 [Documentation] Get MAC address and verify it's existence on the BMC.
38 [Tags] Get_MAC_Address_And_Verify
39
George Keishing97c93942019-03-04 12:45:07 -060040 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060041 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
42 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060043
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060044Verify All Configured IP And Netmask
45 [Documentation] Verify all configured IP and netmask on BMC.
46 [Tags] Verify_All_Configured_IP_And_Netmask
47
48 : FOR ${network_configuration} IN @{network_configurations}
49 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
50 ... ${network_configuration['SubnetMask']}
51
Prashanth Kattif58cce02019-02-06 03:05:14 -060052*** Keywords ***
53
54Test Setup Execution
55 [Documentation] Test setup execution.
56
George Keishing97c93942019-03-04 12:45:07 -060057 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -060058
59 @{network_configurations}= Get Network Configuration
60 Set Test Variable @{network_configurations}
61
62 # Get BMC IP address and prefix length.
63 ${ip_data}= Get BMC IP Info
64 Set Test Variable ${ip_data}
65
Prashanth Katti747ce9d2019-02-07 07:23:48 -060066
Prashanth Kattif58cce02019-02-06 03:05:14 -060067Get Network Configuration
68 [Documentation] Get network configuration.
69
70 # Sample output:
71 #{
72 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
73 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
74 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
75 # "Description": "Management Network Interface",
76 # "IPv4Addresses": [
77 # {
78 # "Address": "169.254.xx.xx",
79 # "AddressOrigin": "IPv4LinkLocal",
80 # "Gateway": "0.0.0.0",
81 # "SubnetMask": "255.255.0.0"
82 # },
83 # {
84 # "Address": "xx.xx.xx.xx",
85 # "AddressOrigin": "Static",
86 # "Gateway": "xx.xx.xx.1",
87 # "SubnetMask": "xx.xx.xx.xx"
88 # }
89 # ],
90 # "Id": "eth0",
91 # "MACAddress": "xx:xx:xx:xx:xx:xx",
92 # "Name": "Manager Ethernet Interface",
93 # "SpeedMbps": 0,
94 # "VLAN": {
95 # "VLANEnable": false,
96 # "VLANId": 0
97 # }
98
George Keishing97c93942019-03-04 12:45:07 -060099 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600100 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
101 [Return] @{network_configurations}
102
George Keishing5d467552019-02-08 23:30:48 -0600103
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600104Verify IP On BMC
105 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600106 [Arguments] ${ip}
107
108 # Description of the argument(s):
109 # ip IP address to be verified.
110
111 # Get IP address details on BMC using IP command.
112 @{ip_data}= Get BMC IP Info
113 Should Contain Match ${ip_data} ${ip}/*
114 ... msg=IP address does not exist.
115
George Keishing5d467552019-02-08 23:30:48 -0600116
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600117Verify Netmask On BMC
118 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600119 [Arguments] ${netmask}
120
121 # Description of the argument(s):
122 # netmask netmask value to be verified.
123
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600124 ${prefix_length}= Netmask Prefix Length ${netmask}
125
126 Should Contain Match ${ip_data} */${prefix_length}
127 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600128
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600129Verify Gateway On BMC
130 [Documentation] Verify gateway on BMC.
131 [Arguments] ${gateway_ip}=0.0.0.0
132
133 # Description of argument(s):
134 # gateway_ip Gateway IP address.
135
136 ${route_info}= Get BMC Route Info
137
138 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
139
140 Run Keyword If '${gateway_ip}' == '0.0.0.0'
141 ... Pass Execution Gateway IP is "0.0.0.0".
142 ... ELSE
143 ... Should Contain ${route_info} ${gateway_ip}
144 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600145
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600146Verify IP And Netmask On BMC
147 [Documentation] Verify IP and netmask on BMC.
148 [Arguments] ${ip} ${netmask}
149
150 # Description of the argument(s):
151 # ip IP address to be verified.
152 # netmask netmask value to be verified.
153
154 ${prefix_length}= Netmask Prefix Length ${netmask}
155 @{ip_data}= Get BMC IP Info
156
157 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
158 Should Contain ${ip_data} ${ip_with_netmask}
159 ... msg=IP and netmask pair does not exist.
160
Prashanth Kattif58cce02019-02-06 03:05:14 -0600161Test Teardown Execution
162 [Documentation] Test teardown execution.
163
164 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600165 Redfish.Logout