def _clear_config(self, want, have): # Delete the interface config based on the want and have config commands = [] if want.get('name'): interface_type = get_interface_type(want['name']) interface = 'interface ' + want['name'] else: interface_type = get_interface_type(have['name']) interface = 'interface ' + have['name'] if have.get('description' ) and want.get('description') != have.get('description'): remove_command_from_config_list(interface, 'description', commands) if not have.get( 'enabled') and want.get('enabled') != have.get('enabled'): # if enable is False set enable as True which is the default behavior remove_command_from_config_list(interface, 'shutdown', commands) if interface_type.lower() == 'gigabitethernet': if have.get('speed') and have.get('speed') != 'auto' and want.get( 'speed') != have.get('speed'): remove_command_from_config_list(interface, 'speed', commands) if have.get( 'duplex') and have.get('duplex') != 'auto' and want.get( 'duplex') != have.get('duplex'): remove_command_from_config_list(interface, 'duplex', commands) if have.get('mtu') and want.get('mtu') != have.get('mtu'): remove_command_from_config_list(interface, 'mtu', commands) return commands
def _clear_config(self, want, have): # Delete the interface config based on the want and have config commands = [] if want.get('name'): interface = 'interface ' + want['name'] else: interface = 'interface ' + have['name'] if have.get('native_vlan'): remove_command_from_config_list(interface, 'dot1q native vlan', commands) if have.get('q_vlan'): remove_command_from_config_list(interface, 'encapsulation dot1q', commands) if have.get('l2protocol') and (want.get('l2protocol') is None or want.get('propagate') is None): if 'no l2transport' not in commands: remove_command_from_config_list(interface, 'l2transport', commands) elif have.get('l2transport' ) and have.get('l2transport') != want.get('l2transport'): if 'no l2transport' not in commands: remove_command_from_config_list(interface, 'l2transport', commands) return commands
def _clear_config(self, want, have): # Delete the interface config based on the want and have config count = 0 commands = [] if want.get('name'): interface = 'interface ' + want['name'] else: interface = 'interface ' + have['name'] if have.get('ipv4') and want.get('ipv4'): for each in have.get('ipv4'): if each.get('secondary') and not ( want.get('ipv4')[count].get('secondary')): cmd = 'ipv4 address {0} secondary'.format( each.get('address')) remove_command_from_config_list(interface, cmd, commands) count += 1 if have.get('ipv4') and not (want.get('ipv4')): remove_command_from_config_list(interface, 'ipv4 address', commands) if have.get('ipv6') and not (want.get('ipv6')): remove_command_from_config_list(interface, 'ipv6 address', commands) return commands