From 8249ae9b837acb14a60e8d235cd0e8e1b4dde1c1 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Tue, 6 May 2025 15:14:27 +0000 Subject: [PATCH] Add an octavia-wsgi compatibility script This patch adds an octavia-wsgi script that gets installed with Octavia for backward compatibility on the stable branches. The pbr wsgi_scripts function no longer generates this script automatically due to recent changes in setuptools. This is a stable branch only patch. Change-Id: I7e0b17dbf9284db27e183a9a27e716266e26a237 (cherry picked from commit b8824ede82c42b81ca35248bd6ab6fb8bf51f3cd) --- bin/octavia-wsgi | 52 +++++++++++++++++++ ...compatibility-script-42b8aca87b98c904.yaml | 5 ++ setup.cfg | 2 + 3 files changed, 59 insertions(+) create mode 100644 bin/octavia-wsgi create mode 100644 releasenotes/notes/Add-octavia-wsgi-compatibility-script-42b8aca87b98c904.yaml diff --git a/bin/octavia-wsgi b/bin/octavia-wsgi new file mode 100644 index 0000000000..c371233a58 --- /dev/null +++ b/bin/octavia-wsgi @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +#PBR Generated from 'wsgi_scripts' - Archived for Octavia stable branches + +import threading + +from octavia.api.app import setup_app + +if __name__ == "__main__": + import argparse + import socket + import sys + import wsgiref.simple_server as wss + + parser = argparse.ArgumentParser( + description=setup_app.__doc__, + formatter_class=argparse.ArgumentDefaultsHelpFormatter, + usage='%(prog)s [-h] [--port PORT] [--host IP] -- [passed options]') + parser.add_argument('--port', '-p', type=int, default=8000, + help='TCP port to listen on') + parser.add_argument('--host', '-b', default='', + help='IP to bind the server to') + parser.add_argument('args', + nargs=argparse.REMAINDER, + metavar='-- [passed options]', + help="'--' is the separator of the arguments used " + "to start the WSGI server and the arguments passed " + "to the WSGI application.") + args = parser.parse_args() + if args.args: + if args.args[0] == '--': + args.args.pop(0) + else: + parser.error("unrecognized arguments: %s" % ' '.join(args.args)) + sys.argv[1:] = args.args + server = wss.make_server(args.host, args.port, setup_app()) + + print("*" * 80) + print("STARTING test server octavia.api.app.setup_app") + url = "http://%s:%d/" % (server.server_name, server.server_port) + print("Available at %s" % url) + print("DANGER! For testing only, do not use in production") + print("*" * 80) + sys.stdout.flush() + + server.serve_forever() +else: + application = None + app_lock = threading.Lock() + + with app_lock: + if application is None: + application = setup_app() diff --git a/releasenotes/notes/Add-octavia-wsgi-compatibility-script-42b8aca87b98c904.yaml b/releasenotes/notes/Add-octavia-wsgi-compatibility-script-42b8aca87b98c904.yaml new file mode 100644 index 0000000000..cf64c13ba9 --- /dev/null +++ b/releasenotes/notes/Add-octavia-wsgi-compatibility-script-42b8aca87b98c904.yaml @@ -0,0 +1,5 @@ +--- +other: + - | + Added a "octavia-wsgi" script for backward compatibility now that pbr's + wsgi_scripts no longer functions with the latest setuptools. diff --git a/setup.cfg b/setup.cfg index 329b46833d..24342e76ec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,8 @@ data_files = diskimage-create/test-requirements.txt diskimage-create/tox.ini diskimage-create/version.txt +scripts = + bin/octavia-wsgi [entry_points] wsgi_scripts =