Class: ViCliConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ViCliConfig.rb

Instance Method Summary collapse

Constructor Details

#initializeViCliConfig

Returns a new instance of ViCliConfig.



6
7
8
9
# File 'lib/ViCliConfig.rb', line 6

def initialize
  @config_file = File.expand_path "~/.vi_cli"
  @config = YAML.load_file @config_file
end

Instance Method Details

#keysObject



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

#loginObject



17
18
19
# File 'lib/ViCliConfig.rb', line 17

def 
  @config['login']
end

#login=(login) ⇒ Object



20
21
22
# File 'lib/ViCliConfig.rb', line 20

def login= 
  @config['login'] = 
end

#login_needed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ViCliConfig.rb', line 23

def 
  @config['login'].nil?
end

#saveObject



44
45
46
# File 'lib/ViCliConfig.rb', line 44

def save
  File.open(@config_file,'w').puts @config.to_yaml
end

#tree_stateObject



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