Requested by: curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>'
Signed-off-by: Ren Wen 15991987063@163.com --- src/scheduler/find_job_boot.cr | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index b2f0802..02cced6 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,28 @@ class Sched return response.to_json end
+ private def get_boot_libvirt(job : Job) + response = {} of String => String | Nil | Array(String) | JSON::Any + + 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"]? + # *templates* is used by libvirt + response["templates"] = job["templates"]? + + return response.to_json + end + private def get_boot_grub(job : Job) initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
@@ -176,6 +198,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"
On Wed, Jan 06, 2021 at 08:50:56PM +0800, Ren Wen wrote:
Requested by: curl -X GET 'http://<host>:<port>/boot.libvirt/mac/<mac_value>'
Signed-off-by: Ren Wen 15991987063@163.com
src/scheduler/find_job_boot.cr | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/find_job_boot.cr b/src/scheduler/find_job_boot.cr index b2f0802..02cced6 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,28 @@ class Sched return response.to_json end
- private def get_boot_libvirt(job : Job)
- response = {} of String => String | Nil | Array(String) | JSON::Any
- 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"]?
- # *templates* is used by libvirt
- response["templates"] = job["templates"]?
- return response.to_json
- end
- private def get_boot_grub(job : Job) initrd_lkp_cgz = "lkp-#{job.os_arch}.cgz"
@@ -176,6 +198,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
no need info field, if you want to use a flag to check whether a task exists, how about use {job_id=> ""} or {status => "0"}
Thanks, Shenwei
when "grub" return job ? get_boot_grub(job) : grub_msg("No job now") when "container"
-- 2.23.0
@@ -176,6 +198,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
no need info field, if you want to use a flag to check whether a task exists, how about use {job_id=> ""} or {status => "0"}
Got it! I'll use {job_id => ""}.
--- Thanks, RenWen
Thanks, Shenwei
when "grub" return job ? get_boot_grub(job) : grub_msg("No job now") when "container"
-- 2.23.0