Ural Tunaboyu has proposed merging ~uralt/autopkgtest-cloud:ppa-endpoint into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~uralt/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/477579 Add a new /ppa/<ppa> endpoint for viewing PPA results. For now all it does is list hyperlinks to all swift objects in a PPA container. -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~uralt/autopkgtest-cloud:ppa-endpoint into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi index 3e7838a..aeb42b4 100755 --- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi +++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi @@ -30,6 +30,7 @@ from helpers.utils import ( get_supported_releases, setup_key, ) +from swiftclient import ClientException, Connection from werkzeug.middleware.proxy_fix import ProxyFix # Initialize app @@ -47,6 +48,7 @@ secret_path = os.path.join(PATH, "secret_key") setup_key(app, secret_path) db_con = None +swift_con = None CONFIG = {} ALL_UBUNTU_RELEASES = get_all_releases() @@ -802,6 +804,42 @@ def release(release, arch=None): ) +def connect_swift(): + global swift_con + + if not swift_con: + swift_con = Connection( + authurl=os.environ["OS_AUTH_URL"], + user=os.environ["OS_USERNAME"], + key=os.environ["OS_PASSWORD"], + tenant_name=os.environ["OS_PROJECT_NAME"], + os_options={ + "region_name": os.environ["OS_REGION_NAME"], + "project_domain_name": os.environ["OS_PROJECT_DOMAIN_NAME"], + "project_name": os.environ["OS_PROJECT_NAME"], + "user_domain_name": os.environ["OS_USER_DOMAIN_NAME"], + }, + auth_version=os.environ["OS_IDENTITY_API_VERSION"], + retries=10, + starting_backoff=10, + ) + + return swift_con + + +@app.route("/ppa/<ppa>") +def ppa(ppa): + swift_con = connect_swift() + + try: + (_, ppa_container) = swift_con.get_container(ppa) + except ClientException as ce: + raise NotFound("ppa", ppa) from ce + object_names = [object["name"] for object in ppa_container] + + return render("browse-ppa.html", ppa_name=ppa, object_names=object_names) + + @app.route("/running") def running(): (releases, arches, queues_info) = get_queues_info() diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-ppa.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-ppa.html new file mode 100644 index 0000000..38e54ba --- /dev/null +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-ppa.html @@ -0,0 +1,18 @@ +{% extends "browse-layout.html" %} +{% import "macros.html" as macros %} + +{% block content %} + <h2>PPA logs and artifacts for {{ ppa_name }}</h2> + + {% if object_names %} + <ul> + {% for name in object_names %} + <li> + <a href="{{ base_url }}results/{{ name }}">{{ name }}</a> + </li> + {% endfor %} + </ul> + {% else %} + <p>No results found for PPA</p> + {% endif %} +{% endblock content %}
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp