On Fri, Oct 30, 2020 at 02:56:50PM +0800, Luan Shengde wrote:
[why]: esaier for user to config the default yaml file
[how]: when get request data, parse the data and write the user infos to default yaml file: ~/.config/compass-ci/default/${USER}.yaml include:
- my_email
- my_name
- my_uuid
- lab
Signed-off-by: Luan Shengde luanshengde2@huawei.com
container/assign-account/get_account_info.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/container/assign-account/get_account_info.rb b/container/assign-account/get_account_info.rb index 2f93d5b..4e61bdc 100755 --- a/container/assign-account/get_account_info.rb +++ b/container/assign-account/get_account_info.rb @@ -44,6 +44,8 @@ the returned data for setup_jumper_account_info like:
=end
+require 'fileutils'
# get jumper and account info class AccountStorage ACCOUNT_DIR = '/opt/account_data/' @@ -111,9 +113,23 @@ class AccountStorage }
setup_authorized_key(account, pub_key)
setup_default_yaml(account) if @data.key? 'my_email'
return jumper_account_info end
def setup_default_yaml(account)
default_yaml_dir = File.join('/home', account, '.config/compass-ci/defaults')
FileUtils.mkdir_p default_yaml_dir
这里可以换个行 Thanks sunyukui
- File.open("#{default_yaml_dir}/#{account}.yaml", 'a') do |file|
file.puts "my_email: #{@data['my_email']}"
file.puts "my_name: #{@data['my_name']}" if @data.key? 'my_name'
file.puts "my_uuid: #{@data['my_uuid']}" if @data.key? 'my_uuid'
file.puts "lab: #{@data['lab']}" if @data.key? 'lab'
file.close
- end
- end
- def setup_authorized_key(account, pub_key) ssh_dir = File.join('/home/', account, '.ssh') Dir.mkdir ssh_dir, 0o700
-- 2.23.0