Class: ViCliConfig
- Inherits:
-
Object
- Object
- ViCliConfig
- Defined in:
- lib/ViCliConfig.rb
Instance Method Summary collapse
-
#initialize ⇒ ViCliConfig
constructor
A new instance of ViCliConfig.
- #keys ⇒ Object
- #login ⇒ Object
- #login=(login) ⇒ Object
- #login_needed? ⇒ Boolean
- #save ⇒ Object
- #tree_state ⇒ Object
- #tree_state=(state) ⇒ Object
Constructor Details
#initialize ⇒ ViCliConfig
Returns a new instance of ViCliConfig.
6 7 8 9 |
# File 'lib/ViCliConfig.rb', line 6 def initialize @config_file = File. "~/.vi_cli" @config = YAML.load_file @config_file end |
Instance Method Details
#keys ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ViCliConfig.rb', line 26 def keys return @config['keys'] unless @config['keys'].nil? @config['keys'] = { '&power on' => {'action' => 'powerOnVM_Task', 'check' => {'vm_on' => false, 'is_templ' => false} }, 'power on specific host' => {'action' => 'powerOnVM_Task', 'args' => ['HostSystem'], 'check' => {'vm_on' => false, 'is_templ' => false} }, '&unfold' => {'action' => 'unfold', 'check' => {'collapsed' => true} }, 'f&old' => {'action' => 'fold', 'check' => {'collapsed' => false} }, '&reboot guest' => {'action' => 'rebootGuest', 'check' => {'vm_on' => true} }, 'convert to &virtual machine' => { 'action' => 'markAsVirtualMachine', 'args' => ['ResourcePool'], 'check' => {'is_templ' => true } }, 'cut power' => {'action' => 'powerOffVM', 'check' => {'vm_on' => true} }, '&migrate' => {'action' => 'migrateVM_Task', 'args' => ['HostSystem'], 'check' => {'vm_on' => false} }, 'fold &children' => 'fold_children', 'convert to &template' => {'action' => 'markAsTemplate', 'check' => {'vm_off' => true, 'is_templ' => false} }, 'suspend' => {'action' => 'suspendVM_Task', 'check' => {'vm_on' => true} }, 'reset' => {'action' => 'resetVM_Task', 'check' => {'vm_on' => true} }, '&shutdown guest' => {'action' => 'shutdownGuest', 'check' => {'vm_on' => true} }, } end |
#login ⇒ Object
17 18 19 |
# File 'lib/ViCliConfig.rb', line 17 def login @config['login'] end |
#login=(login) ⇒ Object
20 21 22 |
# File 'lib/ViCliConfig.rb', line 20 def login= login @config['login'] = login end |
#login_needed? ⇒ Boolean
23 24 25 |
# File 'lib/ViCliConfig.rb', line 23 def login_needed? @config['login'].nil? end |
#save ⇒ Object
44 45 46 |
# File 'lib/ViCliConfig.rb', line 44 def save File.open(@config_file,'w').puts @config.to_yaml end |
#tree_state ⇒ Object
10 11 12 |
# File 'lib/ViCliConfig.rb', line 10 def tree_state @config['tree_state'] end |
#tree_state=(state) ⇒ Object
13 14 15 16 |
# File 'lib/ViCliConfig.rb', line 13 def tree_state= state @config['tree_state'] = state save end |