def check_vlan_exists(eapi_conn, vlan_id):
 vlan_id = str(vlan_id)
 cmd = 'show vlan id {}'.format(vlan_id)
 try:
  response = eapi_conn.enable(cmd)
  check_vlan = pyeapi_result(response)['vlans']
  return check_vlan[vlan_id]['name']
 except (pyeapi.eapilib.CommandError, KeyError):
  pass
 return False

def check_vlan_exists ( eapi_conn , vlan_id ) : vlan_id = str ( vlan_id ) cmd = 'show vlan id {}' . format ( vlan_id ) try : response = eapi_conn . enable ( cmd ) check_vlan = pyeapi_result ( response ) [ 'vlans' ] return check_vlan [ vlan_id ] [ 'name' ] except ( pyeapi . eapilib . CommandError , KeyError ) : pass return False
check if the given vlan exists return either vlan_name or false .