Add QoS rule type object and CRUD commands.
Closes-Bug: 1612194 Depends-On: Idf319cd182304952071bc976a2e56c42fbcb8468 Change-Id: Iecf7bc7acd244a842aae963993f37a64a26b43b9
This commit is contained in:
parent
a7fd67507c
commit
dce331373f
@ -23,6 +23,7 @@ Network Resources
|
||||
v2/qos_dscp_marking_rule
|
||||
v2/qos_minimum_bandwidth_rule
|
||||
v2/qos_policy
|
||||
v2/qos_rule_type
|
||||
v2/quota
|
||||
v2/rbac_policy
|
||||
v2/router
|
||||
|
12
doc/source/users/resources/network/v2/qos_rule_type.rst
Normal file
12
doc/source/users/resources/network/v2/qos_rule_type.rst
Normal file
@ -0,0 +1,12 @@
|
||||
openstack.network.v2.qos_rule_type
|
||||
==================================
|
||||
|
||||
.. automodule:: openstack.network.v2.qos_rule_type
|
||||
|
||||
The QoSRuleType Class
|
||||
---------------------
|
||||
|
||||
The ``QoSRuleType`` class inherits from :class:`~openstack.resource.Resource`.
|
||||
|
||||
.. autoclass:: openstack.network.v2.qos_rule_type.QoSRuleType
|
||||
:members:
|
@ -32,6 +32,7 @@ from openstack.network.v2 import qos_dscp_marking_rule as \
|
||||
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_rule_type as _qos_rule_type
|
||||
from openstack.network.v2 import quota as _quota
|
||||
from openstack.network.v2 import rbac_policy as _rbac_policy
|
||||
from openstack.network.v2 import router as _router
|
||||
@ -1608,6 +1609,16 @@ class Proxy(proxy.BaseProxy):
|
||||
"""
|
||||
return self._update(_qos_policy.QoSPolicy, qos_policy, **attrs)
|
||||
|
||||
def qos_rule_types(self, **query):
|
||||
"""Return a generator of QoS rule types
|
||||
|
||||
:param kwargs \*\*query: Optional query parameters to be sent to limit
|
||||
the resources being returned.
|
||||
:returns: A generator of QoS rule type objects
|
||||
:rtype: :class:`~openstack.network.v2.qos_rule_type.QoSRuleType`
|
||||
"""
|
||||
return self._list(_qos_rule_type.QoSRuleType, paginated=False, **query)
|
||||
|
||||
def delete_quota(self, quota, ignore_missing=True):
|
||||
"""Delete a quota (i.e. reset to the default quota)
|
||||
|
||||
|
32
openstack/network/v2/qos_rule_type.py
Normal file
32
openstack/network/v2/qos_rule_type.py
Normal file
@ -0,0 +1,32 @@
|
||||
# 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 QoSRuleType(resource.Resource):
|
||||
resource_key = 'rule_type'
|
||||
resources_key = 'rule_types'
|
||||
base_path = '/qos/rule-types'
|
||||
service = network_service.NetworkService()
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_retrieve = False
|
||||
allow_update = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: QoS rule type name.
|
||||
type = resource.prop('type')
|
25
openstack/tests/functional/network/v2/test_qos_rule_type.py
Normal file
25
openstack/tests/functional/network/v2/test_qos_rule_type.py
Normal file
@ -0,0 +1,25 @@
|
||||
# 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 six
|
||||
|
||||
from openstack.tests.functional import base
|
||||
|
||||
|
||||
class TestQoSRuleType(base.BaseFunctionalTest):
|
||||
|
||||
def test_list(self):
|
||||
rule_types = list(self.conn.network.qos_rule_types())
|
||||
self.assertGreater(len(rule_types), 0)
|
||||
|
||||
for rule_type in rule_types:
|
||||
self.assertIsInstance(rule_type.type, six.string_types)
|
@ -33,6 +33,7 @@ from openstack.network.v2 import qos_bandwidth_limit_rule
|
||||
from openstack.network.v2 import qos_dscp_marking_rule
|
||||
from openstack.network.v2 import qos_minimum_bandwidth_rule
|
||||
from openstack.network.v2 import qos_policy
|
||||
from openstack.network.v2 import qos_rule_type
|
||||
from openstack.network.v2 import quota
|
||||
from openstack.network.v2 import rbac_policy
|
||||
from openstack.network.v2 import router
|
||||
@ -556,6 +557,10 @@ class TestNetworkProxy(test_proxy_base.TestProxyBase):
|
||||
def test_qos_policy_update(self):
|
||||
self.verify_update(self.proxy.update_qos_policy, qos_policy.QoSPolicy)
|
||||
|
||||
def test_qos_rule_types(self):
|
||||
self.verify_list(self.proxy.qos_rule_types, qos_rule_type.QoSRuleType,
|
||||
paginated=False)
|
||||
|
||||
def test_quota_delete(self):
|
||||
self.verify_delete(self.proxy.delete_quota, quota.Quota, False)
|
||||
|
||||
|
38
openstack/tests/unit/network/v2/test_qos_rule_type.py
Normal file
38
openstack/tests/unit/network/v2/test_qos_rule_type.py
Normal file
@ -0,0 +1,38 @@
|
||||
# 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 testtools
|
||||
|
||||
from openstack.network.v2 import qos_rule_type
|
||||
|
||||
EXAMPLE = {
|
||||
'type': 'bandwidth_limit',
|
||||
}
|
||||
|
||||
|
||||
class TestQoSRuleType(testtools.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
sot = qos_rule_type.QoSRuleType()
|
||||
self.assertEqual('rule_type', sot.resource_key)
|
||||
self.assertEqual('rule_types', sot.resources_key)
|
||||
self.assertEqual('/qos/rule-types', sot.base_path)
|
||||
self.assertEqual('network', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertFalse(sot.allow_retrieve)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = qos_rule_type.QoSRuleType(EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['type'], sot.type)
|
Loading…
Reference in New Issue
Block a user