parameters: (
      lhs: List[Union[network_types.UnicastRoute, network_types.MplsRoute]],
      rhs: List[Union[network_types.UnicastRoute, network_types.MplsRoute]],
      route_type: str,
  )
return_statement: return keys
docstring: Get keys common to both routeDbs with different nexthops
docstring_summary: Get keys common to both routeDbs with different nexthops
docstring_tokens: Get keys common to both routeDbs with different nexthops
function: def prefixes_with_different_nexthops(
      lhs: List[Union[network_types.UnicastRoute, network_types.MplsRoute]],
      rhs: List[Union[network_types.UnicastRoute, network_types.MplsRoute]],
      route_type: str,
  ) -> List[Tuple[str, str, str]]:
      """
      Get keys common to both routeDbs with different nexthops
      """
  
      keys = []
  
      # dict of:
      # 1. prefix(str) : nexthops(str) for UnicastRoute
      # 2. topLabel(str) : nexthops(str) for MplsRoute
      _lhs = get_route_as_dict_in_str(lhs, route_type)
      _rhs = get_route_as_dict_in_str(rhs, route_type)
      common_keys = set(_lhs) & set(_rhs)
  
      if route_type == "unicast":
          for key in common_keys:
              if _lhs[key] != _rhs[key]:
                  keys.append((key, _lhs[key], _rhs[key]))
      elif route_type == "mpls":
          for key in common_keys:
              nh_diff_found = False
              l_nh_coll = _lhs[key]
              r_nh_coll = _rhs[key]
  
              if l_nh_coll == r_nh_coll:
                  continue
  
              # iterate through every single nexthop for this key
              for index in range(0, len(l_nh_coll)):
                  l_nh = l_nh_coll[index]
                  r_nh = r_nh_coll[index]
                  if l_nh != r_nh:
                      l_tokens = l_nh.split()
                      r_tokens = r_nh.split()
                      # Skip verification for MPLS 'POP_AND_LOOKUP' action since
                      # different agent underneath can give different result.
                      if (
                          l_tokens[1] == "POP_AND_LOOKUP"
                          and r_tokens[1] == "POP_AND_LOOKUP"
                      ):
                          continue
                      nh_diff_found = True
  
              # nexthop diff found
              if nh_diff_found:
                  print(key, l_nh_coll, r_nh_coll)
                  keys.append((key, l_nh_coll, r_nh_coll))
  
      return keys
function_tokens: def prefixes_with_different_nexthops ( lhs : List [ Union [ network_types . UnicastRoute , network_types . MplsRoute ] ] , rhs : List [ Union [ network_types . UnicastRoute , network_types . MplsRoute ] ] , route_type : str , ) -> List [ Tuple [ str , str , str ] ] : keys = [ ] # dict of: # 1. prefix(str) : nexthops(str) for UnicastRoute # 2. topLabel(str) : nexthops(str) for MplsRoute _lhs = get_route_as_dict_in_str ( lhs , route_type ) _rhs = get_route_as_dict_in_str ( rhs , route_type ) common_keys = set ( _lhs ) & set ( _rhs ) if route_type == "unicast" : for key in common_keys : if _lhs [ key ] != _rhs [ key ] : keys . append ( ( key , _lhs [ key ] , _rhs [ key ] ) ) elif route_type == "mpls" : for key in common_keys : nh_diff_found = False l_nh_coll = _lhs [ key ] r_nh_coll = _rhs [ key ] if l_nh_coll == r_nh_coll : continue # iterate through every single nexthop for this key for index in range ( 0 , len ( l_nh_coll ) ) : l_nh = l_nh_coll [ index ] r_nh = r_nh_coll [ index ] if l_nh != r_nh : l_tokens = l_nh . split ( ) r_tokens = r_nh . split ( ) # Skip verification for MPLS 'POP_AND_LOOKUP' action since # different agent underneath can give different result. if ( l_tokens [ 1 ] == "POP_AND_LOOKUP" and r_tokens [ 1 ] == "POP_AND_LOOKUP" ) : continue nh_diff_found = True # nexthop diff found if nh_diff_found : print ( key , l_nh_coll , r_nh_coll ) keys . append ( ( key , l_nh_coll , r_nh_coll ) ) return keys