Tim Andersson has proposed merging 
~andersson123/autopkgtest-cloud:preserve-set-correct-content-encoding into 
autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/456887
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of 
~andersson123/autopkgtest-cloud:preserve-set-correct-content-encoding into 
autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/set-correct-headers-for-logs b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/set-correct-headers-for-logs
new file mode 100755
index 0000000..5d5bc95
--- /dev/null
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/set-correct-headers-for-logs
@@ -0,0 +1,81 @@
+#!/usr/bin/python3
+import configparser
+
+import swiftclient
+
+creds_file = "./swift-copy.conf"
+
+releases = "lunar focal jammy mantic noble"
+
+# swift-copy should look something like this:
+# [old]
+# OS_REGION_NAME=
+# OS_INTERFACE=
+# OS_AUTH_URL=
+# OS_PROJECT_DOMAIN_NAME=
+# OS_USERNAME=
+# OS_USER_DOMAIN_NAME=
+# OS_PROJECT_NAME=
+# OS_PASSWORD=
+# OS_IDENTITY_API_VERSION=
+
+# [new]
+# OS_REGION_NAME=
+# OS_INTERFACE=
+# OS_AUTH_URL=
+# OS_PROJECT_DOMAIN_NAME=
+# OS_USERNAME=
+# OS_USER_DOMAIN_NAME=
+# OS_PROJECT_NAME=
+# OS_PASSWORD=
+# OS_IDENTITY_API_VERSION=
+# But with the values filled out of course.
+
+conf = configparser.ConfigParser()
+conf.read(creds_file)
+
+swift_creds = {
+    "authurl": conf["new"]["OS_AUTH_URL"],
+    "user": conf["new"]["OS_USERNAME"],
+    "key": conf["new"]["OS_PASSWORD"],
+    "os_options": {
+        "region_name": conf["new"]["OS_REGION_NAME"],
+        "project_domain_name": conf["new"]["OS_PROJECT_DOMAIN_NAME"],
+        "user_domain_name": conf["new"]["OS_USER_DOMAIN_NAME"],
+        "project_name": conf["new"]["OS_PROJECT_NAME"],
+    },
+    "auth_version": "3.0",
+}
+
+swift_conn = swiftclient.Connection(**swift_creds)
+
+headers = {
+    "Content-Encoding": "gzip",
+    # "Content Type": "text/plain; charset=UTF-8"
+}
+
+
+for release in releases.split(" "):
+    container_name = "autopkgtest-" + release
+    print("On container: %s" % container_name)
+    _, objects = swift_conn.get_container(container_name, full_listing=True)
+    print("Objects acquired from container %s " % container_name)
+    for object in objects:
+        obj_name = object["name"]
+        if "log.gz" in obj_name:
+            print("Posting headers for object: %s" % obj_name)
+            # post the content-encoding and content-type stuff
+            while True:
+                try:
+                    swift_conn.post_object(
+                        container_name, obj_name, headers=headers
+                    )
+                    print(
+                        "Headers successfully posted for object %s" % obj_name
+                    )
+                    break
+                except Exception as _:
+                    print(
+                        "swift connection failed... Re-establishing connection."
+                    )
+                    swift_conn = swiftclient.Connection(**swift_creds)
-- 
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

Reply via email to