@@ -268,16 +268,16 @@ def set_interface(**kwargs):
268
268
if ipv4 :
269
269
for each_ip in ipv4 :
270
270
if each_ip .get ('address' ) == 'dhcp' :
271
- if each_ip .get ('dhcp_client' ) and (each_ip .get ('dhcp_client' ) != have ('dhcp_client' ). split ( '/' )[ 1 ]
272
- or 'no ip address' in clear_cmds ):
273
- if each_ip .get ('dhcp_hostname' ) and each_ip .get ('dhcp_hostname' ) != have ('dhcp_hostname' ):
274
- cmd = 'ip address dhcp client-id GigabitEthernet0/{0 } hostname {1 }' .format
275
- (each_ip .get ('dhcp_client' ), each_ip .get ('dhcp_hostname' ))
271
+ if each_ip .get ('dhcp_client' ) and (each_ip .get ('dhcp_client' ) != have . get ('dhcp_client' )
272
+ or 'no ip address' in clear_cmds ):
273
+ if each_ip .get ('dhcp_hostname' ) and each_ip .get ('dhcp_hostname' ) == have . get ('dhcp_hostname' ):
274
+ cmd = 'ip address dhcp client-id GigabitEthernet0/{} hostname {}' .\
275
+ format (each_ip .get ('dhcp_client' ), each_ip .get ('dhcp_hostname' ))
276
276
L3_Interfaces ._add_command_to_interface (interface , cmd , commands )
277
277
else :
278
278
cmd = 'ip address dhcp client-id GigabitEthernet0/{}' .format (each_ip .get ('dhcp_client' ))
279
279
L3_Interfaces ._add_command_to_interface (interface , cmd , commands )
280
- if each_ip .get ('dhcp_hostname' ) and (each_ip .get ('dhcp_hostname' ) != have ('dhcp_hostname' )
280
+ if each_ip .get ('dhcp_hostname' ) and (each_ip .get ('dhcp_hostname' ) != have . get ('dhcp_hostname' )
281
281
or 'no ip address' in clear_cmds ):
282
282
cmd = 'ip address dhcp hostname {}' .format (each_ip .get ('dhcp_hostname' ))
283
283
L3_Interfaces ._add_command_to_interface (interface , cmd , commands )
@@ -322,12 +322,12 @@ def clear_interface(**kwargs):
322
322
have = kwargs ['have' ]
323
323
interface = 'interface ' + want ['name' ]
324
324
325
+ if have .get ('secondary' ) and not want .get ('secondary' ):
326
+ cmd = 'ip address {} secondary' .format (have .get ('secondary_ipv4' ))
327
+ L3_Interfaces ._remove_command_from_interface (interface , cmd , commands )
325
328
if have .get ('ipv4' ) and not want .get ('ipv4' ):
326
329
L3_Interfaces ._remove_command_from_interface (interface , 'ip address' , commands )
327
330
if have .get ('ipv6' ) and not want .get ('ipv6' ):
328
331
L3_Interfaces ._remove_command_from_interface (interface , 'ipv6 address' , commands )
329
- if have .get ('secondary' ) and not want .get ('secondary' ):
330
- cmd = 'ip address {} secondary' .format (have .get ('secondary_ipv4' ))
331
- L3_Interfaces ._remove_command_from_interface (interface , cmd , commands )
332
332
333
333
return commands
0 commit comments