def get_switchport(port, module):
 command = 'show interface {0} switchport'.format(port)
 body = execute_show_command(command, module)
 try:
  body = execute_show_command(command, module)[0]
 except IndexError:
  body = []
 if body:
  key_map = {'interface': 'interface', 'oper_mode': 'mode', 'switchport': 'switchport', 'access_vlan': 'access_vlan', 'access_vlan_name': 'access_vlan_name', 'native_vlan': 'native_vlan', 'native_vlan_name': 'native_vlan_name', 'trunk_vlans': 'trunk_vlans'}
  sp_table = body['TABLE_interface']['ROW_interface']
  sp = apply_key_map(key_map, sp_table)
  return sp
 else:
  return {}

def get_switchport ( port , module ) : command = 'show interface {0} switchport' . format ( port ) body = execute_show_command ( command , module ) try : body = execute_show_command ( command , module ) [ 0 ] except IndexError : body = [ ] if body : key_map = { 'interface' : 'interface' , 'oper_mode' : 'mode' , 'switchport' : 'switchport' , 'access_vlan' : 'access_vlan' , 'access_vlan_name' : 'access_vlan_name' , 'native_vlan' : 'native_vlan' , 'native_vlan_name' : 'native_vlan_name' , 'trunk_vlans' : 'trunk_vlans' } sp_table = body [ 'TABLE_interface' ] [ 'ROW_interface' ] sp = apply_key_map ( key_map , sp_table ) return sp else : return { }
gets current config of l2 switchport args: device : this is the device object of an nx-api enabled device using the device class within device .