Sha256: c45a3140d79f3b31867d33198a9306219b92afec12923c8c12c7614e90085db9
Contents?: true
Size: 873 Bytes
Versions: 21
Compression:
Stored size: 873 Bytes
Contents
Execute.define_task do desc "get-token", "Fetch current api token from rhoconnect" def get_token(save = true) require 'rest_client' url = config[:syncserver] password = '' begin system "stty -echo" password = ask "admin password: " system "stty echo" rescue NoMethodError, Interrupt system "stty echo" exit end puts '' begin token = RestClient.post("#{url}/rc/v1/system/login", { :login => 'rhoadmin', :password => password }.to_json, :content_type => :json) rescue Exception => e puts e.message puts "Rhoconnect server is not running or invalid credentials." exit end if save token_file = File.join(ENV['HOME'],'.rhoconnect_token') File.open(token_file,'w') {|f| f.write(token)} puts "Token is saved in: #{token_file}" end token end end
Version data entries
21 entries across 21 versions & 1 rubygems