Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit 359d074

Browse files
committed
fix issues
Signed-off-by: Sumit Jaiswal <[email protected]>
1 parent fa9201d commit 359d074

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

module_utils/ios/config/l3_interfaces/l3_interfaces.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,16 @@ def set_interface(**kwargs):
268268
if ipv4:
269269
for each_ip in ipv4:
270270
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'))
276276
L3_Interfaces._add_command_to_interface(interface, cmd, commands)
277277
else:
278278
cmd = 'ip address dhcp client-id GigabitEthernet0/{}'.format(each_ip.get('dhcp_client'))
279279
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')
281281
or 'no ip address' in clear_cmds):
282282
cmd = 'ip address dhcp hostname {}'.format(each_ip.get('dhcp_hostname'))
283283
L3_Interfaces._add_command_to_interface(interface, cmd, commands)
@@ -322,12 +322,12 @@ def clear_interface(**kwargs):
322322
have = kwargs['have']
323323
interface = 'interface ' + want['name']
324324

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)
325328
if have.get('ipv4') and not want.get('ipv4'):
326329
L3_Interfaces._remove_command_from_interface(interface, 'ip address', commands)
327330
if have.get('ipv6') and not want.get('ipv6'):
328331
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)
332332

333333
return commands

0 commit comments

Comments
 (0)