Add QoS minimum bandwidth rule object and CRUD commands.
Closes-Bug: 1609472 Depends-On: Idf319cd182304952071bc976a2e56c42fbcb8468 Change-Id: I2e8869750024a8ccbc7777b95fe8ef6e26ec0885
This commit is contained in:
@@ -19,6 +19,7 @@ Network Resources
|
|||||||
v2/pool
|
v2/pool
|
||||||
v2/pool_member
|
v2/pool_member
|
||||||
v2/port
|
v2/port
|
||||||
|
v2/qos_minimum_bandwidth_rule
|
||||||
v2/qos_policy
|
v2/qos_policy
|
||||||
v2/quota
|
v2/quota
|
||||||
v2/rbac_policy
|
v2/rbac_policy
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
openstack.network.v2.qos_minimum_bandwidth_rule
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
.. automodule:: openstack.network.v2.qos_minimum_bandwidth_rule
|
||||||
|
|
||||||
|
The QoSMinimumBandwidthRule Class
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
The ``QoSMinimumBandwidthRule`` class inherits from :class:`~openstack.resource.Resource`.
|
||||||
|
|
||||||
|
.. autoclass:: openstack.network.v2.qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule
|
||||||
|
:members:
|
||||||
@@ -25,6 +25,8 @@ from openstack.network.v2 import network_ip_availability
|
|||||||
from openstack.network.v2 import pool as _pool
|
from openstack.network.v2 import pool as _pool
|
||||||
from openstack.network.v2 import pool_member as _pool_member
|
from openstack.network.v2 import pool_member as _pool_member
|
||||||
from openstack.network.v2 import port as _port
|
from openstack.network.v2 import port as _port
|
||||||
|
from openstack.network.v2 import qos_minimum_bandwidth_rule as \
|
||||||
|
_qos_minimum_bandwidth_rule
|
||||||
from openstack.network.v2 import qos_policy as _qos_policy
|
from openstack.network.v2 import qos_policy as _qos_policy
|
||||||
from openstack.network.v2 import quota as _quota
|
from openstack.network.v2 import quota as _quota
|
||||||
from openstack.network.v2 import rbac_policy as _rbac_policy
|
from openstack.network.v2 import rbac_policy as _rbac_policy
|
||||||
@@ -1144,6 +1146,215 @@ class Proxy(proxy.BaseProxy):
|
|||||||
result.append(puerta)
|
result.append(puerta)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def create_qos_minimum_bandwidth_rule(self, qos_policy, **attrs):
|
||||||
|
"""Create a new minimum bandwidth rule
|
||||||
|
|
||||||
|
:param dict attrs: Keyword arguments which will be used to create
|
||||||
|
a :class:`~openstack.network.v2.
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`,
|
||||||
|
comprised of the properties on the
|
||||||
|
QoSMinimumBandwidthRule class.
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
|
||||||
|
:returns: The results of resource creation
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule`
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
return self._create(
|
||||||
|
_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
path_args={'qos_policy_id': qos_policy_id}, **attrs)
|
||||||
|
|
||||||
|
def delete_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy,
|
||||||
|
ignore_missing=True):
|
||||||
|
"""Delete a minimum bandwidth rule
|
||||||
|
|
||||||
|
:param qos_rule: The value can be either the ID of a minimum bandwidth
|
||||||
|
rule or a :class:`~openstack.network.v2.
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`
|
||||||
|
instance.
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
:param bool ignore_missing: When set to ``False``
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be
|
||||||
|
raised when the resource does not exist.
|
||||||
|
When set to ``True``, no exception will be set when
|
||||||
|
attempting to delete a nonexistent minimum bandwidth rule.
|
||||||
|
|
||||||
|
:returns: ``None``
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
self._delete(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
qos_rule, ignore_missing=ignore_missing,
|
||||||
|
path_args={'qos_policy_id': qos_policy_id})
|
||||||
|
|
||||||
|
def find_qos_minimum_bandwidth_rule(self, qos_rule_id, qos_policy,
|
||||||
|
ignore_missing=True):
|
||||||
|
"""Find a minimum bandwidth rule
|
||||||
|
|
||||||
|
:param qos_rule_id: The ID of a minimum bandwidth rule.
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
:param bool ignore_missing: When set to ``False``
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be
|
||||||
|
raised when the resource does not exist.
|
||||||
|
When set to ``True``, None will be returned when
|
||||||
|
attempting to find a nonexistent resource.
|
||||||
|
:returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule` or None
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
return self._find(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
qos_rule_id, ignore_missing=ignore_missing,
|
||||||
|
path_args={'qos_policy_id': qos_policy_id})
|
||||||
|
|
||||||
|
def get_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy):
|
||||||
|
"""Get a single minimum bandwidth rule
|
||||||
|
|
||||||
|
:param qos_rule: The value can be the ID of a minimum bandwidth rule or
|
||||||
|
a :class:`~openstack.network.v2.
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`
|
||||||
|
instance.
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
:returns: One :class:`~openstack.network.v2.qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule`
|
||||||
|
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||||
|
when no resource can be found.
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
return self._get(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
qos_rule, path_args={'qos_policy_id': qos_policy_id})
|
||||||
|
|
||||||
|
def qos_minimum_bandwidth_rules(self, qos_policy, **query):
|
||||||
|
"""Return a generator of minimum bandwidth rules
|
||||||
|
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
:param kwargs \*\*query: Optional query parameters to be sent to limit
|
||||||
|
the resources being returned.
|
||||||
|
:returns: A generator of minimum bandwidth rule objects
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule`
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
return self._list(_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
paginated=False,
|
||||||
|
path_args={'qos_policy_id': qos_policy_id}, **query)
|
||||||
|
|
||||||
|
def update_qos_minimum_bandwidth_rule(self, qos_rule, qos_policy,
|
||||||
|
**attrs):
|
||||||
|
"""Update a minimum bandwidth rule
|
||||||
|
|
||||||
|
:param qos_rule: Either the id of a minimum bandwidth rule or a
|
||||||
|
:class:`~openstack.network.v2.
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule`
|
||||||
|
instance.
|
||||||
|
:param qos_policy: The value can be the ID of the QoS policy that the
|
||||||
|
rule belongs or a :class:`~openstack.network.v2.
|
||||||
|
qos_policy.QoSPolicy` instance.
|
||||||
|
:attrs kwargs: The attributes to update on the minimum bandwidth rule
|
||||||
|
represented by ``value``.
|
||||||
|
|
||||||
|
:returns: The updated minimum bandwidth rule
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule`
|
||||||
|
"""
|
||||||
|
qos_policy_id = resource.Resource.get_id(qos_policy)
|
||||||
|
return self._update(_qos_minimum_bandwidth_rule.
|
||||||
|
QoSMinimumBandwidthRule, qos_rule,
|
||||||
|
path_args={'qos_policy_id': qos_policy_id},
|
||||||
|
**attrs)
|
||||||
|
|
||||||
|
def create_qos_policy(self, **attrs):
|
||||||
|
"""Create a new QoS policy from attributes
|
||||||
|
|
||||||
|
:param dict attrs: Keyword arguments which will be used to create
|
||||||
|
a :class:`~openstack.network.v2.qos_policy.
|
||||||
|
QoSPolicy`, comprised of the properties on the
|
||||||
|
QoSPolicy class.
|
||||||
|
|
||||||
|
:returns: The results of QoS policy creation
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
"""
|
||||||
|
return self._create(_qos_policy.QoSPolicy, **attrs)
|
||||||
|
|
||||||
|
def delete_qos_policy(self, qos_policy, ignore_missing=True):
|
||||||
|
"""Delete a QoS policy
|
||||||
|
|
||||||
|
:param qos_policy: The value can be either the ID of a QoS policy or a
|
||||||
|
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
instance.
|
||||||
|
:param bool ignore_missing: When set to ``False``
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be
|
||||||
|
raised when the QoS policy does not exist.
|
||||||
|
When set to ``True``, no exception will be set when
|
||||||
|
attempting to delete a nonexistent QoS policy.
|
||||||
|
|
||||||
|
:returns: ``None``
|
||||||
|
"""
|
||||||
|
self._delete(_qos_policy.QoSPolicy, qos_policy,
|
||||||
|
ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
def find_qos_policy(self, name_or_id, ignore_missing=True):
|
||||||
|
"""Find a single QoS policy
|
||||||
|
|
||||||
|
:param name_or_id: The name or ID of a QoS policy.
|
||||||
|
:param bool ignore_missing: When set to ``False``
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be
|
||||||
|
raised when the resource does not exist.
|
||||||
|
When set to ``True``, None will be returned when
|
||||||
|
attempting to find a nonexistent resource.
|
||||||
|
:returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` or
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
return self._find(_qos_policy.QoSPolicy, name_or_id,
|
||||||
|
ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
def get_qos_policy(self, qos_policy):
|
||||||
|
"""Get a single QoS policy
|
||||||
|
|
||||||
|
:param qos_policy: The value can be the ID of a QoS policy or a
|
||||||
|
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
instance.
|
||||||
|
|
||||||
|
:returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||||
|
when no resource can be found.
|
||||||
|
"""
|
||||||
|
return self._get(_qos_policy.QoSPolicy, qos_policy)
|
||||||
|
|
||||||
|
def qos_policies(self, **query):
|
||||||
|
"""Return a generator of QoS policies
|
||||||
|
|
||||||
|
:param kwargs \*\*query: Optional query parameters to be sent to limit
|
||||||
|
the resources being returned.
|
||||||
|
|
||||||
|
:returns: A generator of QoS policy objects
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
"""
|
||||||
|
return self._list(_qos_policy.QoSPolicy, paginated=False, **query)
|
||||||
|
|
||||||
|
def update_qos_policy(self, qos_policy, **attrs):
|
||||||
|
"""Update a QoS policy
|
||||||
|
|
||||||
|
:param qos_policy: Either the id of a QoS policy or a
|
||||||
|
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
instance.
|
||||||
|
:attrs kwargs: The attributes to update on the QoS policy represented
|
||||||
|
by ``value``.
|
||||||
|
|
||||||
|
:returns: The updated QoS policy
|
||||||
|
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
||||||
|
"""
|
||||||
|
return self._update(_qos_policy.QoSPolicy, qos_policy, **attrs)
|
||||||
|
|
||||||
def delete_quota(self, quota, ignore_missing=True):
|
def delete_quota(self, quota, ignore_missing=True):
|
||||||
"""Delete a quota (i.e. reset to the default quota)
|
"""Delete a quota (i.e. reset to the default quota)
|
||||||
|
|
||||||
@@ -1891,86 +2102,3 @@ class Proxy(proxy.BaseProxy):
|
|||||||
:rtype: :class:`~openstack.network.v2.vpn_service.VPNService`
|
:rtype: :class:`~openstack.network.v2.vpn_service.VPNService`
|
||||||
"""
|
"""
|
||||||
return self._update(_vpn_service.VPNService, vpn_service, **attrs)
|
return self._update(_vpn_service.VPNService, vpn_service, **attrs)
|
||||||
|
|
||||||
def create_qos_policy(self, **attrs):
|
|
||||||
"""Create a new QoS policy from attributes
|
|
||||||
|
|
||||||
:param dict attrs: Keyword arguments which will be used to create
|
|
||||||
a :class:`~openstack.network.v2.qos_policy.
|
|
||||||
QoSPolicy`, comprised of the properties on the
|
|
||||||
QoSPolicy class.
|
|
||||||
|
|
||||||
:returns: The results of QoS policy creation
|
|
||||||
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
"""
|
|
||||||
return self._create(_qos_policy.QoSPolicy, **attrs)
|
|
||||||
|
|
||||||
def delete_qos_policy(self, qos_policy, ignore_missing=True):
|
|
||||||
"""Delete a QoS policy
|
|
||||||
|
|
||||||
:param qos_policy: The value can be either the ID of a QoS policy or a
|
|
||||||
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
instance.
|
|
||||||
:param bool ignore_missing: When set to ``False``
|
|
||||||
:class:`~openstack.exceptions.ResourceNotFound` will be
|
|
||||||
raised when the QoS policy does not exist.
|
|
||||||
When set to ``True``, no exception will be set when
|
|
||||||
attempting to delete a nonexistent QoS policy.
|
|
||||||
|
|
||||||
:returns: ``None``
|
|
||||||
"""
|
|
||||||
self._delete(_qos_policy.QoSPolicy, qos_policy,
|
|
||||||
ignore_missing=ignore_missing)
|
|
||||||
|
|
||||||
def find_qos_policy(self, name_or_id, ignore_missing=True):
|
|
||||||
"""Find a single QoS policy
|
|
||||||
|
|
||||||
:param name_or_id: The name or ID of a QoS policy.
|
|
||||||
:param bool ignore_missing: When set to ``False``
|
|
||||||
:class:`~openstack.exceptions.ResourceNotFound` will be
|
|
||||||
raised when the resource does not exist.
|
|
||||||
When set to ``True``, None will be returned when
|
|
||||||
attempting to find a nonexistent resource.
|
|
||||||
:returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy` or
|
|
||||||
None
|
|
||||||
"""
|
|
||||||
return self._find(_qos_policy.QoSPolicy, name_or_id,
|
|
||||||
ignore_missing=ignore_missing)
|
|
||||||
|
|
||||||
def get_qos_policy(self, qos_policy):
|
|
||||||
"""Get a single QoS policy
|
|
||||||
|
|
||||||
:param qos_policy: The value can be the ID of a QoS policy or a
|
|
||||||
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
instance.
|
|
||||||
|
|
||||||
:returns: One :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
|
||||||
when no resource can be found.
|
|
||||||
"""
|
|
||||||
return self._get(_qos_policy.QoSPolicy, qos_policy)
|
|
||||||
|
|
||||||
def qos_policies(self, **query):
|
|
||||||
"""Return a generator of QoS policies
|
|
||||||
|
|
||||||
:param kwargs \*\*query: Optional query parameters to be sent to limit
|
|
||||||
the resources being returned.
|
|
||||||
|
|
||||||
:returns: A generator of QoS policy objects
|
|
||||||
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
"""
|
|
||||||
return self._list(_qos_policy.QoSPolicy, paginated=False, **query)
|
|
||||||
|
|
||||||
def update_qos_policy(self, qos_policy, **attrs):
|
|
||||||
"""Update a QoS policy
|
|
||||||
|
|
||||||
:param qos_policy: Either the id of a QoS policy or a
|
|
||||||
:class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
instance.
|
|
||||||
:attrs kwargs: The attributes to update on the QoS policy represented
|
|
||||||
by ``value``.
|
|
||||||
|
|
||||||
:returns: The updated QoS policy
|
|
||||||
:rtype: :class:`~openstack.network.v2.qos_policy.QoSPolicy`
|
|
||||||
"""
|
|
||||||
return self._update(_qos_policy.QoSPolicy, qos_policy, **attrs)
|
|
||||||
|
|||||||
46
openstack/network/v2/qos_minimum_bandwidth_rule.py
Normal file
46
openstack/network/v2/qos_minimum_bandwidth_rule.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# 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 openstack.network import network_service
|
||||||
|
from openstack import resource
|
||||||
|
|
||||||
|
|
||||||
|
class QoSMinimumBandwidthRule(resource.Resource):
|
||||||
|
resource_key = 'minimum_bandwidth_rule'
|
||||||
|
resources_key = 'minimum_bandwidth_rules'
|
||||||
|
base_path = '/qos/policies/%(qos_policy_id)s/minimum_bandwidth_rules'
|
||||||
|
service = network_service.NetworkService()
|
||||||
|
|
||||||
|
# capabilities
|
||||||
|
allow_create = True
|
||||||
|
allow_retrieve = True
|
||||||
|
allow_update = True
|
||||||
|
allow_delete = True
|
||||||
|
allow_list = True
|
||||||
|
|
||||||
|
# Properties
|
||||||
|
#: QoS minimum bandwidth rule id.
|
||||||
|
id = resource.prop('id')
|
||||||
|
#: The ID of the QoS policy who owns rule.
|
||||||
|
qos_policy_id = resource.prop('qos_policy_id')
|
||||||
|
#: Minimum bandwidth in kbps.
|
||||||
|
min_kbps = resource.prop('min_kbps')
|
||||||
|
#: Traffic direction from the tenant point of view. Valid values: 'egress'
|
||||||
|
direction = resource.prop('direction')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_create_body(cls, attrs):
|
||||||
|
# Exclude qos_policy_id from attrs since it is not expected by QoS API.
|
||||||
|
if 'qos_policy_id' in attrs:
|
||||||
|
attrs.pop('qos_policy_id')
|
||||||
|
|
||||||
|
return {cls.resource_key: attrs}
|
||||||
@@ -755,10 +755,7 @@ class Resource(collections.MutableMapping):
|
|||||||
del attrs[cls.id_attribute]
|
del attrs[cls.id_attribute]
|
||||||
headers = attrs.pop(HEADERS, None)
|
headers = attrs.pop(HEADERS, None)
|
||||||
|
|
||||||
if cls.resource_key:
|
body = cls._get_create_body(attrs)
|
||||||
body = {cls.resource_key: attrs}
|
|
||||||
else:
|
|
||||||
body = attrs
|
|
||||||
|
|
||||||
url = cls._get_url(path_args, resource_id)
|
url = cls._get_url(path_args, resource_id)
|
||||||
args = {'json': body}
|
args = {'json': body}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from openstack.network.v2 import (qos_minimum_bandwidth_rule as
|
||||||
|
_qos_minimum_bandwidth_rule)
|
||||||
|
from openstack.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
class TestQoSMinimumBandwidthRule(base.BaseFunctionalTest):
|
||||||
|
|
||||||
|
QOS_POLICY_ID = None
|
||||||
|
QOS_POLICY_NAME = uuid.uuid4().hex
|
||||||
|
QOS_IS_SHARED = False
|
||||||
|
QOS_POLICY_DESCRIPTION = "QoS policy description"
|
||||||
|
RULE_ID = None
|
||||||
|
RULE_MIN_KBPS = 1200
|
||||||
|
RULE_MIN_KBPS_NEW = 1800
|
||||||
|
RULE_DIRECTION = 'egress'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(TestQoSMinimumBandwidthRule, cls).setUpClass()
|
||||||
|
qos_policy = cls.conn.network.create_qos_policy(
|
||||||
|
description=cls.QOS_POLICY_DESCRIPTION,
|
||||||
|
name=cls.QOS_POLICY_NAME,
|
||||||
|
shared=cls.QOS_IS_SHARED,
|
||||||
|
)
|
||||||
|
cls.QOS_POLICY_ID = qos_policy.id
|
||||||
|
qos_min_bw_rule = cls.conn.network.create_qos_minimum_bandwidth_rule(
|
||||||
|
cls.QOS_POLICY_ID, direction=cls.RULE_DIRECTION,
|
||||||
|
min_kbps=cls.RULE_MIN_KBPS,
|
||||||
|
)
|
||||||
|
assert isinstance(qos_min_bw_rule,
|
||||||
|
_qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule)
|
||||||
|
cls.assertIs(cls.RULE_MIN_KBPS, qos_min_bw_rule.min_kbps)
|
||||||
|
cls.assertIs(cls.RULE_DIRECTION, qos_min_bw_rule.direction)
|
||||||
|
cls.RULE_ID = qos_min_bw_rule.id
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
rule = cls.conn.network.delete_qos_minimum_bandwidth_rule(
|
||||||
|
cls.RULE_ID,
|
||||||
|
cls.QOS_POLICY_ID)
|
||||||
|
qos_policy = cls.conn.network.delete_qos_policy(cls.QOS_POLICY_ID)
|
||||||
|
cls.assertIs(None, rule)
|
||||||
|
cls.assertIs(None, qos_policy)
|
||||||
|
|
||||||
|
def test_find(self):
|
||||||
|
sot = self.conn.network.find_qos_minimum_bandwidth_rule(
|
||||||
|
self.RULE_ID,
|
||||||
|
self.QOS_POLICY_ID)
|
||||||
|
self.assertEqual(self.RULE_ID, sot.id)
|
||||||
|
self.assertEqual(self.RULE_DIRECTION, sot.direction)
|
||||||
|
self.assertEqual(self.RULE_MIN_KBPS, sot.min_kbps)
|
||||||
|
|
||||||
|
def test_get(self):
|
||||||
|
sot = self.conn.network.get_qos_minimum_bandwidth_rule(
|
||||||
|
self.RULE_ID,
|
||||||
|
self.QOS_POLICY_ID)
|
||||||
|
self.assertEqual(self.RULE_ID, sot.id)
|
||||||
|
self.assertEqual(self.QOS_POLICY_ID, sot.qos_policy_id)
|
||||||
|
self.assertEqual(self.RULE_DIRECTION, sot.direction)
|
||||||
|
self.assertEqual(self.RULE_MIN_KBPS, sot.min_kbps)
|
||||||
|
|
||||||
|
def test_list(self):
|
||||||
|
rule_ids = [o.id for o in
|
||||||
|
self.conn.network.qos_minimum_bandwidth_rules(
|
||||||
|
self.QOS_POLICY_ID)]
|
||||||
|
self.assertIn(self.RULE_ID, rule_ids)
|
||||||
|
|
||||||
|
def test_update(self):
|
||||||
|
sot = self.conn.network.update_qos_minimum_bandwidth_rule(
|
||||||
|
self.RULE_ID,
|
||||||
|
self.QOS_POLICY_ID,
|
||||||
|
min_kbps=self.RULE_MIN_KBPS_NEW)
|
||||||
|
self.assertEqual(self.RULE_MIN_KBPS_NEW, sot.min_kbps)
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
import uuid
|
||||||
|
|
||||||
from openstack.network.v2 import _proxy
|
from openstack.network.v2 import _proxy
|
||||||
from openstack.network.v2 import address_scope
|
from openstack.network.v2 import address_scope
|
||||||
@@ -28,6 +29,7 @@ from openstack.network.v2 import network_ip_availability
|
|||||||
from openstack.network.v2 import pool
|
from openstack.network.v2 import pool
|
||||||
from openstack.network.v2 import pool_member
|
from openstack.network.v2 import pool_member
|
||||||
from openstack.network.v2 import port
|
from openstack.network.v2 import port
|
||||||
|
from openstack.network.v2 import qos_minimum_bandwidth_rule
|
||||||
from openstack.network.v2 import qos_policy
|
from openstack.network.v2 import qos_policy
|
||||||
from openstack.network.v2 import quota
|
from openstack.network.v2 import quota
|
||||||
from openstack.network.v2 import rbac_policy
|
from openstack.network.v2 import rbac_policy
|
||||||
@@ -41,6 +43,10 @@ from openstack.network.v2 import vpn_service
|
|||||||
from openstack.tests.unit import test_proxy_base
|
from openstack.tests.unit import test_proxy_base
|
||||||
|
|
||||||
|
|
||||||
|
QOS_POLICY_ID = 'qos-policy-id-' + uuid.uuid4().hex
|
||||||
|
QOS_RULE_ID = 'qos-rule-id-' + uuid.uuid4().hex
|
||||||
|
|
||||||
|
|
||||||
class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNetworkProxy, self).setUp()
|
super(TestNetworkProxy, self).setUp()
|
||||||
@@ -383,6 +389,53 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
|||||||
def test_port_update(self):
|
def test_port_update(self):
|
||||||
self.verify_update(self.proxy.update_port, port.Port)
|
self.verify_update(self.proxy.update_port, port.Port)
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_create_attrs(self):
|
||||||
|
self.verify_create(
|
||||||
|
self.proxy.create_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
method_kwargs={'qos_policy': QOS_POLICY_ID},
|
||||||
|
expected_kwargs={'path_args': {'qos_policy_id': QOS_POLICY_ID}})
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_delete(self):
|
||||||
|
self.verify_delete(
|
||||||
|
self.proxy.delete_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
False, input_path_args=["resource_or_id", QOS_POLICY_ID],
|
||||||
|
expected_path_args={'qos_policy_id': QOS_POLICY_ID},)
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_delete_ignore(self):
|
||||||
|
self.verify_delete(
|
||||||
|
self.proxy.delete_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
True, input_path_args=["resource_or_id", QOS_POLICY_ID],
|
||||||
|
expected_path_args={'qos_policy_id': QOS_POLICY_ID}, )
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_find(self):
|
||||||
|
self.verify_find(self.proxy.find_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
path_args={'qos_policy_id': QOS_POLICY_ID})
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_get(self):
|
||||||
|
self.verify_get(
|
||||||
|
self.proxy.get_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
method_kwargs={'qos_policy': QOS_POLICY_ID},
|
||||||
|
expected_kwargs={'path_args': {'qos_policy_id': QOS_POLICY_ID}})
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rules(self):
|
||||||
|
self.verify_list(
|
||||||
|
self.proxy.qos_minimum_bandwidth_rules,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
paginated=False,
|
||||||
|
method_kwargs={'qos_policy': QOS_POLICY_ID},
|
||||||
|
expected_kwargs={'path_args': {'qos_policy_id': QOS_POLICY_ID}})
|
||||||
|
|
||||||
|
def test_qos_minimum_bandwidth_rule_update(self):
|
||||||
|
self.verify_update(
|
||||||
|
self.proxy.update_qos_minimum_bandwidth_rule,
|
||||||
|
qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule,
|
||||||
|
path_args={'qos_policy_id': QOS_POLICY_ID})
|
||||||
|
|
||||||
def test_qos_policy_create_attrs(self):
|
def test_qos_policy_create_attrs(self):
|
||||||
self.verify_create(self.proxy.create_qos_policy, qos_policy.QoSPolicy)
|
self.verify_create(self.proxy.create_qos_policy, qos_policy.QoSPolicy)
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
|
import testtools
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from openstack.network.v2 import qos_minimum_bandwidth_rule
|
||||||
|
|
||||||
|
EXAMPLE = {
|
||||||
|
'id': 'IDENTIFIER',
|
||||||
|
'qos_policy_id': 'qos-policy-' + uuid.uuid4().hex,
|
||||||
|
'min_kbps': 1500,
|
||||||
|
'direction': 'egress',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TestQoSMinimumBandwidthRule(testtools.TestCase):
|
||||||
|
|
||||||
|
def test_basic(self):
|
||||||
|
sot = qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule()
|
||||||
|
self.assertEqual('minimum_bandwidth_rule', sot.resource_key)
|
||||||
|
self.assertEqual('minimum_bandwidth_rules', sot.resources_key)
|
||||||
|
self.assertEqual(
|
||||||
|
'/qos/policies/%(qos_policy_id)s/minimum_bandwidth_rules',
|
||||||
|
sot.base_path)
|
||||||
|
self.assertEqual('network', sot.service.service_type)
|
||||||
|
self.assertTrue(sot.allow_create)
|
||||||
|
self.assertTrue(sot.allow_retrieve)
|
||||||
|
self.assertTrue(sot.allow_update)
|
||||||
|
self.assertTrue(sot.allow_delete)
|
||||||
|
self.assertTrue(sot.allow_list)
|
||||||
|
|
||||||
|
def test_make_it(self):
|
||||||
|
sot = qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule(EXAMPLE)
|
||||||
|
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||||
|
self.assertEqual(EXAMPLE['qos_policy_id'], sot.qos_policy_id)
|
||||||
|
self.assertEqual(EXAMPLE['min_kbps'], sot.min_kbps)
|
||||||
|
self.assertEqual(EXAMPLE['direction'], sot.direction)
|
||||||
|
|
||||||
|
def test_create_body(self):
|
||||||
|
params = copy.deepcopy(EXAMPLE)
|
||||||
|
body = (qos_minimum_bandwidth_rule.QoSMinimumBandwidthRule.
|
||||||
|
_get_create_body(params))
|
||||||
|
reference = copy.deepcopy(EXAMPLE)
|
||||||
|
reference.pop('qos_policy_id')
|
||||||
|
self.assertEqual(reference, body['minimum_bandwidth_rule'])
|
||||||
Reference in New Issue
Block a user