@@ -113,27 +113,7 @@ def test_dhcp_single_pool_range(self):
113
113
range_1_start = inc_ip (subnet , 40 )
114
114
range_1_stop = inc_ip (subnet , 50 )
115
115
116
- self .cli_set (base_path + ['listen-interface' , interface ])
117
-
118
- self .cli_set (base_path + ['shared-network-name' , shared_net_name , 'ping-check' ])
119
-
120
- pool = base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet ]
121
- self .cli_set (pool + ['subnet-id' , '1' ])
122
- self .cli_set (pool + ['ignore-client-id' ])
123
- self .cli_set (pool + ['ping-check' ])
124
- # we use the first subnet IP address as default gateway
125
- self .cli_set (pool + ['option' , 'default-router' , router ])
126
- self .cli_set (pool + ['option' , 'name-server' , dns_1 ])
127
- self .cli_set (pool + ['option' , 'name-server' , dns_2 ])
128
- self .cli_set (pool + ['option' , 'domain-name' , domain_name ])
129
-
130
- # check validate() - No DHCP address range or active static-mapping set
131
- with self .assertRaises (ConfigSessionError ):
132
- self .cli_commit ()
133
- self .cli_set (pool + ['range' , '0' , 'start' , range_0_start ])
134
- self .cli_set (pool + ['range' , '0' , 'stop' , range_0_stop ])
135
- self .cli_set (pool + ['range' , '1' , 'start' , range_1_start ])
136
- self .cli_set (pool + ['range' , '1' , 'stop' , range_1_stop ])
116
+ self .setup_single_pool_range (range_0_start , range_0_stop , range_1_start , range_1_stop , shared_net_name )
137
117
138
118
# commit changes
139
119
self .cli_commit ()
@@ -210,6 +190,84 @@ def test_dhcp_single_pool_range(self):
210
190
# Check for running process
211
191
self .verify_service_running ()
212
192
193
+ def setup_single_pool_range (self , range_0_start , range_0_stop , range_1_start , range_1_stop , shared_net_name ):
194
+ self .cli_set (base_path + ['listen-interface' , interface ])
195
+ self .cli_set (base_path + ['shared-network-name' , shared_net_name , 'ping-check' ])
196
+
197
+ pool = base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet ]
198
+
199
+ self .cli_set (pool + ['subnet-id' , '1' ])
200
+ self .cli_set (pool + ['ignore-client-id' ])
201
+ self .cli_set (pool + ['ping-check' ])
202
+ # we use the first subnet IP address as default gateway
203
+ self .cli_set (pool + ['option' , 'default-router' , router ])
204
+ self .cli_set (pool + ['option' , 'name-server' , dns_1 ])
205
+ self .cli_set (pool + ['option' , 'name-server' , dns_2 ])
206
+ self .cli_set (pool + ['option' , 'domain-name' , domain_name ])
207
+
208
+ # check validate() - No DHCP address range or active static-mapping set
209
+ with self .assertRaises (ConfigSessionError ):
210
+ self .cli_commit ()
211
+
212
+ self .cli_set (pool + ['range' , '0' , 'start' , range_0_start ])
213
+ self .cli_set (pool + ['range' , '0' , 'stop' , range_0_stop ])
214
+ self .cli_set (pool + ['range' , '1' , 'start' , range_1_start ])
215
+ self .cli_set (pool + ['range' , '1' , 'stop' , range_1_stop ])
216
+
217
+ def test_dhcp_client_class (self ):
218
+ shared_net_name = 'SMOKE-1'
219
+
220
+ range_0_start = inc_ip (subnet , 10 )
221
+ range_0_stop = inc_ip (subnet , 20 )
222
+ range_1_start = inc_ip (subnet , 40 )
223
+ range_1_stop = inc_ip (subnet , 50 )
224
+
225
+ self .setup_single_pool_range (range_0_start , range_0_stop , range_1_start , range_1_stop , shared_net_name )
226
+
227
+ self .cli_set (base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet , 'client-class' , 'test' ])
228
+
229
+ # check validate() - Client class referenced that doesn't exist yet
230
+ with self .assertRaises (ConfigSessionError ):
231
+ self .cli_commit ()
232
+
233
+ self .cli_delete (base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet , 'client-class' , 'test' ])
234
+
235
+ self .cli_set (base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet , 'range' , '0' , 'client-class' , 'test' ])
236
+
237
+ # check validate() - Client class referenced that doesn't exist yet
238
+ with self .assertRaises (ConfigSessionError ):
239
+ self .cli_commit ()
240
+
241
+ self .cli_set (base_path + ['shared-network-name' , shared_net_name , 'subnet' , subnet , 'client-class' , 'test' ])
242
+
243
+ client_class = base_path + ['client-class' , 'test' ]
244
+ self .cli_set (client_class + ['option82' , 'circuit-id' , 'foo' ])
245
+ self .cli_set (client_class + ['option82' , 'remote-id' , 'bar' ])
246
+
247
+ self .cli_commit ()
248
+
249
+ config = read_file (KEA4_CONF )
250
+ obj = loads (config )
251
+
252
+ self .verify_config_value (
253
+ obj , ['Dhcp4' , 'client-classes' , 0 ], 'name' , 'test'
254
+ )
255
+
256
+ self .verify_config_value (
257
+ obj , ['Dhcp4' , 'client-classes' , 0 ], 'test' , 'relay4[1].hex == 0x666f6f and relay4[2].hex == 0x626172'
258
+ )
259
+
260
+ self .verify_config_value (
261
+ obj , ['Dhcp4' , 'shared-networks' , 0 , 'subnet4' , 0 ], 'client-class' , 'test'
262
+ )
263
+
264
+ self .verify_config_value (
265
+ obj , ['Dhcp4' , 'shared-networks' , 0 , 'subnet4' , 0 , 'pools' , 0 ], 'client-class' , 'test'
266
+ )
267
+
268
+ # Check for running process
269
+ self .verify_service_running ()
270
+
213
271
def test_dhcp_single_pool_options (self ):
214
272
shared_net_name = 'SMOKE-0815'
215
273
0 commit comments