[isar-cip-core][PATCH v3 3/6] Add script deploy-kernelci.py for upload the cip-core-image-kernelci


Jan Kiszka
 

From: Alice Ferrazzi <alice.ferrazzi@...>

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@...>
Signed-off-by: Jan Kiszka <jan.kiszka@...>
---
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.31.1


Jan Kiszka
 

On 27.01.22 18:12, Jan Kiszka wrote:
From: Alice Ferrazzi <alice.ferrazzi@...>

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@...>
Signed-off-by: Jan Kiszka <jan.kiszka@...>
---
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]
Just stumbled over these:

We do not use "extension" (it's always "kernelci"), that's an easy
cleanup. But more important, we also pass the dtb while we do not push
it to kernelci - by intention?

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux


Alice Ferrazzi
 

We do not use "extension" (it's always "kernelci"), that's an easy
cleanup. But more important, we also pass the dtb while we do not push
it to kernelci - by intention?
I don't think changing extension to static name "kernelci" is useful.
about dtb you are right. currently I don't remember if it was intentional.
probably would be useful to upload also the dtb and we can than try to
find a way of make KernelCI work with the generated dtb.

Thanks,
Alicef

--
======================================
Cybertrust Japan Co.,Ltd.
Alice Ferrazzi
alice.ferrazzi@...
======================================


Alice Ferrazzi
 

On Sat, Sep 3, 2022 at 12:35 AM Alice Ferrazzi via
lists.cip-project.org
<alice.ferrazzi=miraclelinux.com@...> wrote:

We do not use "extension" (it's always "kernelci"), that's an easy
cleanup. But more important, we also pass the dtb while we do not push
it to kernelci - by intention?
I don't think changing extension to static name "kernelci" is useful.
about dtb you are right. currently I don't remember if it was intentional.
probably would be useful to upload also the dtb and we can than try to
find a way of make KernelCI work with the generated dtb.
I was looking again the script and extension variable is actually not
used anymore,
I thought from your text to just replace it with a static "kernelci" variable.
Works for me to remove it.

Thanks,
Alicef


--
======================================
Cybertrust Japan Co.,Ltd.
Alice Ferrazzi
alice.ferrazzi@...
======================================