[how] before: define my_name, my_email, lab, then store into ES and config yaml after: query my_name, my_email, lab, my_token from ES, then config yaml
[why] store account info into ES, this part already done by container service register-accounts, so when start auto-submit service, no need to store data, only query ES and config yaml.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- sbin/auto_submit | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/sbin/auto_submit b/sbin/auto_submit index 5648d59..d8c4b5a 100755 --- a/sbin/auto_submit +++ b/sbin/auto_submit @@ -7,6 +7,8 @@ require 'bunny' require 'json' require 'yaml' require_relative '../lib/build_my_info_client' +require 'set' +require "#{ENV['CCI_SRC']}/container/defconfig"
# receive message and auto submit job class AutoSubmit @@ -86,15 +88,30 @@ class AutoSubmit end end
-option = { - my_name: 'Auto Submit Robot', - my_email: 'autosubmit@localhost', - lab: `awk '/^lab:\s/ {print $2; exit}' /etc/compass-ci/defaults/*.yaml`.chomp -} +def my_email + names = Set.new %w[auto-submit] + + defaults = relevant_defaults(names) + defaults['auto-submit']['my_email'] +end + +def query_account_info + option = ESQuery.new(index: 'accounts').query_by_id(my_email) + raise "query auto-submit account info failed: #{my_email}" unless option + + option +end + +def config_yaml + option = query_account_info + + build_my_info = BuildMyInfo.new(option['my_email'], option['my_name'], option['lab'], option['my_token']) + build_my_info.config_default_yaml + build_my_info.config_lab_yaml +end
# fix verification problems when submit jobs by auto-submit service -build_my_info = BuildMyInfo.new(option[:my_email], option[:my_name], option[:lab]) -build_my_info.config_my_info +config_yaml
auto_submitter = AutoSubmit.new auto_submitter.listen