@@ -1262,14 +1262,18 @@ func (o *NB) UpdateLogicalSwitchDHCPv4Options(ctx context.Context, switchName OV
1262
1262
1263
1263
if opts .Router != nil {
1264
1264
dhcpOption .Options ["router" ] = opts .Router .String ()
1265
+ } else {
1266
+ delete (dhcpOption .Options , "router" )
1265
1267
}
1266
1268
1267
1269
if len (opts .DNSSearchList ) > 0 {
1268
1270
// Special quoting to allow domain names.
1269
1271
dhcpOption .Options ["domain_search_list" ] = fmt .Sprintf (`"%s"` , strings .Join (opts .DNSSearchList , "," ))
1272
+ } else {
1273
+ delete (dhcpOption .Options , "domain_search_list" )
1270
1274
}
1271
1275
1272
- if opts .RecursiveDNSServer != nil {
1276
+ if len ( opts .RecursiveDNSServer ) > 0 {
1273
1277
nsIPs := make ([]string , 0 , len (opts .RecursiveDNSServer ))
1274
1278
for _ , nsIP := range opts .RecursiveDNSServer {
1275
1279
if nsIP .To4 () == nil {
@@ -1280,19 +1284,27 @@ func (o *NB) UpdateLogicalSwitchDHCPv4Options(ctx context.Context, switchName OV
1280
1284
}
1281
1285
1282
1286
dhcpOption .Options ["dns_server" ] = fmt .Sprintf ("{%s}" , strings .Join (nsIPs , "," ))
1287
+ } else {
1288
+ delete (dhcpOption .Options , "dns_server" )
1283
1289
}
1284
1290
1285
1291
if opts .DomainName != "" {
1286
1292
// Special quoting to allow domain names.
1287
1293
dhcpOption .Options ["domain_name" ] = fmt .Sprintf (`"%s"` , opts .DomainName )
1294
+ } else {
1295
+ delete (dhcpOption .Options , "domain_name" )
1288
1296
}
1289
1297
1290
1298
if opts .MTU > 0 {
1291
1299
dhcpOption .Options ["mtu" ] = fmt .Sprintf ("%d" , opts .MTU )
1300
+ } else {
1301
+ delete (dhcpOption .Options , "mtu" )
1292
1302
}
1293
1303
1294
1304
if opts .Netmask != "" {
1295
1305
dhcpOption .Options ["netmask" ] = opts .Netmask
1306
+ } else {
1307
+ delete (dhcpOption .Options , "netmask" )
1296
1308
}
1297
1309
1298
1310
if opts .StaticRoutes != "" {
@@ -1364,6 +1376,8 @@ func (o *NB) UpdateLogicalSwitchDHCPv6Options(ctx context.Context, switchName OV
1364
1376
if len (opts .DNSSearchList ) > 0 {
1365
1377
// Special quoting to allow domain names.
1366
1378
dhcpOption .Options ["domain_search" ] = fmt .Sprintf (`"%s"` , strings .Join (opts .DNSSearchList , "," ))
1379
+ } else {
1380
+ delete (dhcpOption .Options , "domain_search" )
1367
1381
}
1368
1382
1369
1383
if opts .RecursiveDNSServer != nil {
@@ -1377,6 +1391,8 @@ func (o *NB) UpdateLogicalSwitchDHCPv6Options(ctx context.Context, switchName OV
1377
1391
}
1378
1392
1379
1393
dhcpOption .Options ["dns_server" ] = fmt .Sprintf ("{%s}" , strings .Join (nsIPs , "," ))
1394
+ } else {
1395
+ delete (dhcpOption .Options , "dns_server" )
1380
1396
}
1381
1397
1382
1398
// Prepare the changes.
0 commit comments