From 9817dc494bdfe705f66e01ccf3431b29529bb0f9 Mon Sep 17 00:00:00 2001 From: Hirofumi Ichihara Date: Sun, 26 Mar 2017 23:52:51 +0900 Subject: [PATCH] Add ACTION_STATUS to dummy of API definition Neutron API extension may need specific action status for the API. Some extensions(e.g. tag and tag-ext) already have it. Change-Id: I0979b727171ad7b91641e0d9e0697da1e47c493f --- neutron_lib/api/definitions/_dummy.py | 10 ++++++++++ neutron_lib/api/definitions/base.py | 10 ++++++++++ neutron_lib/api/definitions/bgpvpn.py | 4 ++++ neutron_lib/api/definitions/data_plane_status.py | 4 ++++ neutron_lib/api/definitions/fip64.py | 4 ++++ neutron_lib/api/definitions/firewall.py | 4 ++++ neutron_lib/api/definitions/firewall_v2.py | 4 ++++ neutron_lib/api/definitions/firewallrouterinsertion.py | 4 ++++ neutron_lib/api/definitions/l3.py | 4 ++++ neutron_lib/api/definitions/logging_resource.py | 4 ++++ neutron_lib/api/definitions/port_security.py | 4 ++++ neutron_lib/api/definitions/portbindings.py | 4 ++++ neutron_lib/api/definitions/provider_net.py | 4 ++++ neutron_lib/api/definitions/router_interface_fip.py | 4 ++++ neutron_lib/api/definitions/trunk.py | 4 ++++ neutron_lib/api/definitions/trunk_details.py | 4 ++++ neutron_lib/tests/unit/api/definitions/base.py | 10 ++++++++++ .../notes/add-action-status-3dbfe2490a0d231a.yaml | 4 ++++ 18 files changed, 90 insertions(+) create mode 100644 releasenotes/notes/add-action-status-3dbfe2490a0d231a.yaml diff --git a/neutron_lib/api/definitions/_dummy.py b/neutron_lib/api/definitions/_dummy.py index 11673f618..e552dc99a 100644 --- a/neutron_lib/api/definitions/_dummy.py +++ b/neutron_lib/api/definitions/_dummy.py @@ -104,6 +104,16 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { ACTION_MAP = { } +# The action status: it associates response statuses with methods to be +# performed on the API resource (mandatory). For example: +# +# ACTION_STATUS = { +# 'create': 201, +# 'delete': 204 +# } +ACTION_STATUS = { +} + # The list of required extensions (mandatory). REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 38f183cae..b2e0ec5e1 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -37,6 +37,16 @@ KNOWN_HTTP_ACTIONS = ( 'PUT', ) +KNOWN_ACTION_STATUSES = ( + 200, + 201, + 202, + 203, + 204, + 205, + 206, +) + KNOWN_EXTENSIONS = ( 'address-scope', 'agent', diff --git a/neutron_lib/api/definitions/bgpvpn.py b/neutron_lib/api/definitions/bgpvpn.py index 2c4b11a8c..bac79fd3e 100644 --- a/neutron_lib/api/definitions/bgpvpn.py +++ b/neutron_lib/api/definitions/bgpvpn.py @@ -179,6 +179,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { ACTION_MAP = { } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [l3.ALIAS] diff --git a/neutron_lib/api/definitions/data_plane_status.py b/neutron_lib/api/definitions/data_plane_status.py index 5bcbf604d..f102e102d 100644 --- a/neutron_lib/api/definitions/data_plane_status.py +++ b/neutron_lib/api/definitions/data_plane_status.py @@ -69,6 +69,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { ACTION_MAP = { } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/fip64.py b/neutron_lib/api/definitions/fip64.py index 7a11d3f9f..e7ef276ca 100644 --- a/neutron_lib/api/definitions/fip64.py +++ b/neutron_lib/api/definitions/fip64.py @@ -48,6 +48,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = None # The action map. ACTION_MAP = {} +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ l3.ALIAS, diff --git a/neutron_lib/api/definitions/firewall.py b/neutron_lib/api/definitions/firewall.py index 64c8c1700..a232d3582 100644 --- a/neutron_lib/api/definitions/firewall.py +++ b/neutron_lib/api/definitions/firewall.py @@ -166,6 +166,10 @@ ACTION_MAP = { 'firewall_policy': {'insert_rule': 'PUT', 'remove_rule': 'PUT'}, } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/firewall_v2.py b/neutron_lib/api/definitions/firewall_v2.py index 99a61fe17..36eae0c7e 100644 --- a/neutron_lib/api/definitions/firewall_v2.py +++ b/neutron_lib/api/definitions/firewall_v2.py @@ -182,6 +182,10 @@ ACTION_MAP = { 'firewall_policy': {'insert_rule': 'PUT', 'remove_rule': 'PUT'}, } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/firewallrouterinsertion.py b/neutron_lib/api/definitions/firewallrouterinsertion.py index 00f41fd6f..d4264f673 100644 --- a/neutron_lib/api/definitions/firewallrouterinsertion.py +++ b/neutron_lib/api/definitions/firewallrouterinsertion.py @@ -60,6 +60,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { ACTION_MAP = { } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/l3.py b/neutron_lib/api/definitions/l3.py index 6bf800941..79f92f199 100644 --- a/neutron_lib/api/definitions/l3.py +++ b/neutron_lib/api/definitions/l3.py @@ -151,6 +151,10 @@ ACTION_MAP = { } } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/logging_resource.py b/neutron_lib/api/definitions/logging_resource.py index 7386ecedd..c66089a40 100644 --- a/neutron_lib/api/definitions/logging_resource.py +++ b/neutron_lib/api/definitions/logging_resource.py @@ -126,6 +126,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { # The action map. ACTION_MAP = {} +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ firewall.ALIAS, diff --git a/neutron_lib/api/definitions/port_security.py b/neutron_lib/api/definitions/port_security.py index 4e1dffd44..c077f6e02 100644 --- a/neutron_lib/api/definitions/port_security.py +++ b/neutron_lib/api/definitions/port_security.py @@ -80,6 +80,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {} # the API resource. ACTION_MAP = {} +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [] diff --git a/neutron_lib/api/definitions/portbindings.py b/neutron_lib/api/definitions/portbindings.py index 32d02cc4f..af39c47fb 100644 --- a/neutron_lib/api/definitions/portbindings.py +++ b/neutron_lib/api/definitions/portbindings.py @@ -188,6 +188,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = None ACTION_MAP = { } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/provider_net.py b/neutron_lib/api/definitions/provider_net.py index 5c4e24cfa..8ff8437f9 100644 --- a/neutron_lib/api/definitions/provider_net.py +++ b/neutron_lib/api/definitions/provider_net.py @@ -98,6 +98,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = None ACTION_MAP = { } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ ] diff --git a/neutron_lib/api/definitions/router_interface_fip.py b/neutron_lib/api/definitions/router_interface_fip.py index dc72f44ab..bc43e0f2f 100644 --- a/neutron_lib/api/definitions/router_interface_fip.py +++ b/neutron_lib/api/definitions/router_interface_fip.py @@ -48,6 +48,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = None # The action map. ACTION_MAP = {} +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ l3.ALIAS, diff --git a/neutron_lib/api/definitions/trunk.py b/neutron_lib/api/definitions/trunk.py index 4ef61db03..6d7e2f3df 100644 --- a/neutron_lib/api/definitions/trunk.py +++ b/neutron_lib/api/definitions/trunk.py @@ -89,6 +89,10 @@ ACTION_MAP = { } } +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [ "binding", diff --git a/neutron_lib/api/definitions/trunk_details.py b/neutron_lib/api/definitions/trunk_details.py index 75edd4fbc..64f299e4d 100644 --- a/neutron_lib/api/definitions/trunk_details.py +++ b/neutron_lib/api/definitions/trunk_details.py @@ -64,6 +64,10 @@ SUB_RESOURCE_ATTRIBUTE_MAP = None # The action map. ACTION_MAP = None +# The action status. +ACTION_STATUS = { +} + # The list of required extensions. REQUIRED_EXTENSIONS = [trunk.ALIAS] diff --git a/neutron_lib/tests/unit/api/definitions/base.py b/neutron_lib/tests/unit/api/definitions/base.py index 7bc700f31..79b30ad30 100644 --- a/neutron_lib/tests/unit/api/definitions/base.py +++ b/neutron_lib/tests/unit/api/definitions/base.py @@ -84,6 +84,7 @@ class DefinitionBaseTestCase(test_base.BaseTestCase): self.resource_map = self.extension_module.RESOURCE_ATTRIBUTE_MAP self.subresource_map = self.extension_module.SUB_RESOURCE_ATTRIBUTE_MAP self.action_map = self.extension_module.ACTION_MAP + self.action_status = self.extension_module.ACTION_STATUS self.required_extensions = self.extension_module.REQUIRED_EXTENSIONS self.optional_extensions = self.extension_module.OPTIONAL_EXTENSIONS @@ -93,6 +94,7 @@ class DefinitionBaseTestCase(test_base.BaseTestCase): self.assertFalse(self.extension_attributes) self.assertFalse(self.resource_map) self.assertFalse(self.action_map) + self.assertFalse(self.action_status) def test_is_standard_attr_extension(self): if self.is_standard_attr_extension: @@ -154,6 +156,14 @@ class DefinitionBaseTestCase(test_base.BaseTestCase): self.assertIn(action, base.KNOWN_HTTP_ACTIONS, 'HTTP verb is unknown, check for typos.') + def test_action_status(self): + if not self.action_status: + self.skipTest('API definition has no action status.') + + for status in self.action_status.values(): + self.assertIn(status, base.KNOWN_ACTION_STATUSES, + 'HTTP status is unknown, check for typos.') + def test_required_extensions(self): if not self.required_extensions: self.skipTest('API definition has no required extensions.') diff --git a/releasenotes/notes/add-action-status-3dbfe2490a0d231a.yaml b/releasenotes/notes/add-action-status-3dbfe2490a0d231a.yaml new file mode 100644 index 000000000..c20050e6f --- /dev/null +++ b/releasenotes/notes/add-action-status-3dbfe2490a0d231a.yaml @@ -0,0 +1,4 @@ +--- +features: + - The ``ACTION_STATUS`` is added to API definitions for neutron extension has + specific ``action_status``. \ No newline at end of file