blob: e817619c348a006be0380fff847988d665c1e377 [file] [log] [blame]
Rahul Maheshwari757d80c2016-10-17 01:09:55 -05001*** Settings ***
2
3Documentation This testsuite is for testing network setting
4... of host OS.
5
6Resource ../lib/rest_client.robot
7Resource ../lib/ipmi_client.robot
8Resource ../lib/utils.robot
9Resource ../lib/openbmc_ffdc.robot
10Library ../lib/utilities.py
11
12Suite Setup Open Connection And Log In
13Suite Teardown Close All Connections
14
15Test Teardown Post Test Execution
16
17*** Variables ***
18${SET_ADDR_PREFIX} 0x00 0x08 0x61 0x80 0x21 0x70 0x62 0x21 0x00 0x01 0x06 0x04
19${STATIC} 0x00 0x01 #equivalent address type 1
20${DHCP} 0x00 0x00 #equivalent address type 0
21${CLEAR_ADDR} 0x00 0x08 0x61 0x80 0x00 0x00 0x00 0x00
22${INVALID_MAC} f4:52:14
23
24*** Test Cases ***
25
26Set Static Address With REST
27 [Documentation] This testcase is to set static address for host's network
28 ... setting using REST. Later verify using REST
29 ... that it is set correctly.
30 [Tags] Set_Static_Address_With_REST
31
32 ${ip_address}= utilities.random_ip
33 ${gateway}= utilities.random_ip
34 ${mac_address}= utilities.random_mac
35 ${subnet}= Evaluate random.randint(0, 32) modules=random
36
37 ${settings}= Catenate SEPARATOR=
38 ... ipaddress=${ip_address},prefix=${subnet},
39 ... gateway=${gateway},mac=${mac_address},addr_type=1
40
41 Set Network Override Setting ${settings}
42
43 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
44 Should Be Equal ${resp} ${settings}
45
46
47Set DHCP Address With REST
48 [Documentation] This testcase is to set dhcp address for host's network
49 ... setting using REST. Later verify using REST that it
50 ... is set correctly.
51 [Tags] Set_DHCP_Address_With_REST
52
53 ${mac_address}= utilities.random_mac
54
55 ${settings}= Catenate SEPARATOR=
56 ... ipaddress=,prefix=,gateway=,mac=${mac_address},addr_type=0
57
58 Set Network Override Setting ${settings}
59
60 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
61 Should Be Equal ${resp} ${settings}
62
63
64Set Static Address With IPMI
65 [Documentation] This testcase is to set static address for host's network
66 ... setting using IPMI. Later verify using REST that it is
67 ... set correctly.
68 [Tags] Set_Static_Address_With_IPMI
69
70 ${ip_address}= utilities.random_ip
71 ${gateway}= utilities.random_ip
72 ${mac_address}= utilities.random_mac
73 ${subnet}= Evaluate random.randint(0, 32) modules=random
74
75 ${mac_address_hex}= Mac Address To Hex String ${mac_address}
76 ${ip_address_hex}= IP Address To Hex String ${ip_address}
77 ${gateway_hex}= IP Address To Hex String ${gateway}
78 ${subnet_hex}= Convert To Hex ${subnet} prefix=0x
79 ... lowercase=yes
80
81 ${ipmi_raw_cmd}= Catenate SEPARATOR=
82 ... ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${STATIC}${SPACE}
83 ... ${ip_address_hex}${SPACE}${subnet_hex}${SPACE}${gateway_hex}
84
85 Run IPMI command ${ipmi_raw_cmd}
86
87 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
88
89 ${settings}= Catenate SEPARATOR=
90 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
91 ... mac=${mac_address},addr_type=1
92
93 Should Be Equal ${resp} ${settings}
94
95
96Set DHCP Address With IPMI
97 [Documentation] This testcase is to set dhcp address for host's network
98 ... setting using IPMI. Later verify using REST that it is
99 ... set correctly.
100 [Tags] Set_DHCP_Address_With_IPMI
101
102 ${mac_address}= utilities.random_mac
103 ${mac_address_hex}= Mac Address To Hex String ${mac_address}
104
105 ${ipmi_raw_cmd}= Catenate SEPARATOR=
106 ... ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${DHCP}
107 Run IPMI command ${ipmi_raw_cmd}
108
109 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
110 Should Contain ${resp} addr_type=0
111
112
113Clear Address With IPMI
114 [Documentation] This testcase is to clear host's network setting
115 ... using IPMI. Later verify using REST that it is
116 ... cleared.
117 [Tags] Clear_Address_With_IPMI
118
119 Run IPMI command ${CLEAR_ADDR}
120
121 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
122 Should Be Equal ${resp} ipaddress=,prefix=,gateway=,mac=,addr_type=
123
124
125Set Invalid Address With REST
126 [Documentation] This testcase is to verify that proper error message is
127 ... prompted by REST with invalid mac address for
128 ... host's network setting.
129 [Tags] Set_Invalid_Address_With_REST
130
131 ${ip_address}= utilities.random_ip
132 ${gateway}= utilities.random_ip
133 ${subnet}= Evaluate random.randint(0, 32) modules=random
134
135 ${invalid_settings}= Catenate SEPARATOR=
136 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
137 ... mac=${INVALID_MAC},addr_type=1
138
139 ${resp}= Set Network Override Setting ${invalid_settings}
140 Should Be Equal ${resp} error
141
142
143Set Invalid Address With IPMI
144 [Documentation] This testcase is to verify that invalid mac address for
145 ... host's network setting can not be set by IPMI.
146 [Tags] Set_Invalid_Address_With_IPMI
147
148 ${ip_address}= utilities.random_ip
149 ${gateway}= utilities.random_ip
150 ${subnet}= Evaluate random.randint(0, 32) modules=random
151
152 ${ip_address_hex}= IP Address To Hex String ${ip_address}
153 ${gateway_hex}= IP Address To Hex String ${gateway}
154 ${invalid_mac_hex}= Mac Address To Hex String ${INVALID_MAC}
155 ${subnet_hex}= Convert To Hex ${subnet} prefix=0x
156 ... lowercase=yes
157
158 ${ipmi_raw_cmd}= Catenate SEPARATOR=
159 ... ${SET_ADDR_PREFIX}${SPACE}${invalid_mac_hex}${SPACE}${STATIC}${SPACE}
160 ... ${ip_address_hex}${SPACE}${subnet_hex}${SPACE}${gateway_hex}
161 Run IPMI command ${ipmi_raw_cmd}
162
163 ${invalid_settings}= Catenate SEPARATOR=
164 ... ipaddress=${ip_address},prefix=${subnet},gateway=${gateway},
165 ... mac=${INVALID_MAC},addr_type=1
166
167 ${resp}= Read Attribute /org/openbmc/settings/host0 network_config
168 Should Not Be Equal ${resp} ${invalid_settings}
169
170
171*** Keywords ***
172
173Set Network Override Setting
174 [Documentation] Set host's network settings with passed arguments and
175 ... return its status.
176 ... Description of arguments:
177 ... settings Network settings which need to be set
178 [Arguments] ${settings}
179 ${host_network}= Set Variable ${settings}
180 ${valueDict}= create dictionary data=${host_network}
181 ${resp}= OpenBMC Put Request
182 ... /org/openbmc/settings/host0/attr/network_config data=${valueDict}
183 ${jsondata}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600184 [Return] ${jsondata['status']}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500185
186Post Test Execution
187 [Documentation] Perform operations after test execution. Captures FFDC
188 ... in case of test case failure and sets defaults values
189 ... for host's network settings.
190
191 FFDC On Test Case Fail
192
193 Run IPMI command ${CLEAR_ADDR}