Merge "Add source_ip_prefix and destination_ip_prefix to metering label rules"

This commit is contained in:
Zuul 2020-08-31 22:27:56 +00:00 committed by Gerrit Code Review
commit c92e22a470
7 changed files with 142 additions and 8 deletions

View File

@ -206,6 +206,8 @@ Request
- direction: metering_label_rule-direction-query
- remote_ip_prefix: metering_label_rule-remote_ip_prefix-query
- source_ip_prefix: metering_label_rule-source_ip_prefix-query
- destination_ip_prefix: metering_label_rule-destination_ip_prefix-query
- excluded : excluded-query
- metering_label_id: metering_label-id-query
- id: id-query
@ -221,6 +223,8 @@ Response Parameters
- metering_label_rules: metering_label_rules
- direction: metering_label_rule-direction
- remote_ip_prefix: metering_label_rule-remote_ip_prefix
- source_ip_prefix: metering_label_rule-source_ip_prefix-query
- destination_ip_prefix: metering_label_rule-destination_ip_prefix-query
- excluded : excluded
- metering_label_id: metering_label-id-body
- id: metering_label_rule-id
@ -249,6 +253,8 @@ Request
- metering_label_rule: metering_label_rule
- remote_ip_prefix: metering_label_rule-remote_ip_prefix
- source_ip_prefix: metering_label_rule-source_ip_prefix-query
- destination_ip_prefix: metering_label_rule-destination_ip_prefix-query
- direction: metering_label_rule-direction
- metering_label_id: metering_label-id-body
- excluded: excluded-request
@ -267,6 +273,8 @@ Response Parameters
- metering_label_rule: metering_label_rule
- direction: metering_label_rule-direction
- remote_ip_prefix: metering_label_rule-remote_ip_prefix
- source_ip_prefix: metering_label_rule-source_ip_prefix-query
- destination_ip_prefix: metering_label_rule-destination_ip_prefix-query
- excluded : excluded
- metering_label_id: metering_label-id-body
- id: metering_label_rule-id
@ -294,6 +302,10 @@ The response body shows this information for each metering label rule:
- The remote IP prefix (deprecated).
- The source IP prefix
- The destination IP prefix
- The metering label ID for the metering label with which the rule
is associated.
@ -322,6 +334,8 @@ Response Paramters
- metering_label_rule: metering_label_rule
- direction: metering_label_rule-direction
- remote_ip_prefix: metering_label_rule-remote_ip_prefix
- source_ip_prefix: metering_label_rule-source_ip_prefix-query
- destination_ip_prefix: metering_label_rule-destination_ip_prefix-query
- excluded : excluded
- metering_label_id: metering_label-id-body
- id: metering_label_rule-id

View File

@ -725,6 +725,19 @@ metering_label-sort_key:
in: query
required: false
type: string
metering_label_rule-destination_ip_prefix-query:
description: |
The destination IP prefix that the metering rule is associated with; in
this context, destination IP prefix represents the destination IP of the
network packet. Therefore, for an ingress rule, the destination IP is
the internal IP associated with some OpenStack VM. On the other hand,
for an egress rule, the destination IP prefix is the IP of some external
system that an application running inside some OpenStack virtual machine
is trying to access. Moreover, instead of an IP, one can also use a CIDR
as the destination IP prefix.
in: query
required: false
type: string
metering_label_rule-direction-query:
description: |
Filter the metering rule list result by the direction in
@ -735,8 +748,8 @@ metering_label_rule-direction-query:
metering_label_rule-remote_ip_prefix-query:
description: |
(deprecated) Filter the metering rule list result by the source IP prefix
that the metering rule associates with. By source IP prefix, we mean,
the internal/private IPs used in OpenStack.
that the metering rule associates with. By source IP prefix, one should
read the internal/private IPs used in OpenStack.
in: query
required: false
type: string
@ -753,6 +766,18 @@ metering_label_rule-sort_key:
in: query
required: false
type: string
metering_label_rule-source_ip_prefix-query:
description: |
The source IP prefix that the metering rule is associated with; in this
context, source IP prefix represents the source IP of the network packet.
Therefore, for an ingress rule, the source IP is the IP of the system
accessing something inside OpenStack. On the other hand, for an egress
rule, the source IP is the internal IP associated with some OpenStack VM.
Moreover, instead of an IP, one can also use a CIDR as the source IP
prefix.
in: query
required: false
type: string
min_kbps-query:
description: |
Filter the list result by the minimum KBPS (kilobits per second) value
@ -2411,16 +2436,17 @@ ethertype-request:
type: string
excluded:
description: |
Indicates whether to count the traffic of a
specific IP address with the ``remote_ip_prefix`` value.
Indicates whether to count the traffic of a specific IP address with the
``remote_ip_prefix``, ``source_ip_prefix``, or ``destination_ip_prefix``
values.
in: body
required: true
type: boolean
excluded-request:
description: |
Indicates whether to count the traffic of a
specific IP address with the ``remote_ip_prefix`` value. Default
is ``false``.
Indicates whether to count the traffic of a specific IP address with the
``remote_ip_prefix``, ``source_ip_prefix``, or ``destination_ip_prefix``
values. Default is ``false``.
in: body
required: false
type: boolean
@ -3841,7 +3867,8 @@ metering_label_rule-id:
metering_label_rule-remote_ip_prefix:
description: |
(deprecated) The source IP prefix that is matched by this metering rule. By
source IP prefix, we mean, the internal/private IPs used in OpenStack.
source IP prefix, one should read the internal/private IPs used in
OpenStack.
in: body
required: true
type: string

View File

@ -62,6 +62,7 @@ from neutron_lib.api.definitions import l3_port_ip_change_not_allowed
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 metering_source_and_destination_filters
from neutron_lib.api.definitions import multiprovidernet
from neutron_lib.api.definitions import network
from neutron_lib.api.definitions import network_availability_zone
@ -177,6 +178,7 @@ _ALL_API_DEFINITIONS = {
logging,
logging_resource,
metering,
metering_source_and_destination_filters,
multiprovidernet,
network,
network_availability_zone,

View File

@ -113,6 +113,7 @@ KNOWN_EXTENSIONS = (
'l3-port-ip-change-not-allowed',
'logging',
'metering',
'metering_source_and_destination_filters',
'multi-provider',
'net-mtu',
'network-ip-availability',

View File

@ -0,0 +1,57 @@
#
# 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
ALIAS = 'metering_source_and_destination_fields'
IS_SHIM_EXTENSION = False
IS_STANDARD_ATTR_EXTENSION = False
NAME = 'Neutron Metering with source and destination filtering'
API_PREFIX = ''
DESCRIPTION = 'Neutron Metering extension that enables the use of source ' \
'and destination IP prefixes to create metering label rules.'
UPDATED_TIMESTAMP = '2020-08-21T08:12:00-00:00'
RESOURCE_ATTRIBUTE_MAP = {}
REQUIRED_EXTENSIONS = [metering.ALIAS]
_PARENT = {
'collection_name': metering.METERING_LABEL_RULES,
'member_name': metering.METERING_LABEL_RULES
}
SUB_RESOURCE_ATTRIBUTE_MAP = {
metering.METERING_LABEL_RULES: {
'parent': _PARENT,
'parameters': {
'remote_ip_prefix': {
'allow_post': True, 'allow_put': False,
'is_visible': True, 'required_by_policy': False,
'is_filter': True, 'is_sort_key': True, 'default': None
},
'source_ip_prefix': {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'required_by_policy': False,
'is_filter': True, 'is_sort_key': True, 'default': None
},
'destination_ip_prefix': {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'required_by_policy': False,
'is_filter': True, 'is_sort_key': True, 'default': None
}
}
}
}
ACTION_MAP = {}
OPTIONAL_EXTENSIONS = []
ACTION_STATUS = {}

View File

@ -0,0 +1,28 @@
#
# 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.api.definitions import metering_source_and_destination_filters
from neutron_lib.tests.unit.api.definitions import base
class SourceAndDestinationMeteringLabelRuleDefinitionTestCase(
base.DefinitionBaseTestCase):
extension_module = metering_source_and_destination_filters
extension_resources = (metering.METERING_LABEL_RULES,)
extension_subresources = (metering.METERING_LABEL_RULES,)
extension_attributes = ('remote_ip_prefix', 'source_ip_prefix',
'destination_ip_prefix')

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``source_ip_prefix`` and ``destination_ip_prefix`` to Neutron metering
label rules.