Sort multiple macs in port lookup
Sorting makes the usage more predictable. Change-Id: Id88a0f8b5a6c5d0f411803d8618b8aac32165c99
This commit is contained in:
		@@ -16,7 +16,12 @@ from neutron.callbacks import registry
 | 
			
		||||
from neutron.callbacks import resources
 | 
			
		||||
from neutron.common import constants as l3_constants
 | 
			
		||||
from neutron.db import l3_db
 | 
			
		||||
from neutron.db import models_v2
 | 
			
		||||
from neutron.db import securitygroups_db
 | 
			
		||||
from neutron.plugins.ml2 import db as ml2_db
 | 
			
		||||
from oslo_log import log
 | 
			
		||||
 | 
			
		||||
LOG = log.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Monkey patch create floatingip to allow subnet_id to be specified.
 | 
			
		||||
@@ -167,3 +172,12 @@ def _get_security_groups_on_port(self, context, port):
 | 
			
		||||
 | 
			
		||||
securitygroups_db.SecurityGroupDbMixin._get_security_groups_on_port = (
 | 
			
		||||
    _get_security_groups_on_port)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_port_from_device_mac(context, device_mac):
 | 
			
		||||
    LOG.debug("get_port_from_device_mac() called for mac %s", device_mac)
 | 
			
		||||
    qry = context.session.query(models_v2.Port).filter_by(
 | 
			
		||||
        mac_address=device_mac).order_by(models_v2.Port.device_owner.desc())
 | 
			
		||||
    return qry.first()
 | 
			
		||||
 | 
			
		||||
ml2_db.get_port_from_device_mac = get_port_from_device_mac
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user