class DTK::Client::Operation::Account
Constants
- OPERATIONS
- RoutePrefix
Public Class Methods
add_key(path_to_key, opts = {})
click to toggle source
opts can have keys
:first_registration - Booelan (default: false) :name - (default: 'dtk-client')
# File lib/client/operation/account.rb, line 43 def self.add_key(path_to_key, opts = {}) match, matched_username = nil, nil unless File.file?(path_to_key) raise Error,"[ERROR] No ssh key file found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run `ssh-keygen -t rsa`)." end response = add_user_access(path_to_key, opts) if response.ok? and !response.data(:match) repo_manager_fingerprint, repo_manager_dns = response.data_ret_and_remove!(:repo_manager_fingerprint, :repo_manager_dns) SSHUtil.update_ssh_known_hosts(repo_manager_dns, repo_manager_fingerprint) OsUtil.print_info("SSH key '#{response.data('new_username')}' added successfully!") end response end
Private Class Methods
add_user_access(path_to_key, opts = {})
click to toggle source
opts can have keys
:first_registration - Booelan (default: false) :name - (default: 'dtk-client')
# File lib/client/operation/account.rb, line 65 def self.add_user_access(path_to_key, opts = {}) first_registration = opts[:first_registration] || false name = opts[:name] || 'dtk-client' rsa_pub_key = SSHUtil.read_and_validate_pub_key(path_to_key) post_body = { :rsa_pub_key => rsa_pub_key.chomp, :username => name && name.chomp, :first_registration => first_registration, } response = rest_post("#{RoutePrefix}/add_user_direct_access", post_body) end