class RightScaleCLI::Configure

Public Class Methods

banner(task, namespace = true, subcommand = false) click to toggle source

default_task :all

new(*args) click to toggle source
Calls superclass method
# File lib/rightscale_cli/configure.rb, line 31
def initialize(*args)
  super
  @logger = RightScaleCLI::Logger.new()
  @config = RightScaleCLI::Config.new
  @directives = @config.directives
end

Public Instance Methods

account() click to toggle source
# File lib/rightscale_cli/configure.rb, line 45
def account()
  @directives.merge!( { :account_id => ask("RightScale account ID (e.g. 1337):")})
  update_conf
end
all() click to toggle source
# File lib/rightscale_cli/configure.rb, line 93
def all()
  # currently this is the lazy way, each is written sequentially
  account
  user
  password
  # do not ask for the api access token as we'll generate this from the refresh token
  # oauth
  refresh
  shard
  api
  puts 'Configuration saved.'
  if @directives[:refresh_token]
    puts 'Refresh API token now? (y/n):'
    if yesno
      system 'rs refresh token'
    end
  end
end
api() click to toggle source
# File lib/rightscale_cli/configure.rb, line 75
def api()
  @directives.merge!( { :api_version => ask("RightScale API version (e.g. 1.5):") })
  update_conf
end
oauth() click to toggle source
# File lib/rightscale_cli/configure.rb, line 63
def oauth()
  @directives.merge!( { :access_token => ask("RightScale API access token:") })
  update_conf
end
password() click to toggle source
# File lib/rightscale_cli/configure.rb, line 57
def password()
  @directives.merge!( { :password_base64 => Base64.encode64(ask_pass).strip })
  update_conf
end
refresh() click to toggle source
# File lib/rightscale_cli/configure.rb, line 69
def refresh()
  @directives.merge!( { :refresh_token => ask('RightScale API refresh token:') })
  update_conf
end
shard() click to toggle source
# File lib/rightscale_cli/configure.rb, line 81
def shard()
  shard = ask("RightScale shard (e.g. us-4.rightscale.com):")
  @directives.merge!( { :api_url => "https://#{shard}", :token_endpoint => "https://#{shard}/api/oauth2" })
  update_conf
end
show() click to toggle source
# File lib/rightscale_cli/configure.rb, line 88
def show()
  puts @directives
end
update_conf() click to toggle source
# File lib/rightscale_cli/configure.rb, line 39
def update_conf()
  File.open(@config.config_path, 'w') {|f| f.write(ERB.new(IO.read(@config.template_path)).result(binding)) }
end
user() click to toggle source
# File lib/rightscale_cli/configure.rb, line 51
def user()
  @directives.merge!( { :email => ask("RightScale username (e.g. bill.gates@microsoft.com):") })
  update_conf
end