Merge "rehome metering extension api definition"
This commit is contained in:
commit
8d44c9e222
@ -36,6 +36,7 @@ from neutron_lib.api.definitions import l3_ext_ha_mode
|
||||
from neutron_lib.api.definitions import l3_flavors
|
||||
from neutron_lib.api.definitions import logging
|
||||
from neutron_lib.api.definitions import logging_resource
|
||||
from neutron_lib.api.definitions import metering
|
||||
from neutron_lib.api.definitions import network
|
||||
from neutron_lib.api.definitions import network_availability_zone
|
||||
from neutron_lib.api.definitions import network_ip_availability
|
||||
@ -85,6 +86,7 @@ _ALL_API_DEFINITIONS = {
|
||||
l3_flavors,
|
||||
logging,
|
||||
logging_resource,
|
||||
metering,
|
||||
network,
|
||||
network_availability_zone,
|
||||
network_ip_availability,
|
||||
|
98
neutron_lib/api/definitions/metering.py
Normal file
98
neutron_lib/api/definitions/metering.py
Normal file
@ -0,0 +1,98 @@
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.db import constants as db_const
|
||||
|
||||
|
||||
METERING_LABELS = 'metering_labels'
|
||||
METERING_LABEL_RULES = 'metering_label_rules'
|
||||
|
||||
ALIAS = 'metering'
|
||||
IS_SHIM_EXTENSION = False
|
||||
IS_STANDARD_ATTR_EXTENSION = False
|
||||
NAME = 'Neutron Metering'
|
||||
API_PREFIX = ''
|
||||
DESCRIPTION = 'Neutron Metering extension.'
|
||||
UPDATED_TIMESTAMP = '2013-06-12T10:00:00-00:00'
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
METERING_LABELS: {
|
||||
'id': {
|
||||
'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True,
|
||||
'primary_key': True
|
||||
},
|
||||
'name': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': db_const.NAME_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''
|
||||
},
|
||||
'description': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'validate': {
|
||||
'type:string': db_const.LONG_DESCRIPTION_FIELD_SIZE},
|
||||
'is_visible': True, 'default': ''
|
||||
},
|
||||
'tenant_id': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True
|
||||
},
|
||||
'shared': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': False,
|
||||
'convert_to': converters.convert_to_boolean
|
||||
}
|
||||
},
|
||||
METERING_LABEL_RULES: {
|
||||
'id': {
|
||||
'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True,
|
||||
'primary_key': True
|
||||
},
|
||||
'metering_label_id': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True, 'required_by_policy': True
|
||||
},
|
||||
'direction': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True,
|
||||
'validate': {'type:values': ['ingress', 'egress']}
|
||||
},
|
||||
'excluded': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': False,
|
||||
'convert_to': converters.convert_to_boolean
|
||||
},
|
||||
'remote_ip_prefix': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'required_by_policy': True,
|
||||
'validate': {'type:subnet': None}
|
||||
},
|
||||
'tenant_id': {
|
||||
'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'validate': {'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True
|
||||
}
|
||||
}
|
||||
}
|
||||
SUB_RESOURCE_ATTRIBUTE_MAP = {}
|
||||
ACTION_MAP = {}
|
||||
REQUIRED_EXTENSIONS = []
|
||||
OPTIONAL_EXTENSIONS = []
|
||||
ACTION_STATUS = {}
|
33
neutron_lib/exceptions/metering.py
Normal file
33
neutron_lib/exceptions/metering.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib import exceptions
|
||||
|
||||
|
||||
class MeteringLabelNotFound(exceptions.NotFound):
|
||||
message = _("Metering label '%(label_id)s' does not exist.")
|
||||
|
||||
|
||||
class DuplicateMeteringRuleInPost(exceptions.InUse):
|
||||
message = _("Duplicate Metering Rule in POST.")
|
||||
|
||||
|
||||
class MeteringLabelRuleNotFound(exceptions.NotFound):
|
||||
message = _("Metering label rule '%(rule_id)s' does not exist.")
|
||||
|
||||
|
||||
class MeteringLabelRuleOverlaps(exceptions.Conflict):
|
||||
message = _("Metering label rule with remote_ip_prefix "
|
||||
"'%(remote_ip_prefix)s' overlaps another.")
|
24
neutron_lib/tests/unit/api/definitions/test_metering.py
Normal file
24
neutron_lib/tests/unit/api/definitions/test_metering.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import metering
|
||||
from neutron_lib.tests.unit.api.definitions import base
|
||||
|
||||
|
||||
class MeteringDefinitionTestCase(base.DefinitionBaseTestCase):
|
||||
extension_module = metering
|
||||
extension_resources = (metering.METERING_LABEL_RULES,
|
||||
metering.METERING_LABELS)
|
||||
extension_attributes = ('remote_ip_prefix',
|
||||
'excluded',
|
||||
'metering_label_id',
|
||||
'direction')
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- The ``metering`` extension's API is now available in
|
||||
``neutron_lib.api.definitions.metering``.
|
||||
- Exceptions for the ``metering`` extension are available in
|
||||
``neutron_lib.exceptions.metering``.
|
Loading…
x
Reference in New Issue
Block a user