diff --git a/octavia/api/v2/types/listener.py b/octavia/api/v2/types/listener.py index 6ea100d455..5d1296e5e8 100644 --- a/octavia/api/v2/types/listener.py +++ b/octavia/api/v2/types/listener.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from octavia_lib.common import constants as lib_constants from wsme import types as wtypes from octavia.api.common import types @@ -111,7 +112,8 @@ class ListenerPOST(BaseListenerType): name = wtypes.wsattr(wtypes.StringType(max_length=255)) description = wtypes.wsattr(wtypes.StringType(max_length=255)) admin_state_up = wtypes.wsattr(bool, default=True) - protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS), + protocol = wtypes.wsattr(wtypes.Enum(str, + *lib_constants.LISTENER_SUPPORTED_PROTOCOLS), mandatory=True) protocol_port = wtypes.wsattr( wtypes.IntegerType(minimum=constants.MIN_PORT_NUMBER, @@ -205,7 +207,8 @@ class ListenerSingleCreate(BaseListenerType): name = wtypes.wsattr(wtypes.StringType(max_length=255)) description = wtypes.wsattr(wtypes.StringType(max_length=255)) admin_state_up = wtypes.wsattr(bool, default=True) - protocol = wtypes.wsattr(wtypes.Enum(str, *constants.SUPPORTED_PROTOCOLS), + protocol = wtypes.wsattr(wtypes.Enum(str, + *lib_constants.LISTENER_SUPPORTED_PROTOCOLS), mandatory=True) protocol_port = wtypes.wsattr( wtypes.IntegerType(minimum=constants.MIN_PORT_NUMBER, diff --git a/octavia/tests/functional/api/v2/test_listener.py b/octavia/tests/functional/api/v2/test_listener.py index 034676a460..6b5db1a777 100644 --- a/octavia/tests/functional/api/v2/test_listener.py +++ b/octavia/tests/functional/api/v2/test_listener.py @@ -2240,6 +2240,11 @@ class TestListener(base.BaseAPITest): 'protocol_port': 80} self.post(self.LISTENERS_PATH, lb_listener, status=400) + def test_create_listener_proxy_protocol(self): + lb_listener = {'protocol': 'PROXY', + 'protocol_port': 80} + self.post(self.LISTENERS_PATH, lb_listener, status=400) + def test_update_listener_bad_protocol(self): listener = self.create_listener(constants.PROTOCOL_TCP, 80, self.lb_id) self.set_lb_status(self.lb_id) @@ -2767,10 +2772,6 @@ class TestListener(base.BaseAPITest): self._test_update_protocol_insert_headers_mismatch( constants.PROTOCOL_HTTPS) - def test_update_protocol_PROXY_insert_headers(self): - self._test_update_protocol_insert_headers_mismatch( - constants.PROTOCOL_PROXY) - def test_update_protocol_TCP_insert_headers(self): self._test_update_protocol_insert_headers_mismatch( constants.PROTOCOL_TCP) diff --git a/releasenotes/notes/fix-listener-creation-allowing-pool-protocol-b9e9ef147f6eeaf4.yaml b/releasenotes/notes/fix-listener-creation-allowing-pool-protocol-b9e9ef147f6eeaf4.yaml new file mode 100644 index 0000000000..ad93faef12 --- /dev/null +++ b/releasenotes/notes/fix-listener-creation-allowing-pool-protocol-b9e9ef147f6eeaf4.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes listener creation failure when protocol used is PROXY or PROXYV2 + which are pool protocol and not listener protocol.