Class: VirtualMaster::CLI
- Inherits:
-
Object
- Object
- VirtualMaster::CLI
- Defined in:
- lib/vmaster/cli.rb
Constant Summary collapse
- @@config_file =
nil
- @@api =
nil
- @@config =
nil
- @@callbacks =
[]
Class Method Summary collapse
Class Method Details
.api ⇒ Object
21 22 23 24 25 26 |
# File 'lib/vmaster/cli.rb', line 21 def self.api self.config unless @@config abort "No configuration available! Please run 'virtualmaster config' first!" unless @@api @@api end |
.callbacks ⇒ Object
55 56 57 |
# File 'lib/vmaster/cli.rb', line 55 def self.callbacks @@callbacks end |
.config ⇒ Object
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 |
.config_file(config) ⇒ Object
17 18 19 |
# File 'lib/vmaster/cli.rb', line 17 def self.config_file(config) @@config_file = config end |
.run ⇒ Object
11 12 13 14 15 |
# File 'lib/vmaster/cli.rb', line 11 def self.run @@config_file = File.join(ENV["HOME"], ".virtualmaster") yield end |