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('receive') and have.get('receive') != want.get('receive'): cmd = 'lldp receive' remove_command_from_config_list(interface, cmd, commands) if have.get('transmit') and have.get('transmit') != want.get('transmit'): cmd = 'lldp transmit' remove_command_from_config_list(interface, cmd, 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('port_priority') and have.get('port_priority') != want.get('port_priority'): cmd = 'lacp port-priority' remove_command_from_config_list(interface, cmd, commands) if have.get('max_bundle') and have.get('max_bundle') != want.get('max_bundle'): cmd = 'lacp max-bundle' remove_command_from_config_list(interface, cmd, commands) if have.get('fast_switchover'): cmd = 'lacp fast-switchover' remove_command_from_config_list(interface, cmd, 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, 'ip address', commands) if have.get('ipv6') and not want.get('ipv6'): remove_command_from_config_list(interface, 'ipv6 address', 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('access') and want.get('access') is None: remove_command_from_config_list( interface, L2_Interfaces.access_cmds['access_vlan'], commands) elif have.get('access') and want.get('access'): if have.get('access').get('vlan') != want.get('access').get( 'vlan'): remove_command_from_config_list( interface, L2_Interfaces.access_cmds['access_vlan'], commands) if have.get('trunk') and want.get('trunk') is None: # Check when no config is passed if have.get('trunk').get('encapsulation'): remove_command_from_config_list( interface, self.trunk_cmds['encapsulation'], commands) if have.get('trunk').get('native_vlan'): remove_command_from_config_list(interface, self.trunk_cmds['native_vlan'], commands) if have.get('trunk').get('allowed_vlans'): remove_command_from_config_list( interface, self.trunk_cmds['allowed_vlans'], commands) if have.get('trunk').get('pruning_vlans'): remove_command_from_config_list( interface, self.trunk_cmds['pruning_vlans'], commands) elif have.get('trunk') and want.get('trunk'): # Check when config is passed, also used in replaced and override state if have.get('trunk').get('encapsulation')\ and have.get('trunk').get('encapsulation') != want.get('trunk').get('encapsulation'): remove_command_from_config_list( interface, self.trunk_cmds['encapsulation'], commands) if have.get('trunk').get('native_vlan') \ and have.get('trunk').get('native_vlan') != want.get('trunk').get('native_vlan'): remove_command_from_config_list(interface, self.trunk_cmds['native_vlan'], commands) if have.get('trunk').get('allowed_vlans') \ and have.get('trunk').get('allowed_vlans') != want.get('trunk').get('allowed_vlans'): remove_command_from_config_list( interface, self.trunk_cmds['allowed_vlans'], commands) if have.get('trunk').get('pruning_vlans') \ and have.get('trunk').get('pruning_vlans') != want.get('trunk').get('pruning_vlans'): remove_command_from_config_list( interface, self.trunk_cmds['pruning_vlans'], commands) return commands