@@ -268,6 +268,10 @@ def test_gateway_chassis_for_chassis_not_in_gw_chassis_list(self):
268
268
269
269
class TestDHCPUtils (base .BaseTestCase ):
270
270
271
+ def setUp (self ):
272
+ ovn_conf .register_opts ()
273
+ super (TestDHCPUtils , self ).setUp ()
274
+
271
275
def test_validate_port_extra_dhcp_opts_empty (self ):
272
276
port = {edo_ext .EXTRADHCPOPTS : []}
273
277
result = utils .validate_port_extra_dhcp_opts (port )
@@ -371,12 +375,50 @@ def test_get_lsp_dhcp_opts(self):
371
375
dhcp_disabled , options = utils .get_lsp_dhcp_opts (port , 4 )
372
376
self .assertFalse (dhcp_disabled )
373
377
# Assert the names got translated to their OVN names
374
- expected_options = {'tftp_server_address ' : '10.0.0.1' ,
378
+ expected_options = {'next_server ' : '10.0.0.1' ,
375
379
'ntp_server' : '10.0.2.1' ,
376
380
'bootfile_name' : '"homer_simpson.bin"' }
377
381
self .assertEqual (expected_options , options )
378
382
379
- def test_get_lsp_dhcp_opts_for_domain_search (self ):
383
+ def test_get_lsp_dhcp_opts_for_baremetal (self ):
384
+ opt0 = {'opt_name' : 'tag:ipxe,bootfile-name' ,
385
+ 'opt_value' : 'http://172.7.27.29/ipxe' ,
386
+ 'ip_version' : 4 }
387
+ opt1 = {'opt_name' : 'tag:!ipxe,bootfile-name' ,
388
+ 'opt_value' : 'undionly.kpxe' ,
389
+ 'ip_version' : 4 }
390
+ opt2 = {'opt_name' : 'tftp-server' ,
391
+ 'opt_value' : '"172.7.27.29"' ,
392
+ 'ip_version' : 4 }
393
+ port = {portbindings .VNIC_TYPE : portbindings .VNIC_BAREMETAL ,
394
+ edo_ext .EXTRADHCPOPTS : [opt0 , opt1 , opt2 ]}
395
+
396
+ dhcp_disabled , options = utils .get_lsp_dhcp_opts (port , 4 )
397
+ self .assertFalse (dhcp_disabled )
398
+ # Assert the names got translated to their OVN names and the
399
+ # options that weren't double-quoted are now double-quoted
400
+ expected_options = {'tftp_server' : '"172.7.27.29"' ,
401
+ 'bootfile_name' : '"http://172.7.27.29/ipxe"' ,
402
+ 'bootfile_name_alt' : '"undionly.kpxe"' }
403
+ self .assertEqual (expected_options , options )
404
+
405
+ def test_get_lsp_dhcp_opts_dhcp_disabled_for_baremetal (self ):
406
+ cfg .CONF .set_override (
407
+ 'disable_ovn_dhcp_for_baremetal_ports' , True , group = 'ovn' )
408
+
409
+ opt = {'opt_name' : 'tag:ipxe,bootfile-name' ,
410
+ 'opt_value' : 'http://172.7.27.29/ipxe' ,
411
+ 'ip_version' : 4 }
412
+ port = {portbindings .VNIC_TYPE : portbindings .VNIC_BAREMETAL ,
413
+ edo_ext .EXTRADHCPOPTS : [opt ]}
414
+
415
+ dhcp_disabled , options = utils .get_lsp_dhcp_opts (port , 4 )
416
+ # Assert DHCP is disabled for this port
417
+ self .assertTrue (dhcp_disabled )
418
+ # Assert no options were passed
419
+ self .assertEqual ({}, options )
420
+
421
+ def test_get_lsp_dhcp_opts_for_domain_search (self ):
380
422
opt = {'opt_name' : 'domain-search' ,
381
423
'opt_value' : 'openstack.org,ovn.org' ,
382
424
'ip_version' : 4 }
@@ -390,7 +432,6 @@ def test_get_lsp_dhcp_opts_for_domain_search(self):
390
432
expected_options = {'domain_search_list' : '"openstack.org,ovn.org"' }
391
433
self .assertEqual (expected_options , options )
392
434
393
-
394
435
class TestGetDhcpDnsServers (base .BaseTestCase ):
395
436
396
437
def setUp (self ):
0 commit comments