vmc 0.3.12.beta.1 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cli/runner.rb +4 -2
- data/lib/cli/version.rb +1 -1
- data/lib/vmc/client.rb +12 -3
- data/spec/unit/cli_opts_spec.rb +2 -7
- data/spec/unit/client_spec.rb +22 -6
- metadata +77 -81
data/lib/cli/runner.rb
CHANGED
@@ -410,8 +410,7 @@ class VMC::Cli::Runner
|
|
410
410
|
|
411
411
|
def run
|
412
412
|
|
413
|
-
trap('TERM') { print "\
|
414
|
-
trap('INT') { print "\nInterrupted\n"; exit(false)}
|
413
|
+
trap('TERM') { print "\nTerminated\n"; exit(false)}
|
415
414
|
|
416
415
|
parse_options!
|
417
416
|
|
@@ -467,6 +466,9 @@ class VMC::Cli::Runner
|
|
467
466
|
puts e.message.red
|
468
467
|
puts e.backtrace
|
469
468
|
@exit_status = false
|
469
|
+
rescue Interrupt => e
|
470
|
+
say("\nInterrupted".red)
|
471
|
+
@exit_status = false
|
470
472
|
rescue => e
|
471
473
|
puts e.message.red
|
472
474
|
puts e.backtrace
|
data/lib/cli/version.rb
CHANGED
data/lib/vmc/client.rb
CHANGED
@@ -381,7 +381,8 @@ class VMC::Client
|
|
381
381
|
end
|
382
382
|
|
383
383
|
def perform_http_request(req)
|
384
|
-
|
384
|
+
proxy_uri = URI.parse(req[:url]).find_proxy()
|
385
|
+
RestClient.proxy = proxy_uri.to_s if proxy_uri
|
385
386
|
|
386
387
|
# Setup tracing if needed
|
387
388
|
unless trace.nil?
|
@@ -395,9 +396,17 @@ class VMC::Client
|
|
395
396
|
puts '>>>'
|
396
397
|
puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
397
398
|
puts "REQUEST: #{req[:method]} #{req[:url]}"
|
398
|
-
puts "RESPONSE_HEADERS:
|
399
|
+
puts "RESPONSE_HEADERS:"
|
400
|
+
response.headers.each do |key, value|
|
401
|
+
puts " #{key} : #{value}"
|
402
|
+
end
|
399
403
|
puts "REQUEST_BODY: #{req[:payload]}" if req[:payload]
|
400
|
-
puts "RESPONSE: [#{response.code}]
|
404
|
+
puts "RESPONSE: [#{response.code}]"
|
405
|
+
begin
|
406
|
+
puts JSON.pretty_generate(JSON.parse(response.body))
|
407
|
+
rescue
|
408
|
+
puts "#{response.body}"
|
409
|
+
end
|
401
410
|
puts '<<<'
|
402
411
|
end
|
403
412
|
end
|
data/spec/unit/cli_opts_spec.rb
CHANGED
@@ -32,16 +32,11 @@ describe 'VMC::Cli::Runner' do
|
|
32
32
|
cli.options[:bind].should == 'bar'
|
33
33
|
end
|
34
34
|
|
35
|
-
it 'should parse
|
35
|
+
it 'should parse instances and instance into a number and string' do
|
36
36
|
args = "--instances 1 --instance 2"
|
37
37
|
cli = VMC::Cli::Runner.new(args.split).parse_options!
|
38
38
|
cli.options[:instances].should == 1
|
39
|
-
cli.options[:instance].should == 2
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should complain if instance arg is not a number' do
|
43
|
-
args = "--instance foo"
|
44
|
-
expect { VMC::Cli::Runner.new(args.split).parse_options! }.to raise_error
|
39
|
+
cli.options[:instance].should == "2"
|
45
40
|
end
|
46
41
|
|
47
42
|
it 'should parse url, mem, path correctly' do
|
data/spec/unit/client_spec.rb
CHANGED
@@ -11,6 +11,13 @@ describe 'VMC::Client' do
|
|
11
11
|
@auth_token = spec_asset('sample_token.txt')
|
12
12
|
end
|
13
13
|
|
14
|
+
before(:each) do
|
15
|
+
# make sure these get cleared so we don't have tests pass that shouldn't
|
16
|
+
RestClient.proxy = nil
|
17
|
+
ENV['http_proxy'] = nil
|
18
|
+
ENV['https_proxy'] = nil
|
19
|
+
end
|
20
|
+
|
14
21
|
it 'should report its version' do
|
15
22
|
VMC::Client.version.should =~ /\d.\d.\d/
|
16
23
|
end
|
@@ -275,14 +282,24 @@ describe 'VMC::Client' do
|
|
275
282
|
end
|
276
283
|
|
277
284
|
it 'should set a proxy if one is set' do
|
285
|
+
target = "http://nonlocal.domain.com"
|
286
|
+
info_path = "#{target}#{VMC::INFO_PATH}"
|
287
|
+
stub_request(:get, info_path).to_return(File.new(spec_asset('info_return.txt')))
|
288
|
+
proxy = 'http://proxy.vmware.com:3128'
|
289
|
+
ENV['http_proxy'] = proxy
|
290
|
+
client = VMC::Client.new(target)
|
291
|
+
info = client.info
|
292
|
+
RestClient.proxy.should == proxy
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'should not set a proxy when accessing localhost' do
|
278
296
|
info_path = "#{@local_target}#{VMC::INFO_PATH}"
|
279
297
|
stub_request(:get, info_path).to_return(File.new(spec_asset('info_return.txt')))
|
280
298
|
proxy = 'http://proxy.vmware.com:3128'
|
281
299
|
ENV['http_proxy'] = proxy
|
282
300
|
client = VMC::Client.new(@local_target)
|
283
301
|
info = client.info
|
284
|
-
RestClient.proxy.should ==
|
285
|
-
ENV['http_proxy'] = nil
|
302
|
+
RestClient.proxy.should == nil
|
286
303
|
end
|
287
304
|
|
288
305
|
it 'should use a secure proxy over a normal proxy if one is set' do
|
@@ -295,20 +312,19 @@ describe 'VMC::Client' do
|
|
295
312
|
client = VMC::Client.new(@target)
|
296
313
|
info = client.info
|
297
314
|
RestClient.proxy.should == secure_proxy
|
298
|
-
ENV['http_proxy'] = ENV['https_proxy'] = nil
|
299
315
|
end
|
300
316
|
|
301
317
|
it 'should not use a secure proxy for non-secure site' do
|
302
|
-
|
318
|
+
target = "http://nonlocal.domain.com"
|
319
|
+
info_path = "#{target}#{VMC::INFO_PATH}"
|
303
320
|
stub_request(:get, info_path).to_return(File.new(spec_asset('info_return.txt')))
|
304
321
|
proxy = 'http://proxy.vmware.com:3128'
|
305
322
|
secure_proxy = 'http://secure-proxy.vmware.com:3128'
|
306
323
|
ENV['http_proxy'] = proxy
|
307
324
|
ENV['https_proxy'] = secure_proxy
|
308
|
-
client = VMC::Client.new(
|
325
|
+
client = VMC::Client.new(target)
|
309
326
|
info = client.info
|
310
327
|
RestClient.proxy.should == proxy
|
311
|
-
ENV['http_proxy'] = ENV['https_proxy'] = nil
|
312
328
|
end
|
313
329
|
|
314
330
|
# WebMock.allow_net_connect!
|
metadata
CHANGED
@@ -1,119 +1,118 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmc
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.12
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- VMware
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-06-02 00:00:00 -07:00
|
12
|
+
date: 2011-07-12 00:00:00.000000000 -05:00
|
14
13
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: json_pure
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2160775700 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
|
-
requirements:
|
19
|
+
requirements:
|
22
20
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
21
|
+
- !ruby/object:Gem::Version
|
24
22
|
version: 1.5.1
|
25
23
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rubyzip2
|
29
24
|
prerelease: false
|
30
|
-
|
25
|
+
version_requirements: *2160775700
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rubyzip2
|
28
|
+
requirement: &2160775200 !ruby/object:Gem::Requirement
|
31
29
|
none: false
|
32
|
-
requirements:
|
30
|
+
requirements:
|
33
31
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
32
|
+
- !ruby/object:Gem::Version
|
35
33
|
version: 2.0.1
|
36
34
|
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: highline
|
40
35
|
prerelease: false
|
41
|
-
|
36
|
+
version_requirements: *2160775200
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: highline
|
39
|
+
requirement: &2160774680 !ruby/object:Gem::Requirement
|
42
40
|
none: false
|
43
|
-
requirements:
|
41
|
+
requirements:
|
44
42
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
43
|
+
- !ruby/object:Gem::Version
|
46
44
|
version: 1.6.1
|
47
45
|
type: :runtime
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rest-client
|
51
46
|
prerelease: false
|
52
|
-
|
47
|
+
version_requirements: *2160774680
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rest-client
|
50
|
+
requirement: &2160774120 !ruby/object:Gem::Requirement
|
53
51
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
57
55
|
version: 1.6.1
|
58
56
|
- - <
|
59
|
-
- !ruby/object:Gem::Version
|
57
|
+
- !ruby/object:Gem::Version
|
60
58
|
version: 1.7.0
|
61
59
|
type: :runtime
|
62
|
-
version_requirements: *id004
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: terminal-table
|
65
60
|
prerelease: false
|
66
|
-
|
61
|
+
version_requirements: *2160774120
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: terminal-table
|
64
|
+
requirement: &2160773380 !ruby/object:Gem::Requirement
|
67
65
|
none: false
|
68
|
-
requirements:
|
66
|
+
requirements:
|
69
67
|
- - ~>
|
70
|
-
- !ruby/object:Gem::Version
|
68
|
+
- !ruby/object:Gem::Version
|
71
69
|
version: 1.4.2
|
72
70
|
type: :runtime
|
73
|
-
version_requirements: *id005
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: rake
|
76
71
|
prerelease: false
|
77
|
-
|
72
|
+
version_requirements: *2160773380
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rake
|
75
|
+
requirement: &2160772980 !ruby/object:Gem::Requirement
|
78
76
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version:
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
83
81
|
type: :development
|
84
|
-
version_requirements: *id006
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: rspec
|
87
82
|
prerelease: false
|
88
|
-
|
83
|
+
version_requirements: *2160772980
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: &2160772400 !ruby/object:Gem::Requirement
|
89
87
|
none: false
|
90
|
-
requirements:
|
88
|
+
requirements:
|
91
89
|
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
90
|
+
- !ruby/object:Gem::Version
|
93
91
|
version: 1.3.0
|
94
92
|
type: :development
|
95
|
-
version_requirements: *id007
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: webmock
|
98
93
|
prerelease: false
|
99
|
-
|
94
|
+
version_requirements: *2160772400
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: webmock
|
97
|
+
requirement: &2160771840 !ruby/object:Gem::Requirement
|
100
98
|
none: false
|
101
|
-
requirements:
|
99
|
+
requirements:
|
102
100
|
- - ~>
|
103
|
-
- !ruby/object:Gem::Version
|
101
|
+
- !ruby/object:Gem::Version
|
104
102
|
version: 1.5.0
|
105
103
|
type: :development
|
106
|
-
|
107
|
-
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *2160771840
|
106
|
+
description: Client library and CLI that provides access to the VMware Cloud Application
|
107
|
+
Platform.
|
108
108
|
email: support@vmware.com
|
109
|
-
executables:
|
109
|
+
executables:
|
110
110
|
- vmc
|
111
111
|
extensions: []
|
112
|
-
|
113
|
-
extra_rdoc_files:
|
112
|
+
extra_rdoc_files:
|
114
113
|
- README.md
|
115
114
|
- LICENSE
|
116
|
-
files:
|
115
|
+
files:
|
117
116
|
- LICENSE
|
118
117
|
- README.md
|
119
118
|
- Rakefile
|
@@ -161,30 +160,27 @@ files:
|
|
161
160
|
has_rdoc: true
|
162
161
|
homepage: http://vmware.com
|
163
162
|
licenses: []
|
164
|
-
|
165
163
|
post_install_message:
|
166
164
|
rdoc_options: []
|
167
|
-
|
168
|
-
require_paths:
|
165
|
+
require_paths:
|
169
166
|
- lib
|
170
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
168
|
none: false
|
172
|
-
requirements:
|
173
|
-
- -
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version:
|
176
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
174
|
none: false
|
178
|
-
requirements:
|
179
|
-
- -
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version:
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
182
179
|
requirements: []
|
183
|
-
|
184
180
|
rubyforge_project:
|
185
181
|
rubygems_version: 1.6.2
|
186
182
|
signing_key:
|
187
183
|
specification_version: 3
|
188
|
-
summary: Client library and CLI that provides access to the VMware Cloud Application
|
184
|
+
summary: Client library and CLI that provides access to the VMware Cloud Application
|
185
|
+
Platform.
|
189
186
|
test_files: []
|
190
|
-
|