Merge "Use QoS constants definitions"

This commit is contained in:
Zuul
2018-10-23 00:24:45 +00:00
committed by Gerrit Code Review
9 changed files with 30 additions and 23 deletions

View File

@@ -15,6 +15,7 @@
from neutron_lib.api import converters from neutron_lib.api import converters
from neutron_lib import constants from neutron_lib import constants
from neutron_lib.db import constants as db_const from neutron_lib.db import constants as db_const
from neutron_lib.services.qos import constants as qos_consts
METERING_LABELS = 'metering_labels' METERING_LABELS = 'metering_labels'
@@ -76,11 +77,11 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_filter': True, 'is_sort_key': True, 'is_filter': True, 'is_sort_key': True,
'is_visible': True, 'required_by_policy': True 'is_visible': True, 'required_by_policy': True
}, },
'direction': { qos_consts.DIRECTION: {
'allow_post': True, 'allow_put': False, 'allow_post': True, 'allow_put': False,
'is_visible': True, 'is_filter': True, 'is_visible': True, 'is_filter': True,
'is_sort_key': True, 'is_sort_key': True,
'validate': {'type:values': ['ingress', 'egress']} 'validate': {'type:values': constants.VALID_DIRECTIONS}
}, },
'excluded': { 'excluded': {
'allow_post': True, 'allow_put': False, 'allow_post': True, 'allow_put': False,

View File

@@ -116,7 +116,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'parent': _PARENT, 'parent': _PARENT,
'parameters': dict( 'parameters': dict(
_QOS_RULE_COMMON_FIELDS, _QOS_RULE_COMMON_FIELDS,
**{'max_kbps': { **{qos_const.MAX_KBPS: {
'allow_post': True, 'allow_put': True, 'allow_post': True, 'allow_put': True,
'convert_to': converters.convert_to_int, 'convert_to': converters.convert_to_int,
'is_visible': True, 'is_visible': True,
@@ -125,7 +125,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'validate': { 'validate': {
'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]} 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]}
}, },
'max_burst_kbps': { qos_const.MAX_BURST: {
'allow_post': True, 'allow_put': True, 'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': 0, 'is_visible': True, 'default': 0,
'is_filter': True, 'is_filter': True,
@@ -138,7 +138,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'parent': _PARENT, 'parent': _PARENT,
'parameters': dict( 'parameters': dict(
_QOS_RULE_COMMON_FIELDS, _QOS_RULE_COMMON_FIELDS,
**{'dscp_mark': { **{qos_const.DSCP_MARK: {
'allow_post': True, 'allow_put': True, 'allow_post': True, 'allow_put': True,
'convert_to': converters.convert_to_int, 'convert_to': converters.convert_to_int,
'is_visible': True, 'is_visible': True,
@@ -151,7 +151,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'parent': _PARENT, 'parent': _PARENT,
'parameters': dict( 'parameters': dict(
_QOS_RULE_COMMON_FIELDS, _QOS_RULE_COMMON_FIELDS,
**{'min_kbps': { **{qos_const.MIN_KBPS: {
'allow_post': True, 'allow_put': True, 'allow_post': True, 'allow_put': True,
'is_visible': True, 'is_visible': True,
'is_filter': True, 'is_filter': True,
@@ -159,7 +159,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'convert_to': converters.convert_to_int, 'convert_to': converters.convert_to_int,
'validate': { 'validate': {
'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]}}, 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]}},
'direction': { qos_const.DIRECTION: {
'allow_post': True, 'allow_put': True, 'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': constants.EGRESS_DIRECTION, 'is_visible': True, 'default': constants.EGRESS_DIRECTION,
'is_filter': True, 'is_filter': True,

View File

@@ -15,10 +15,9 @@
from neutron_lib.api.definitions import qos as qos_apidef from neutron_lib.api.definitions import qos as qos_apidef
from neutron_lib import constants from neutron_lib import constants
from neutron_lib.services.qos import constants as qos_const
DIRECTION = 'direction'
ALIAS = 'qos-bw-limit-direction' ALIAS = 'qos-bw-limit-direction'
LABEL = '' LABEL = ''
IS_SHIM_EXTENSION = False IS_SHIM_EXTENSION = False
@@ -34,7 +33,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
# sub-resource extension itself # sub-resource extension itself
qos_apidef.BANDWIDTH_LIMIT_RULES: { qos_apidef.BANDWIDTH_LIMIT_RULES: {
'parameters': { 'parameters': {
DIRECTION: { qos_const.DIRECTION: {
'allow_post': True, 'allow_post': True,
'allow_put': True, 'allow_put': True,
'is_visible': True, 'is_visible': True,

View File

@@ -55,7 +55,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'type:range': [0, db_const.DB_INTEGER_MAX_VALUE] 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]
} }
}, },
qos_bw_limit_direction.DIRECTION: { q_const.DIRECTION: {
'allow_post': False, 'allow_post': False,
'allow_put': True, 'allow_put': True,
'is_visible': True, 'is_visible': True,
@@ -100,7 +100,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'type:range': [0, db_const.DB_INTEGER_MAX_VALUE] 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE]
} }
}, },
qos_bw_limit_direction.DIRECTION: { q_const.DIRECTION: {
'allow_post': False, 'allow_put': True, 'allow_post': False, 'allow_put': True,
'is_visible': True, 'default': constants.EGRESS_DIRECTION, 'is_visible': True, 'default': constants.EGRESS_DIRECTION,
'is_filter': True, 'is_filter': True,

View File

@@ -11,6 +11,7 @@
# under the License. # under the License.
from neutron_lib.api.definitions import metering from neutron_lib.api.definitions import metering
from neutron_lib.services.qos import constants as qos_consts
from neutron_lib.tests.unit.api.definitions import base from neutron_lib.tests.unit.api.definitions import base
@@ -21,4 +22,4 @@ class MeteringDefinitionTestCase(base.DefinitionBaseTestCase):
extension_attributes = ('remote_ip_prefix', extension_attributes = ('remote_ip_prefix',
'excluded', 'excluded',
'metering_label_id', 'metering_label_id',
'direction') qos_consts.DIRECTION)

View File

@@ -11,6 +11,7 @@
# under the License. # under the License.
from neutron_lib.api.definitions import qos from neutron_lib.api.definitions import qos
from neutron_lib.services.qos import constants as q_const
from neutron_lib.tests.unit.api.definitions import base from neutron_lib.tests.unit.api.definitions import base
@@ -20,6 +21,6 @@ class QoSDefinitionTestCase(base.DefinitionBaseTestCase):
extension_subresources = (qos.BANDWIDTH_LIMIT_RULES, extension_subresources = (qos.BANDWIDTH_LIMIT_RULES,
qos.DSCP_MARKING_RULES, qos.DSCP_MARKING_RULES,
qos.MIN_BANDWIDTH_RULES) qos.MIN_BANDWIDTH_RULES)
extension_attributes = ('direction', 'max_burst_kbps', 'type', extension_attributes = (q_const.DIRECTION, q_const.MAX_BURST, 'type',
'dscp_mark', 'min_kbps', 'rules', 'max_kbps', q_const.DSCP_MARK, q_const.MIN_KBPS, 'rules',
'qos_policy_id') q_const.MAX_KBPS, q_const.QOS_POLICY_ID)

View File

@@ -15,10 +15,11 @@
from neutron_lib.api.definitions import qos from neutron_lib.api.definitions import qos
from neutron_lib.api.definitions import qos_bw_limit_direction from neutron_lib.api.definitions import qos_bw_limit_direction
from neutron_lib.services.qos import constants as qos_const
from neutron_lib.tests.unit.api.definitions import base from neutron_lib.tests.unit.api.definitions import base
class QoSBwLimitDirectionDefinitionTestCase(base.DefinitionBaseTestCase): class QoSBwLimitDirectionDefinitionTestCase(base.DefinitionBaseTestCase):
extension_module = qos_bw_limit_direction extension_module = qos_bw_limit_direction
extension_subresources = (qos.BANDWIDTH_LIMIT_RULES,) extension_subresources = (qos.BANDWIDTH_LIMIT_RULES,)
extension_attributes = (qos_bw_limit_direction.DIRECTION,) extension_attributes = (qos_const.DIRECTION,)

View File

@@ -11,7 +11,6 @@
# under the License. # under the License.
from neutron_lib.api.definitions import qos from neutron_lib.api.definitions import qos
from neutron_lib.api.definitions import qos_bw_limit_direction
from neutron_lib.api.definitions import qos_rules_alias from neutron_lib.api.definitions import qos_rules_alias
from neutron_lib.services.qos import constants as q_const from neutron_lib.services.qos import constants as q_const
from neutron_lib.tests.unit.api.definitions import base from neutron_lib.tests.unit.api.definitions import base
@@ -22,7 +21,7 @@ class QoSRulesAliasDefinitionTestCase(base.DefinitionBaseTestCase):
extension_resources = (qos.BANDWIDTH_LIMIT_RULES, extension_resources = (qos.BANDWIDTH_LIMIT_RULES,
qos.DSCP_MARKING_RULES, qos.DSCP_MARKING_RULES,
qos.MIN_BANDWIDTH_RULES) qos.MIN_BANDWIDTH_RULES)
extension_attributes = (qos_bw_limit_direction.DIRECTION, extension_attributes = (q_const.DIRECTION,
q_const.MAX_BURST, q_const.MAX_BURST,
q_const.DSCP_MARK, q_const.DSCP_MARK,
q_const.MIN_KBPS, q_const.MIN_KBPS,

View File

@@ -15,6 +15,7 @@
import mock import mock
from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import portbindings
from neutron_lib import constants
from neutron_lib.services.qos import base as qos_base from neutron_lib.services.qos import base as qos_base
from neutron_lib.services.qos import constants as qos_consts from neutron_lib.services.qos import constants as qos_consts
from neutron_lib.tests import _base from neutron_lib.tests import _base
@@ -22,8 +23,8 @@ from neutron_lib.tests import _base
SUPPORTED_RULES = { SUPPORTED_RULES = {
qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: {
"min_kbps": {'type:values': None}, qos_consts.MIN_KBPS: {'type:values': None},
'direction': {'type:values': ['egress']} qos_consts.DIRECTION: {'type:values': ['egress']}
} }
} }
@@ -73,9 +74,13 @@ class TestDriverBase(_base.BaseTestCase):
_make_driver().is_rule_supported( _make_driver().is_rule_supported(
_make_rule( _make_rule(
rule_type=qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH, rule_type=qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH,
params={'min_kbps': None, 'direction': 'egress'}))) params={qos_consts.MIN_KBPS: None,
qos_consts.DIRECTION:
constants.EGRESS_DIRECTION})))
self.assertFalse( self.assertFalse(
_make_driver().is_rule_supported( _make_driver().is_rule_supported(
_make_rule( _make_rule(
rule_type=qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH, rule_type=qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH,
params={'min_kbps': None, 'direction': 'ingress'}))) params={qos_consts.MIN_KBPS: None,
qos_consts.DIRECTION:
constants.INGRESS_DIRECTION})))