Class: VMC::Cli::Command::Knifemisc

Inherits:
Misc
  • Object
show all
Includes:
KNIFE::Cli
Defined in:
lib/vmc_knife/commands/knife_cmds.rb

Constant Summary

Constants included from KNIFE::Cli

KNIFE::Cli::VERSION

Instance Method Summary collapse

Methods included from KNIFE::Cli

#load_manifest

Instance Method Details

#login(manifest_file_path = nil) ⇒ Object

configures the target and login according to the info in the manifest.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/vmc_knife/commands/knife_cmds.rb', line 152

def (manifest_file_path=nil)
  man  = load_manifest(manifest_file_path)
  target_url = man['target']
  raise "No target defined in the manifest #{@manifest_path}" if target_url.nil?
  puts "set_target #{target_url}"
  set_target(target_url)

  email = man['email']
  password = man['password']
  @options[:email] = email if email
  @options[:password] = password if password

  tries ||= 0
  # login_and_save_token:

  puts "login with #{email} #{password}"
  token = client.(email, password)
  VMC::Cli::Config.store_token(token)

rescue VMC::Client::TargetError
  display "Problem with login, invalid account or password.".red
  retry if (tries += 1) < 3 && prompt_ok && !@options[:password]
  exit 1
rescue => e
  display "Problem with login, #{e}, try again or register for an account.".red
  display e.backtrace
  exit 1

end