[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 + 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
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
On Fri, Oct 30, 2020 at 03:05:36PM +0800, Sun Yukui wrote:
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
这里可以换个行
I got it
Thanks Luan Shengde
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
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
- def setup_default_yaml(account)
- default_yaml_dir = File.join('/home', account, '.config/compass-ci/defaults')
- FileUtils.mkdir_p default_yaml_dir
- 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.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'
align with if
Thanks, Jiaxin
On Fri, Oct 30, 2020 at 03:07:29PM +0800, Lin Jiaxin wrote:
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
- def setup_default_yaml(account)
- default_yaml_dir = File.join('/home', account, '.config/compass-ci/defaults')
- FileUtils.mkdir_p default_yaml_dir
- 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.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'
align with if
Thanks, Jiaxin
How about this: 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'
Thanks, Xijian
On Fri, Oct 30, 2020 at 03:34:50PM +0800, Xu Xijian wrote:
On Fri, Oct 30, 2020 at 03:07:29PM +0800, Lin Jiaxin wrote:
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
- def setup_default_yaml(account)
- default_yaml_dir = File.join('/home', account, '.config/compass-ci/defaults')
- FileUtils.mkdir_p default_yaml_dir
- 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.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'
align with if
Thanks, Jiaxin
How about this: 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'
yes, this can pass the rubocop
Thanks Luan Shengde
Thanks, Xijian
On Fri, Oct 30, 2020 at 03:07:29PM +0800, Lin Jiaxin wrote:
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
- def setup_default_yaml(account)
- default_yaml_dir = File.join('/home', account, '.config/compass-ci/defaults')
- FileUtils.mkdir_p default_yaml_dir
- 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.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'
if write like this, the rubocop will throw offenses: get_account_info.rb.bk:128:16: C: Layout/SpaceBeforeFirstArg: Put one space between the method name and the first argument. file.puts "lab: #{@data['lab']}" if @data.key? 'lab' ^^^^^^^^^^^
Thanks Luan Shengde
align with if
Thanks, Jiaxin
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
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
No need close if you use block.
Thanks, Xueliang
- end
- end
- def setup_authorized_key(account, pub_key) ssh_dir = File.join('/home/', account, '.ssh') Dir.mkdir ssh_dir, 0o700
-- 2.23.0
On Fri, Oct 30, 2020 at 03:17:41PM +0800, Cao Xueliang wrote:
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
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
No need close if you use block.
ok, I will try
Thanks Luan Shengde
Thanks, Xueliang
- end
- end
- def setup_authorized_key(account, pub_key) ssh_dir = File.join('/home/', account, '.ssh') Dir.mkdir ssh_dir, 0o700
-- 2.23.0
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
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'
just fail it (refuse assign account) if no above fields.
file.puts "lab: #{@data['lab']}" if @data.key? 'lab'
Where does lab comes from? Obviously lab should be our lab. This is our jumper vm.
Thanks, Fengguang
On Sun, Nov 01, 2020 at 11:55:46AM +0800, Wu Fengguang wrote:
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
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'
just fail it (refuse assign account) if no above fields.
I got it.
file.puts "lab: #{@data['lab']}" if @data.key? 'lab'
Where does lab comes from? Obviously lab should be our lab. This is our jumper vm.
I will fix this.
Thanks Luan Shengde
Thanks, Fengguang