Merge "Use constants from neutron-lib"
This commit is contained in:
@@ -18,7 +18,6 @@ import netaddr
|
||||
from neutron_lib import constants as lib_consts
|
||||
|
||||
from neutron_dynamic_routing.services.bgp.agent.driver import exceptions as bgp_driver_exc # noqa
|
||||
from neutron_dynamic_routing.services.bgp.common import constants as bgp_consts # noqa
|
||||
|
||||
|
||||
# Parameter validation functions provided are provided by the base.
|
||||
@@ -27,11 +26,11 @@ def validate_as_num(param, as_num):
|
||||
raise bgp_driver_exc.InvalidParamType(param=param,
|
||||
param_type='integer')
|
||||
|
||||
if not (bgp_consts.MIN_ASNUM <= as_num <= bgp_consts.MAX_4BYTE_ASNUM):
|
||||
if not (lib_consts.MIN_ASNUM <= as_num <= lib_consts.MAX_4BYTE_ASNUM):
|
||||
# Must be in [AS_NUM_MIN, MAX_4BYTE_ASNUM] range.
|
||||
allowed_range = ('[' +
|
||||
str(bgp_consts.MIN_ASNUM) + '-' +
|
||||
str(bgp_consts.MAX_4BYTE_ASNUM) +
|
||||
str(lib_consts.MIN_ASNUM) + '-' +
|
||||
str(lib_consts.MAX_4BYTE_ASNUM) +
|
||||
']')
|
||||
raise bgp_driver_exc.InvalidParamRange(param=param,
|
||||
range=allowed_range)
|
||||
@@ -39,7 +38,7 @@ def validate_as_num(param, as_num):
|
||||
|
||||
def validate_auth(auth_type, password):
|
||||
validate_string(password)
|
||||
if auth_type in bgp_consts.SUPPORTED_AUTH_TYPES:
|
||||
if auth_type in lib_consts.SUPPORTED_AUTH_TYPES:
|
||||
if auth_type != 'none' and password is None:
|
||||
raise bgp_driver_exc.PasswordNotSpecified(auth_type=auth_type)
|
||||
if auth_type == 'none' and password is not None:
|
||||
|
@@ -18,11 +18,3 @@ AGENT_TYPE_BGP_ROUTING = 'BGP dynamic routing agent'
|
||||
BGP_DRAGENT = 'bgp_dragent'
|
||||
|
||||
BGP_PLUGIN = 'q-bgp-plugin'
|
||||
|
||||
# List of supported authentication types.
|
||||
SUPPORTED_AUTH_TYPES = ['none', 'md5']
|
||||
|
||||
# Supported AS number range
|
||||
MIN_ASNUM = 1
|
||||
MAX_ASNUM = 65535
|
||||
MAX_4BYTE_ASNUM = 4294967295
|
||||
|
@@ -19,7 +19,6 @@ from neutron.tests import base
|
||||
|
||||
from neutron_dynamic_routing.services.bgp.agent.driver import exceptions as bgp_driver_exc # noqa
|
||||
from neutron_dynamic_routing.services.bgp.agent.driver import utils as bgp_driver_utils # noqa
|
||||
from neutron_dynamic_routing.services.bgp.common import constants as bgp_consts # noqa
|
||||
|
||||
FAKE_IP = '2.2.2.5'
|
||||
FAKE_IPV6 = '2001:db8::'
|
||||
@@ -51,20 +50,20 @@ class TestValidateMethod(base.BaseTestCase):
|
||||
|
||||
def test_validate_as_num_with_invalid_max_range(self):
|
||||
allowed_range = ('\\[' +
|
||||
str(bgp_consts.MIN_ASNUM) + '-' +
|
||||
str(bgp_consts.MAX_4BYTE_ASNUM) +
|
||||
str(lib_consts.MIN_ASNUM) + '-' +
|
||||
str(lib_consts.MAX_4BYTE_ASNUM) +
|
||||
'\\]')
|
||||
with self.assertRaisesRegex(
|
||||
bgp_driver_exc.InvalidParamRange,
|
||||
EXC_INV_PARAMRANGE % {'param': 'local_as',
|
||||
'range': allowed_range}):
|
||||
bgp_driver_utils.validate_as_num('local_as',
|
||||
bgp_consts.MAX_4BYTE_ASNUM + 1)
|
||||
lib_consts.MAX_4BYTE_ASNUM + 1)
|
||||
|
||||
def test_validate_as_num_with_invalid_min_range(self):
|
||||
allowed_range = ('\\[' +
|
||||
str(bgp_consts.MIN_ASNUM) + '-' +
|
||||
str(bgp_consts.MAX_4BYTE_ASNUM) +
|
||||
str(lib_consts.MIN_ASNUM) + '-' +
|
||||
str(lib_consts.MAX_4BYTE_ASNUM) +
|
||||
'\\]')
|
||||
with self.assertRaisesRegex(
|
||||
bgp_driver_exc.InvalidParamRange,
|
||||
@@ -74,13 +73,13 @@ class TestValidateMethod(base.BaseTestCase):
|
||||
|
||||
def test_validate_auth_with_valid_auth_type(self):
|
||||
passwords = [None, 'password']
|
||||
for (auth_type, passwd) in zip(bgp_consts.SUPPORTED_AUTH_TYPES,
|
||||
for (auth_type, passwd) in zip(lib_consts.SUPPORTED_AUTH_TYPES,
|
||||
passwords):
|
||||
self.assertIsNone(bgp_driver_utils.validate_auth(auth_type,
|
||||
passwd))
|
||||
|
||||
def test_validate_auth_with_integer_password(self):
|
||||
auth_type = bgp_consts.SUPPORTED_AUTH_TYPES[1]
|
||||
auth_type = lib_consts.SUPPORTED_AUTH_TYPES[1]
|
||||
with self.assertRaisesRegex(
|
||||
bgp_driver_exc.InvalidParamType,
|
||||
EXC_INV_PARAMTYPE % {'param': '12345',
|
||||
@@ -95,7 +94,7 @@ class TestValidateMethod(base.BaseTestCase):
|
||||
bgp_driver_utils.validate_auth(auth_type, 'password')
|
||||
|
||||
def test_validate_auth_with_not_none_auth_type_and_none_password(self):
|
||||
auth_type = bgp_consts.SUPPORTED_AUTH_TYPES[1]
|
||||
auth_type = lib_consts.SUPPORTED_AUTH_TYPES[1]
|
||||
with self.assertRaisesRegex(
|
||||
bgp_driver_exc.PasswordNotSpecified,
|
||||
EXC_PASSWORD_NOTSPEC % {'auth_type': auth_type}):
|
||||
|
@@ -8,7 +8,7 @@ httplib2>=0.9.1 # MIT
|
||||
netaddr>=0.7.18 # BSD
|
||||
SQLAlchemy>=1.3.3 # MIT
|
||||
alembic>=0.9.6 # MIT
|
||||
neutron-lib>=1.26.0 # Apache-2.0
|
||||
neutron-lib>=2.12.0 # Apache-2.0
|
||||
os-ken>=0.3.0 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
oslo.db>=4.44.0 # Apache-2.0
|
||||
|
Reference in New Issue
Block a user