diff --git a/doc/source/users/resources/network/index.rst b/doc/source/users/resources/network/index.rst index 19be0887e..b6e271b75 100644 --- a/doc/source/users/resources/network/index.rst +++ b/doc/source/users/resources/network/index.rst @@ -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 diff --git a/doc/source/users/resources/network/v2/qos_rule_type.rst b/doc/source/users/resources/network/v2/qos_rule_type.rst new file mode 100644 index 000000000..6d5ed5a8c --- /dev/null +++ b/doc/source/users/resources/network/v2/qos_rule_type.rst @@ -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: diff --git a/openstack/network/v2/_proxy.py b/openstack/network/v2/_proxy.py index a6e65fccb..6c94aab85 100644 --- a/openstack/network/v2/_proxy.py +++ b/openstack/network/v2/_proxy.py @@ -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) diff --git a/openstack/network/v2/qos_rule_type.py b/openstack/network/v2/qos_rule_type.py new file mode 100644 index 000000000..f56071134 --- /dev/null +++ b/openstack/network/v2/qos_rule_type.py @@ -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') diff --git a/openstack/tests/functional/network/v2/test_qos_rule_type.py b/openstack/tests/functional/network/v2/test_qos_rule_type.py new file mode 100644 index 000000000..96c545da3 --- /dev/null +++ b/openstack/tests/functional/network/v2/test_qos_rule_type.py @@ -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) diff --git a/openstack/tests/unit/network/v2/test_proxy.py b/openstack/tests/unit/network/v2/test_proxy.py index 8ed4b3aba..0f8c8e79f 100644 --- a/openstack/tests/unit/network/v2/test_proxy.py +++ b/openstack/tests/unit/network/v2/test_proxy.py @@ -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) diff --git a/openstack/tests/unit/network/v2/test_qos_rule_type.py b/openstack/tests/unit/network/v2/test_qos_rule_type.py new file mode 100644 index 000000000..7888c1c09 --- /dev/null +++ b/openstack/tests/unit/network/v2/test_qos_rule_type.py @@ -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)