rvc 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/rvc/modules/vim.rb +1 -1
- data/lib/rvc/modules/vmrc.rb +86 -21
- data/test/_test_completion.rb +27 -0
- data/test/_test_option_parser.rb +6 -0
- metadata +17 -2
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.5
|
data/lib/rvc/modules/vim.rb
CHANGED
data/lib/rvc/modules/vmrc.rb
CHANGED
@@ -19,17 +19,28 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'tmpdir'
|
22
|
+
require 'digest/sha2'
|
23
|
+
require 'zip'
|
24
|
+
require 'rbconfig'
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
case RbConfig::CONFIG['host_os']
|
27
|
+
when /mswin/, /mingw/
|
28
|
+
VMRC_NAME = "vmware-vmrc-win32-x86-3.0.0-309851"
|
29
|
+
VMRC_SHA256 = "8d8f9655121db5987bef1c2fa3a08ef2c4dd7769eb230bbd5b3ba9fd9576db56"
|
30
|
+
VMRC_BIN = "vmware-vmrc.exe"
|
31
|
+
when /linux/
|
32
|
+
VMRC_NAME = "vmware-vmrc-linux-x86-3.0.0-309851"
|
33
|
+
VMRC_SHA256 = "c86ecd9d9a1dd909a119c19d28325cb87d6e2853885d3014a7dac65175dd2ae1"
|
34
|
+
VMRC_BIN = "vmware-vmrc"
|
35
|
+
else
|
36
|
+
$stderr.puts "No VMRC available for OS #{RbConfig::CONFIG['host_os']}"
|
37
|
+
end
|
28
38
|
|
29
|
-
|
39
|
+
VMRC_BASENAME = "#{VMRC_NAME}.xpi"
|
40
|
+
VMRC_URL = "http://cloud.github.com/downloads/vmware/rvc/#{VMRC_BASENAME}"
|
30
41
|
|
31
42
|
def find_local_vmrc
|
32
|
-
path = File.join(Dir.tmpdir, VMRC_NAME, 'plugins',
|
43
|
+
path = File.join(Dir.tmpdir, VMRC_NAME, 'plugins', VMRC_BIN)
|
33
44
|
File.exists?(path) && path
|
34
45
|
end
|
35
46
|
|
@@ -54,6 +65,19 @@ def view vms
|
|
54
65
|
moref = vm._ref
|
55
66
|
ticket = vm._connection.serviceInstance.content.sessionManager.AcquireCloneTicket
|
56
67
|
host = vm._connection._host
|
68
|
+
spawn_vmrc vmrc, moref, host, ticket
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
case RbConfig::CONFIG['host_os']
|
73
|
+
when /mswin/, /mingw/
|
74
|
+
def spawn_vmrc vmrc, moref, host, ticket
|
75
|
+
err "Ruby 1.9 required" unless Process.respond_to? :spawn
|
76
|
+
Process.spawn vmrc, '-h', host, '-p', ticket, '-M', moref,
|
77
|
+
:err => "#{ENV['HOME']||'.'}/.rvc-vmrc.log"
|
78
|
+
end
|
79
|
+
else
|
80
|
+
def spawn_vmrc vmrc, moref, host, ticket
|
57
81
|
fork do
|
58
82
|
ENV['https_proxy'] = ENV['HTTPS_PROXY'] = ''
|
59
83
|
$stderr.reopen("#{ENV['HOME']||'.'}/.rvc-vmrc.log", "a")
|
@@ -61,30 +85,71 @@ def view vms
|
|
61
85
|
$stderr.puts "Using VMRC #{vmrc}"
|
62
86
|
$stderr.flush
|
63
87
|
Process.setpgrp
|
64
|
-
exec vmrc, '-M', moref,
|
65
|
-
'-h', host,
|
66
|
-
'-p', ticket
|
88
|
+
exec vmrc, '-M', moref, '-h', host, '-p', ticket
|
67
89
|
end
|
68
90
|
end
|
69
91
|
end
|
70
92
|
|
93
|
+
|
71
94
|
opts :install do
|
72
95
|
summary "Install VMRC"
|
73
96
|
end
|
74
97
|
|
75
98
|
def install
|
76
|
-
|
77
|
-
|
99
|
+
zip_filename = File.join(Dir.tmpdir, VMRC_BASENAME)
|
100
|
+
download VMRC_URL, zip_filename
|
101
|
+
verify zip_filename, VMRC_SHA256
|
102
|
+
extract zip_filename, File.join(Dir.tmpdir, VMRC_NAME)
|
103
|
+
puts "VMRC was installed successfully."
|
104
|
+
end
|
105
|
+
|
106
|
+
def download url_str, dest
|
78
107
|
puts "Downloading VMRC..."
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
108
|
+
|
109
|
+
url = URI.parse(url_str)
|
110
|
+
|
111
|
+
http = if ENV['http_proxy']
|
112
|
+
proxy_uri = URI.parse(ENV['http_proxy'])
|
113
|
+
proxy_user, proxy_pass = proxy_uri.userinfo.split(/:/) if proxy_uri.userinfo
|
114
|
+
Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_user, proxy_pass)
|
115
|
+
else
|
116
|
+
Net::HTTP
|
117
|
+
end
|
118
|
+
|
119
|
+
begin
|
120
|
+
File.open(dest, 'wb') do |io|
|
121
|
+
res = http.start(url.host, url.port) do |http|
|
122
|
+
http.get(url.path) do |segment|
|
123
|
+
io.write segment
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
rescue Exception
|
128
|
+
err "Error downloading VMRC: #{$!.class}: #{$!.message}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def verify filename, expected_hash
|
83
133
|
puts "Checking integrity..."
|
84
|
-
|
85
|
-
|
134
|
+
hexdigest = Digest::SHA256.file(filename).hexdigest
|
135
|
+
err "Hash mismatch" if hexdigest != VMRC_SHA256
|
136
|
+
end
|
137
|
+
|
138
|
+
def extract src, dst
|
86
139
|
puts "Installing VMRC..."
|
87
|
-
|
88
|
-
|
89
|
-
|
140
|
+
FileUtils.mkdir_p dst
|
141
|
+
Zip::ZipFile.open(src) do |zf|
|
142
|
+
zf.each do |e|
|
143
|
+
dst_filename = File.join(dst, e.name)
|
144
|
+
case e.ftype
|
145
|
+
when :file
|
146
|
+
zf.extract e.name, dst_filename
|
147
|
+
File.chmod(e.unix_perms, dst_filename) if e.unix_perms
|
148
|
+
when :directory
|
149
|
+
FileUtils.mkdir_p dst_filename
|
150
|
+
else
|
151
|
+
$stderr.puts "unknown file type #{e.ftype}"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
90
155
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rvc'
|
3
|
+
require 'inventory_fixtures'
|
4
|
+
|
5
|
+
class CompletionTest < Test::Unit::TestCase
|
6
|
+
NodeBaz = FixtureNode.new
|
7
|
+
NodeBar = FixtureNode.new
|
8
|
+
NodeFoo = FixtureNode.new('bar' => NodeBar, 'baz' => NodeBaz)
|
9
|
+
Root = FixtureNode.new('foo' => NodeFoo)
|
10
|
+
|
11
|
+
def check word, expected
|
12
|
+
got = RVC::Completion::Completor[word]
|
13
|
+
assert_equal expected, got
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@context = RVC::Context.new Root
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
@context = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_simple
|
25
|
+
check
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Rich Lane
|
@@ -57,6 +57,17 @@ dependencies:
|
|
57
57
|
version: 1.6.1
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: zip
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.2
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id005
|
60
71
|
description:
|
61
72
|
email: rlane@vmware.com
|
62
73
|
executables:
|
@@ -112,6 +123,8 @@ files:
|
|
112
123
|
- test/inventory_fixtures.rb
|
113
124
|
- test/test_fs.rb
|
114
125
|
- test/test_parse_path.rb
|
126
|
+
- test/_test_completion.rb
|
127
|
+
- test/_test_option_parser.rb
|
115
128
|
has_rdoc: true
|
116
129
|
homepage:
|
117
130
|
licenses: []
|
@@ -136,11 +149,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
149
|
requirements: []
|
137
150
|
|
138
151
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.5.3
|
140
153
|
signing_key:
|
141
154
|
specification_version: 3
|
142
155
|
summary: vSphere console UI
|
143
156
|
test_files:
|
157
|
+
- test/_test_completion.rb
|
158
|
+
- test/_test_option_parser.rb
|
144
159
|
- test/inventory_fixtures.rb
|
145
160
|
- test/test_fs.rb
|
146
161
|
- test/test_parse_path.rb
|