[original values] initrds_uri: 'initrd http://172.168.131.113:8800/initrd/osimage/openeuler/aarch64/20.03/20201022....
initrd http://172.168.131.113:8800/initrd/deps/nfs/debian/aarch64/sid/run-ipconfig_...
initrd http://172.17.0.1:8000/os/openeuler/aarch64/20.03/boot/modules-4.19.90-2003....
initrd http://172.17.0.1:8000/os/openeuler/aarch64/20.03/boot/headers-4.19.90-2003....
initrd http://172.168.131.113:8800/initrd/deps/initramfs/openeuler/aarch64/20.03/mp...
initrd http://172.168.131.113:8800/initrd/deps/initramfs/openeuler/aarch64/20.03/sp...
initrd http://172.168.131.113:8800/initrd/pkg/initramfs/openeuler/aarch64/20.03/mps...
initrd http://172.168.131.113:8800/initrd/pkg/initramfs/openeuler/aarch64/20.03/spi...
initrd http://172.168.131.113:8800/initrd/lkp/baijing/lkp-aarch64.cgz
initrd http://172.168.131.113:3000/job_initrd_tmpfs/crystal.146511/job.cgz
'
[now values] initrds_uri: - initrd http://172.168.131.113:8800/initrd/osimage/openeuler/aarch64/20.03/20201022.... - initrd http://172.168.131.113:8800/initrd/deps/nfs/debian/aarch64/sid/run-ipconfig_... - initrd http://172.17.0.1:8000/os/openeuler/aarch64/20.03/boot/modules-4.19.90-2003.... - initrd http://172.17.0.1:8000/os/openeuler/aarch64/20.03/boot/headers-4.19.90-2003.... - initrd http://172.168.131.113:8800/initrd/deps/initramfs/openeuler/aarch64/20.03/mp... - initrd http://172.168.131.113:8800/initrd/deps/initramfs/openeuler/aarch64/20.03/sp... - initrd http://172.168.131.113:8800/initrd/pkg/initramfs/openeuler/aarch64/20.03/mps... - initrd http://172.168.131.113:8800/initrd/pkg/initramfs/openeuler/aarch64/20.03/spi... - initrd http://172.168.131.113:8800/initrd/lkp/baijing/lkp-aarch64.cgz - initrd http://172.168.131.113:3087/job_initrd_tmpfs/crystal.147702/job.cgz
Signed-off-by: Bai Jing 799286817@qq.com --- src/scheduler/jobfile_operate.cr | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/scheduler/jobfile_operate.cr b/src/scheduler/jobfile_operate.cr index 98bf011..7ec3ea1 100644 --- a/src/scheduler/jobfile_operate.cr +++ b/src/scheduler/jobfile_operate.cr @@ -76,8 +76,24 @@ module Jobfile::Operate script_lines = JSON.parse(script_lines) end
+ def self.handle_job_field(job_content, fields) + fields.each do |field| + case field + when "initrds_uri" + values = job_content[field].to_s.split("\n").map(&.strip).reject!(&.empty?) + values = values.map { |value| JSON::Any.new(value) } + job_content[field] = JSON::Any.new(values) + end + end + + return job_content + end + def self.create_job_cpio(job_content : JSON::Any, base_dir : String) job_content = job_content.as_h + + need_to_handle = ["initrds_uri"] + tmp_job_content = handle_job_field(job_content.clone, need_to_handle)
# put job2sh in an array if job_content.has_key?("job2sh") @@ -100,8 +116,8 @@ module Jobfile::Operate # - this will create a <'#! jobs/pixz.yaml':> in the yaml file # - but the orange is <#! jobs/pixz.yaml> in the user job.yaml # tested : no effect to job.sh - File.open(temp_yaml, "w") do |file| - YAML.dump(job_content, file) + File.open(temp_yaml, "a") do |file| + YAML.dump(tmp_job_content, file) end
# generate unbroken job shell content