vi_cli 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/lib/VM.rb +5 -1
- data/lib/VMFolder.rb +3 -0
- data/lib/VcData.rb +9 -3
- data/lib/ViCli.rb +14 -2
- data/lib/ViCliConfig.rb +1 -0
- data/lib/Watcher.rb +10 -3
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.1.2 / 2009-06-15
|
2
|
+
|
3
|
+
* 1 bug fix
|
4
|
+
* Pause getchar thread when showing dialogs
|
5
|
+
* 1 major enhancement
|
6
|
+
* Cache arguments used in tasks
|
7
|
+
* 3 minor enhancements
|
8
|
+
* Cache virtual machine summary and hardware
|
9
|
+
* Show progress for running tasks
|
10
|
+
* Add power on specific host to virtual machine tasks
|
11
|
+
|
1
12
|
=== 0.1.1 / 2009-06-08
|
2
13
|
|
3
14
|
* 1 bug fix
|
data/lib/VM.rb
CHANGED
@@ -5,6 +5,7 @@ class VM
|
|
5
5
|
@ref = ref
|
6
6
|
@session = session
|
7
7
|
@name = name
|
8
|
+
@cached_state = Hash[ :state => [], :hw => [] ]
|
8
9
|
end
|
9
10
|
def name
|
10
11
|
@name.strip
|
@@ -95,7 +96,10 @@ class VM
|
|
95
96
|
res << [first ? 'notes' : '',a]
|
96
97
|
first = false
|
97
98
|
end
|
98
|
-
Hash[ :state => res, :hw => get_hw_info.compact ]
|
99
|
+
@cached_state = Hash[ :state => res, :hw => get_hw_info.compact ]
|
100
|
+
end
|
101
|
+
def cached_state
|
102
|
+
@cached_state
|
99
103
|
end
|
100
104
|
def execute_task task, *args
|
101
105
|
@ref.send task.to_sym, *args
|
data/lib/VMFolder.rb
CHANGED
data/lib/VcData.rb
CHANGED
@@ -20,11 +20,15 @@ class VcData
|
|
20
20
|
@session = $mock || VMware::Session.new(@connection)
|
21
21
|
@vm_folder = $mock || @session.root_folder.children[0].vm_folder
|
22
22
|
@refs = []
|
23
|
+
@entities = {}
|
23
24
|
@save_data = save_data
|
24
25
|
@tree_changed = false
|
25
26
|
end
|
26
27
|
def find_entities type
|
27
|
-
@
|
28
|
+
return @entities[type] unless @entities[type].nil?
|
29
|
+
@entities[type] = @session.find_entities(type).collect do |ref|
|
30
|
+
{ :ref => ref, :name => @session.wrap(ref)['name'].to_s }
|
31
|
+
end
|
28
32
|
end
|
29
33
|
def collect folder, save_data, indent=''
|
30
34
|
if folder.class.to_s == "VMware::Folder"
|
@@ -84,8 +88,10 @@ class VcData
|
|
84
88
|
desc = t['name'] || t['descriptionId'] # TODO use task descriptions form TaskManager
|
85
89
|
target = t['entityName']
|
86
90
|
cancelled = t['cancelled'].to_s
|
87
|
-
status = t['state']
|
88
|
-
status = t['error']['localizedMessage'] if status == 'error'
|
91
|
+
status = t['state'].to_s
|
92
|
+
status = t['error']['localizedMessage'].to_s if status == 'error'
|
93
|
+
status = t['progress'].to_s+'%' if status == 'running'
|
94
|
+
status = 'running' if status == '%'
|
89
95
|
user = t['reason']
|
90
96
|
user = user['userName'] || user['name'] || user['alarmName'] || '<System>'
|
91
97
|
start = t['startTime']
|
data/lib/ViCli.rb
CHANGED
@@ -32,7 +32,7 @@ class ViCli
|
|
32
32
|
def on_focus_callback index
|
33
33
|
add_tasks index
|
34
34
|
#TODO needs cached data for state and hardware
|
35
|
-
draw_state
|
35
|
+
draw_state @model.get :cached_state, index
|
36
36
|
@gui.refresh
|
37
37
|
@watcher.refresh_queue.push @gui.current_list_index
|
38
38
|
end
|
@@ -45,7 +45,9 @@ class ViCli
|
|
45
45
|
entities = @model.find_entities arg
|
46
46
|
return nil if entities.empty?
|
47
47
|
return entities.first[:ref] if entities.length == 1
|
48
|
+
@watcher.pause :getchar
|
48
49
|
selected = @gui.select entities.collect {|e| e[:name] }
|
50
|
+
@watcher.resume :getchar
|
49
51
|
entities.each {|e| return e[:ref] if e[:name] == selected }
|
50
52
|
end
|
51
53
|
def on_fire_callback index, key
|
@@ -64,6 +66,8 @@ class ViCli
|
|
64
66
|
end
|
65
67
|
def load_folders
|
66
68
|
@gui.set_status "Loading VM Folders ..."
|
69
|
+
args = @config.keys.values.collect { |i| i['args'] }
|
70
|
+
args.compact.flatten.uniq.each { |i| @model.find_entities i }
|
67
71
|
@model.refresh_list
|
68
72
|
@gui.draw_list @model.vm_list
|
69
73
|
@watcher.refresh_queue.push @gui.current_list_index
|
@@ -102,7 +106,15 @@ class ViCli
|
|
102
106
|
end
|
103
107
|
def setup_queues
|
104
108
|
#@watcher.register(:resize) { |q| loop { q.push sleep 5 } }
|
105
|
-
@watcher.register(:getchar)
|
109
|
+
@watcher.register(:getchar) do |q|
|
110
|
+
loop do
|
111
|
+
begin
|
112
|
+
loop { q.push @gui.getchar }
|
113
|
+
rescue => ex
|
114
|
+
Thread.stop
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
106
118
|
@watcher.register(:sleep) do |q|
|
107
119
|
loop do
|
108
120
|
start = Time.now
|
data/lib/ViCliConfig.rb
CHANGED
@@ -27,6 +27,7 @@ class ViCliConfig
|
|
27
27
|
return @config['keys'] unless @config['keys'].nil?
|
28
28
|
@config['keys'] = {
|
29
29
|
'&power on' => {'action' => 'powerOnVM_Task', 'check' => {'vm_on' => false, 'is_templ' => false} },
|
30
|
+
'power on specific host' => {'action' => 'powerOnVM_Task', 'args' => ['HostSystem'], 'check' => {'vm_on' => false, 'is_templ' => false} },
|
30
31
|
'&unfold' => {'action' => 'unfold', 'check' => {'collapsed' => true} },
|
31
32
|
'f&old' => {'action' => 'fold', 'check' => {'collapsed' => false} },
|
32
33
|
'&reboot guest' => {'action' => 'rebootGuest', 'check' => {'vm_on' => true} },
|
data/lib/Watcher.rb
CHANGED
@@ -8,6 +8,7 @@ class Watcher
|
|
8
8
|
def initialize
|
9
9
|
@queue = Queue.new
|
10
10
|
@queues = {}
|
11
|
+
@threads = {}
|
11
12
|
@refresh_queue = LastQueue.new
|
12
13
|
end
|
13
14
|
def update
|
@@ -17,11 +18,17 @@ class Watcher
|
|
17
18
|
@queue.pop
|
18
19
|
end
|
19
20
|
def [] key
|
20
|
-
@queues[key
|
21
|
+
@queues[key]
|
21
22
|
end
|
22
23
|
def register name, &block
|
23
|
-
q = @queues[name
|
24
|
-
Thread.new q, &block
|
24
|
+
q = @queues[name] = ObservedQueue.new(self)
|
25
|
+
@threads[name] = Thread.new q, &block
|
26
|
+
end
|
27
|
+
def pause name
|
28
|
+
@threads[name].raise "sleep!"
|
29
|
+
end
|
30
|
+
def resume name
|
31
|
+
@threads[name].wakeup
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vi_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SebDE
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-15 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|