Browse Source

Fix VlanAllocation import

VlanAllocation was moved from the Vlan Type driver to a db model,
this change imports VlanAllocation form its new location.

Change-Id: I285a0339ee9181bcb27ef409e78e0e73503bc319
changes/60/439260/1
Mitchell Jameson 5 years ago
parent
commit
b6a1d76220
  1. 14
      networking_arista/ml2/drivers/driver_helpers.py
  2. 4
      networking_arista/tests/unit/ml2/test_arista_type_driver.py

14
networking_arista/ml2/drivers/driver_helpers.py

@ -17,7 +17,7 @@ from oslo_log import log
from six import moves
from neutron.db import api as db_api
from neutron.plugins.ml2.drivers import type_vlan
from neutron.db.models.plugins.ml2 import vlanallocation
from networking_arista._i18n import _LI
from networking_arista.common import exceptions as arista_exc
@ -120,8 +120,9 @@ class VlanSyncService(object):
session = db_api.get_session()
with session.begin(subtransactions=True):
allocs = (session.query(type_vlan.VlanAllocation).with_lockmode(
'update'))
allocs = (
session.query(vlanallocation.VlanAllocation).with_lockmode(
'update'))
for alloc in allocs:
if alloc.physical_network != 'default':
@ -140,7 +141,8 @@ class VlanSyncService(object):
for vlan_id in sorted(assigned_vlans):
allocated = vlan_id in used_vlans
alloc = type_vlan.VlanAllocation(physical_network='default',
vlan_id=vlan_id,
allocated=allocated)
alloc = vlanallocation.VlanAllocation(
physical_network='default',
vlan_id=vlan_id,
allocated=allocated)
session.add(alloc)

4
networking_arista/tests/unit/ml2/test_arista_type_driver.py

@ -18,7 +18,7 @@ from mock import patch
from oslo_config import cfg
from neutron.db import api as db_api
from neutron.plugins.ml2.drivers import type_vlan
from neutron.db.models.plugins.ml2 import vlanallocation
from neutron.tests import base
from neutron.tests.unit import testlib_api
@ -64,7 +64,7 @@ class VlanSyncServiceTest(testlib_api.SqlTestCase):
def _ensure_in_db(self, assigned, allocated, available):
session = db_api.get_session()
with session.begin():
vlans = session.query(type_vlan.VlanAllocation).all()
vlans = session.query(vlanallocation.VlanAllocation).all()
for vlan in vlans:
self.assertIn(vlan.vlan_id, assigned)

Loading…
Cancel
Save