@ -27,6 +27,9 @@ from oslo_utils import excutils
import requests
from six import add_metaclass
from neutron . db import api as db_api
from neutron . db . models . plugins . ml2 import vlanallocation
from networking_arista . _i18n import _ , _LI , _LW , _LE
from networking_arista . common import db_lib
from networking_arista . common import exceptions as arista_exc
@ -84,6 +87,21 @@ class AristaRPCWrapperBase(object):
self . security_group_driver = arista_sec_gp . AristaSecGroupSwitchDriver (
self . _ndb )
# We denote mlag_pair physnets as peer1_peer2 in the physnet name, the
# following builds a mapping of peer name to physnet name for use
# during port binding
self . mlag_pairs = { }
session = db_api . get_reader_session ( )
with session . begin ( ) :
physnets = session . query (
vlanallocation . VlanAllocation . physical_network
) . distinct ( ) . all ( )
for ( physnet , ) in physnets :
if ' _ ' in physnet :
peers = physnet . split ( ' _ ' )
self . mlag_pairs [ peers [ 0 ] ] = physnet
self . mlag_pairs [ peers [ 1 ] ] = physnet
# Indication of CVX availabililty in the driver.
self . _cvx_available = True
@ -1989,6 +2007,10 @@ class AristaRPCWrapperEapi(AristaRPCWrapperBase):
if hostname :
switch_id = response [ 1 ] [ ' hosts ' ] [ hostname ] [ ' name ' ]
# Check if the switch is part of an MLAG pair, and lookup the
# pair's physnet name if so
physnet = self . mlag_pairs . get ( physnet , physnet )
for k in response [ 1 ] [ ' hosts ' ] :
mac_to_hostname [ response [ 1 ] [ ' hosts ' ] [ k ] [ ' name ' ] ] = k