@@ -238,48 +238,56 @@ def test_connect_with_links(self):
238
238
239
239
@requires_api_version ('1.22' )
240
240
def test_connect_with_ipv4_address (self ):
241
- net_name , net_id = self .create_network ()
241
+ net_name , net_id = self .create_network (
242
+ ipam = create_ipam_config (
243
+ driver = 'default' ,
244
+ pool_configs = [
245
+ create_ipam_pool (
246
+ subnet = "172.28.0.0/16" , iprange = "172.28.5.0/24" ,
247
+ gateway = "172.28.5.254"
248
+ )
249
+ ]
250
+ )
251
+ )
242
252
243
253
container = self .create_and_start (
244
254
host_config = self .client .create_host_config (network_mode = net_name ))
245
255
246
256
self .client .disconnect_container_from_network (container , net_name )
247
257
self .client .connect_container_to_network (
248
- container , net_name ,
249
- ipv4_address = '192.168.0.1' )
258
+ container , net_name , ipv4_address = '172.28.5.24'
259
+ )
250
260
251
261
container_data = self .client .inspect_container (container )
262
+ net_data = container_data ['NetworkSettings' ]['Networks' ][net_name ]
252
263
self .assertEqual (
253
- container_data ['NetworkSettings' ]['Networks' ][net_name ]
254
- ['IPAMConfig' ]['IPv4Address' ],
255
- '192.168.0.1' )
256
-
257
- self .create_and_start (
258
- name = 'docker-py-test-upstream' ,
259
- host_config = self .client .create_host_config (network_mode = net_name ))
260
-
261
- self .execute (container , ['nslookup' , 'bar' ])
264
+ net_data ['IPAMConfig' ]['IPv4Address' ], '172.28.5.24'
265
+ )
262
266
263
267
@requires_api_version ('1.22' )
264
268
def test_connect_with_ipv6_address (self ):
265
- net_name , net_id = self .create_network ()
269
+ net_name , net_id = self .create_network (
270
+ ipam = create_ipam_config (
271
+ driver = 'default' ,
272
+ pool_configs = [
273
+ create_ipam_pool (
274
+ subnet = "2001:389::1/64" , iprange = "2001:389::0/96" ,
275
+ gateway = "2001:389::ffff"
276
+ )
277
+ ]
278
+ )
279
+ )
266
280
267
281
container = self .create_and_start (
268
282
host_config = self .client .create_host_config (network_mode = net_name ))
269
283
270
284
self .client .disconnect_container_from_network (container , net_name )
271
285
self .client .connect_container_to_network (
272
- container , net_name ,
273
- ipv6_address = '2001:389::1' )
286
+ container , net_name , ipv6_address = '2001:389::f00d'
287
+ )
274
288
275
289
container_data = self .client .inspect_container (container )
290
+ net_data = container_data ['NetworkSettings' ]['Networks' ][net_name ]
276
291
self .assertEqual (
277
- container_data ['NetworkSettings' ]['Networks' ][net_name ]
278
- ['IPAMConfig' ]['IPv6Address' ],
279
- '2001:389::1' )
280
-
281
- self .create_and_start (
282
- name = 'docker-py-test-upstream' ,
283
- host_config = self .client .create_host_config (network_mode = net_name ))
284
-
285
- self .execute (container , ['nslookup' , 'bar' ])
292
+ net_data ['IPAMConfig' ]['IPv6Address' ], '2001:389::f00d'
293
+ )
0 commit comments