28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/vmaster/cli.rb', line 28
def self.config
unless @@config
if File.exists? @@config_file
config = YAML::load(File.open(@@config_file))
@@config = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
unless @@config[:profiles]
puts "WARNING: Please, reconfigure virtualmaster-cli (delete your '~/.virtualmaster' and run `virtualmaster config` again). This way you can use custom instance profiles correctly (new in version 0.0.5)"
puts
end
begin
@@api = DeltacloudVM::Client(VirtualMaster::DEFAULT_URL, @@config[:username], @@config[:password])
rescue DeltacloudVM::Client::BackendError => e
abort "Invalid API response: #{e.message}"
rescue Exception => e
abort "Unable to connect to Virtualmaster's DeltaCloud API: #{e.message}"
end
else
abort "Specified configuration file (#{config_file}) does not exist!"
end
end
@@config
end
|