A new way to find job, requested by:
curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>'
Signed-off-by: Ren Wen <15991987063(a)163.com>
---
src/scheduler/find_job_boot.cr | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr
index b2f0802..f6981e7 100644
--- a/src/scheduler/find_job_boot.cr
+++ b/src/scheduler/find_job_boot.cr
@@ -7,7 +7,7 @@ class Sched
boot_type = @env.params.url["boot_type"]
case boot_type
- when "ipxe"
+ when "ipxe", "libvirt"
host = @redis.hash_get("sched/mac2host", normalize_mac(value))
when "grub"
host = @redis.hash_get("sched/mac2host", normalize_mac(value))
@@ -135,6 +135,29 @@ class Sched
return response.to_json
end
+ private def get_boot_libvirt(job : Job)
+ response = {} of String => String | Nil | Array(String) | Hash(String, String)
+
+ response["job_id"] = job.id
+ response["kernel_uri"] = job.kernel_uri.lchop("kernel ")
+
+ initrds_uri = job["initrds_uri"]?
+ initrds_uri = initrds_uri.as_a.map(&.as_s.lchop("initrd ")) if initrds_uri
+ response["initrds_uri"] = initrds_uri
+
+ kernel_params = job["kernel_params"]?
+ kernel_params = kernel_params.as_a.map(&.to_s).reject(&.starts_with?("initrd=")).join(" ") if kernel_params
+ response["kernel_params"] = kernel_params
+
+ response["result_root"] = job.result_root
+ response["LKP_SERVER"] = "#{job["LKP_SERVER"]?}"
+
+ # Not implement now
+ response["templates"] = {} of String => String
+
+ return response.to_json
+ end
+
private def get_boot_grub(job : Job)
initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
@@ -176,6 +199,8 @@ class Sched
case boot_type
when "ipxe"
return job ? get_boot_ipxe(job) : ipxe_msg("No job now")
+ when "libvirt"
+ return job ? get_boot_libvirt(job) : {"info" => "No job now"}.to_json
when "grub"
return job ? get_boot_grub(job) : grub_msg("No job now")
when "container"
--
2.23.0