public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
From: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
To: cip-dev@lists.cip-project.org
Cc: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Subject: [isar-cip-core][PATCH 3/4] Add script deploy-kernelci.py for upload the cip-core-image-kernelci
Date: Thu,  6 Jan 2022 20:16:13 +0900	[thread overview]
Message-ID: <20220106111614.218823-4-alice.ferrazzi@miraclelinux.com> (raw)
In-Reply-To: <20220106111614.218823-1-alice.ferrazzi@miraclelinux.com>

The cip-core-image-kernelci need to be uploaded to the KernelCI
production storage for been used by KernelCI.
This script use the KernelCI API for uploading the
cip-core-image-kernelci to the production storage.
The images are uploaded in the following link:
https://storage.kernelci.org/images/rootfs/cip/

Signed-off-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
---
 scripts/deploy-kernelci.py | 55 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100755 scripts/deploy-kernelci.py

diff --git a/scripts/deploy-kernelci.py b/scripts/deploy-kernelci.py
new file mode 100755
index 0000000..5a8adca
--- /dev/null
+++ b/scripts/deploy-kernelci.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import subprocess
+import requests
+import os
+import sys
+import time
+from urllib.parse import urljoin
+
+cdate=time.strftime("%Y%m%d")
+api="https://api.kernelci.org/upload"
+token=os.getenv("KERNELCI_TOKEN")
+
+release=sys.argv[1]
+target=sys.argv[2]
+extension=sys.argv[3]
+
+rootfs_filename="cip-core-image-kernelci-cip-core-"+release+"-"+target+".tar.gz"
+initrd_filename="cip-core-image-kernelci-cip-core-"+release+"-"+target+"-initrd.img"
+initrd_gz_filename="cip-core-image-kernelci-cip-core-"+release+"-"+target+"-initrd.img.gz"
+
+input_dir="build/tmp/deploy/images/"+target
+upload_path="/images/rootfs/cip/"+cdate+"/"+target+"/"
+upload_path_latest="/images/rootfs/cip/latest/"+target+"/"
+rootfs=input_dir+"/"+rootfs_filename
+initrd=input_dir+"/"+initrd_filename
+
+def upload_file(api, token, path, input_file, input_filename):
+    headers = {
+        'Authorization': token,
+    }
+    data = {
+        'path': path,
+    }
+    files = {
+        'file': (input_filename, open(input_file, 'rb').read()),
+    }
+    url = urljoin(api, 'upload')
+    resp = requests.post(url, headers=headers, data=data, files=files)
+    resp.raise_for_status()
+
+if os.path.exists(rootfs) and os.path.exists(initrd):
+    print("uploading rootfs to KernelCI")
+    upload_file(api, token, upload_path, rootfs, rootfs_filename)
+    print("uploading initrd to KernelCI")
+    upload_file(api, token, upload_path, initrd, initrd_gz_filename)
+    print("uploaded to: https://storage.kernelci.org"+upload_path)
+
+    # Upload latest
+    print("uploading rootfs to KernelCI CIP latest")
+    upload_file(api, token, upload_path_latest, rootfs, rootfs_filename)
+    print("uploading initrd to KernelCI CIP latest")
+    upload_file(api, token, upload_path_latest, initrd, initrd_gz_filename)
+    print("uploaded to: https://storage.kernelci.org"+upload_path_latest)
-- 
2.33.1



  parent reply	other threads:[~2022-01-06 11:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 11:16 [isar-cip-core][PATCH 0/4] Add cip-core-image-kernelci building and uploading system Alice Ferrazzi
2022-01-06 11:16 ` [isar-cip-core][PATCH 1/4] Add cip-core-image-kernelci Alice Ferrazzi
2022-01-06 14:01   ` Jan Kiszka
2022-01-07 10:16     ` Alice Ferrazzi
2022-01-06 11:16 ` [isar-cip-core][PATCH 2/4] Add dmesg filter needed for lava test result Alice Ferrazzi
2022-01-06 11:16 ` Alice Ferrazzi [this message]
2022-01-06 11:16 ` [isar-cip-core][PATCH 4/4] enable cip-core-image-kernelci Alice Ferrazzi
2022-01-06 14:12   ` Jan Kiszka
2022-01-07 10:02     ` Alice Ferrazzi
2022-01-07 10:07       ` Jan Kiszka
2022-01-07 10:23         ` Alice Ferrazzi
2022-01-07 11:18           ` Jan Kiszka
2022-01-07 13:40             ` Alice Ferrazzi
2022-01-07 13:46               ` Jan Kiszka
2022-01-06 13:43 ` [isar-cip-core][PATCH 0/4] Add cip-core-image-kernelci building and uploading system Jan Kiszka
2022-01-06 14:18 ` Jan Kiszka
2022-01-07  9:57   ` Alice Ferrazzi
2022-01-07 10:10     ` Jan Kiszka
2022-01-07 10:20       ` Alice Ferrazzi
     [not found]       ` <CANgtXuPc0_27ZCR7au1e-C3y+-7De-nZQ2ddmjKAinT7Cm09_A@mail.gmail.com>
2022-01-07 10:22         ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220106111614.218823-4-alice.ferrazzi@miraclelinux.com \
    --to=alice.ferrazzi@miraclelinux.com \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox