def get_interface_config_commands(interface, intf, existing):
 commands = []
 desc = interface.get('description')
 if desc:
  commands.append('description {0}'.format(desc))
 mode = interface.get('mode')
 if mode:
  if (mode == 'layer2'):
   command = 'switchport'
  elif (mode == 'layer3'):
   command = 'no switchport'
  commands.append(command)
 admin_state = interface.get('admin_state')
 if admin_state:
  command = get_admin_state(interface, intf, admin_state)
  commands.append(command)
 ip_forward = interface.get('ip_forward')
 if ip_forward:
  if (ip_forward == 'enable'):
   commands.append('ip forward')
  else:
   commands.append('no ip forward')
 fabric_forwarding_anycast_gateway = interface.get('fabric_forwarding_anycast_gateway')
 if (fabric_forwarding_anycast_gateway is not None):
  if (fabric_forwarding_anycast_gateway is True):
   commands.append('fabric forwarding mode anycast-gateway')
  elif (fabric_forwarding_anycast_gateway is False):
   commands.append('no fabric forwarding mode anycast-gateway')
 if commands:
  commands.insert(0, ('interface ' + intf))
 return commands

def get_interface_config_commands ( interface , intf , existing ) : commands = [ ] desc = interface . get ( 'description' ) if desc : commands . append ( 'description {0}' . format ( desc ) ) mode = interface . get ( 'mode' ) if mode : if ( mode == 'layer2' ) : command = 'switchport' elif ( mode == 'layer3' ) : command = 'no switchport' commands . append ( command ) admin_state = interface . get ( 'admin_state' ) if admin_state : command = get_admin_state ( interface , intf , admin_state ) commands . append ( command ) ip_forward = interface . get ( 'ip_forward' ) if ip_forward : if ( ip_forward == 'enable' ) : commands . append ( 'ip forward' ) else : commands . append ( 'no ip forward' ) fabric_forwarding_anycast_gateway = interface . get ( 'fabric_forwarding_anycast_gateway' ) if ( fabric_forwarding_anycast_gateway is not None ) : if ( fabric_forwarding_anycast_gateway is True ) : commands . append ( 'fabric forwarding mode anycast-gateway' ) elif ( fabric_forwarding_anycast_gateway is False ) : commands . append ( 'no fabric forwarding mode anycast-gateway' ) if commands : commands . insert ( 0 , ( 'interface ' + intf ) ) return commands
generates list of commands to configure on device args: interface : k/v pairs in the form of a set that should be configured on the device intf : full name of interface .