An option for 'submit': -f, --upload-file FILE upload an XML template of libvirt
File's extension should be '.xml'.
Example:
case1: submit -f existent_file.xml => existent_file/<md5sum>.xml case2: submit -f nonexistent_file.xml => Find no file: nonexistent_file.xml
Signed-off-by: Ren Wen 15991987063@163.com --- lib/job2sh.rb | 10 ++++++++++ sbin/submit | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/lib/job2sh.rb b/lib/job2sh.rb index 7f9cf562f..14c4e3f4b 100755 --- a/lib/job2sh.rb +++ b/lib/job2sh.rb @@ -15,6 +15,16 @@ SHELL_BLOCK_KEYWORDS = { 'function' => ['{', '}'] }.freeze
+def cci_defaults + hash = {} + Dir.glob(['/etc/compass-ci/defaults/*.yaml', + '/etc/compass-ci/accounts/*.yaml', + "#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file| + hash.update YAML.load_file(file) || {} + end + hash +end + def valid_shell_variable?(key) key =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/ end diff --git a/sbin/submit b/sbin/submit index 39cdcf576..e9e10d903 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop']
options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end
+ opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file| + unless File.exist? file + puts "Find no file: #{file}" + exit 1 + end + + opt_upload_files << file + end + end
options.parse!(ARGV)
+def upload_configs(files) + defaults = cci_defaults() + upload_host = defaults['LKP_SERVER'] + upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081 + + files.each do |file| + response = `curl -sSf -T #{file} http://#%7Bupload_host%7D:#%7Bupload_port%7D/%60 + if $? == 0 + puts response + else + # TODO: how to deal with uploaded file when one failing + puts response + exit 1 + end + end + + exit 0 +end + +upload_configs(opt_upload_files) + seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '='
On Wed, Jan 20, 2021 at 08:36:07PM +0800, Ren Wen wrote:
An option for 'submit': -f, --upload-file FILE upload an XML template of libvirt
File's extension should be '.xml'.
Example:
case1: submit -f existent_file.xml => existent_file/<md5sum>.xml case2: submit -f nonexistent_file.xml => Find no file: nonexistent_file.xml
Signed-off-by: Ren Wen 15991987063@163.com
lib/job2sh.rb | 10 ++++++++++ sbin/submit | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/lib/job2sh.rb b/lib/job2sh.rb index 7f9cf562f..14c4e3f4b 100755 --- a/lib/job2sh.rb +++ b/lib/job2sh.rb @@ -15,6 +15,16 @@ SHELL_BLOCK_KEYWORDS = { 'function' => ['{', '}'] }.freeze
+def cci_defaults
- hash = {}
- Dir.glob(['/etc/compass-ci/defaults/*.yaml',
'/etc/compass-ci/accounts/*.yaml',
"#{ENV['HOME']}/.config/compass-ci/defaults/*.yaml"]).each do |file|
- hash.update YAML.load_file(file) || {}
- end
- hash
+end
This function has been implemented in compass-ci/container/defconfig.rb.
The "/etc" and "/home" has been loaded by "load_self_config" in "lkp-tests/lib/job.rb".
Do you still need the function?
Thanks, Xueliang
def valid_shell_variable?(key) key =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/ end diff --git a/sbin/submit b/sbin/submit index 39cdcf576..e9e10d903 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop']
options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end
- opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file|
- unless File.exist? file
puts "Find no file: #{file}"
exit 1
- end
- opt_upload_files << file
- end
end
options.parse!(ARGV)
+def upload_configs(files)
- defaults = cci_defaults()
- upload_host = defaults['LKP_SERVER']
- upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081
- files.each do |file|
- response = `curl -sSf -T #{file} http://#%7Bupload_host%7D:#%7Bupload_port%7D/%60
- if $? == 0
puts response
- else
# TODO: how to deal with uploaded file when one failing
puts response
exit 1
- end
- end
- exit 0
+end
+upload_configs(opt_upload_files)
seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '=' -- 2.23.0
This function has been implemented in compass-ci/container/defconfig.rb.
The "/etc" and "/home" has been loaded by "load_self_config" in "lkp-tests/lib/job.rb".
Do you still need the function?
I copied the funtion from "defconfig.rb". It's different from "load_self_config".
Thanks, RenWen
Thanks, Xueliang
def valid_shell_variable?(key) key =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/ end diff --git a/sbin/submit b/sbin/submit index 39cdcf576..e9e10d903 100755 --- a/sbin/submit +++ b/sbin/submit @@ -17,6 +17,7 @@ opt_auto_define_files = false opt_monitor = false opt_monitor_query = {} opt_my_queue = false +opt_upload_files = [] actions = ['output', 'stop']
options = OptionParser.new do |opts| @@ -64,10 +65,40 @@ options = OptionParser.new do |opts| opt_my_queue = true end
- opts.on('-f FILE', '--upload-file FILE', "upload an XML template of libvirt. File: *.xml") do |file|
- unless File.exist? file
puts "Find no file: #{file}"
exit 1
- end
- opt_upload_files << file
- end
end
options.parse!(ARGV)
+def upload_configs(files)
- defaults = cci_defaults()
- upload_host = defaults['LKP_SERVER']
- upload_port = defaults['UPLOAD_LIBVIRT_PORT'] || 3081
- files.each do |file|
- response = `curl -sSf -T #{file} http://#%7Bupload_host%7D:#%7Bupload_port%7D/%60
- if $? == 0
puts response
- else
# TODO: how to deal with uploaded file when one failing
puts response
exit 1
- end
- end
- exit 0
+end
+upload_configs(opt_upload_files)
seen_job_yaml = false ARGV.delete_if do |arg| if arg.index '=' -- 2.23.0