vmc 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,31 +27,48 @@ module VMC::Cli::Command
27
27
 
28
28
  alias :apps :list
29
29
 
30
- SLEEP_TIME = 0.5
30
+ SLEEP_TIME = 1
31
31
  LINE_LENGTH = 80
32
32
 
33
33
  # Numerators are in secs
34
- TICKER_TICKS = 15/SLEEP_TIME
34
+ TICKER_TICKS = 25/SLEEP_TIME
35
35
  HEALTH_TICKS = 5/SLEEP_TIME
36
- TAIL_TICKS = 25/SLEEP_TIME
36
+ TAIL_TICKS = 45/SLEEP_TIME
37
37
  GIVEUP_TICKS = 120/SLEEP_TIME
38
38
  YES_SET = Set.new(["y", "Y", "yes", "YES"])
39
39
 
40
-
41
40
  def start(appname, push = false)
42
41
  app = client.app_info(appname)
42
+
43
43
  return display "Application '#{appname}' could not be found".red if app.nil?
44
44
  return display "Application '#{appname}' already started".yellow if app[:state] == 'STARTED'
45
+
46
+ banner = 'Staging Application: '
47
+ display banner, false
48
+
49
+ t = Thread.new do
50
+ count = 0
51
+ while count < TAIL_TICKS do
52
+ display '.', false
53
+ sleep SLEEP_TIME
54
+ count += 1
55
+ end
56
+ end
57
+
45
58
  app[:state] = 'STARTED'
46
59
  client.update_app(appname, app)
47
60
 
48
- count = log_lines_displayed = 0
49
- failed = false
50
- start_time = Time.now.to_i
61
+ Thread.kill(t)
62
+ clear(LINE_LENGTH)
63
+ display "#{banner}#{'OK'.green}"
51
64
 
52
65
  banner = 'Starting Application: '
53
66
  display banner, false
54
67
 
68
+ count = log_lines_displayed = 0
69
+ failed = false
70
+ start_time = Time.now.to_i
71
+
55
72
  loop do
56
73
  display '.', false unless count > TICKER_TICKS
57
74
  sleep SLEEP_TIME
@@ -187,9 +204,9 @@ module VMC::Cli::Command
187
204
  app_services.each { |service|
188
205
  del_service = force && no_prompt ? 'Y' : 'N'
189
206
  unless no_prompt || force
190
- del_service = ask("Provisioned service [#{service}] detected, would you like to delete it? [Yn]: ")
207
+ del_service = ask("Provisioned service [#{service}] detected, would you like to delete it? [yN]: ")
191
208
  end
192
- services_to_delete << service unless del_service.upcase == 'N'
209
+ services_to_delete << service if del_service.upcase == 'Y'
193
210
  }
194
211
  display "Deleting application [#{appname}]: ", false
195
212
  client.delete_app(appname)
@@ -386,6 +403,7 @@ module VMC::Cli::Command
386
403
  framework_correct ||= 'y'
387
404
  if prompt_ok && (framework.nil? || framework_correct.upcase == 'N')
388
405
  display "#{"[WARNING]".yellow} Can't determine the Application Type." unless framework
406
+ framework = nil if framework_correct.upcase == 'N'
389
407
  choose do |menu|
390
408
  menu.layout = :one_line
391
409
  menu.prompt = "Select Application Type: "
@@ -642,15 +660,20 @@ module VMC::Cli::Command
642
660
  menu.header = "The following system services are available:"
643
661
  menu.prompt = 'Please select one you wish to provision: '
644
662
  menu.select_by = :index_or_name
663
+ service_choices = []
645
664
  services.each do |service_type, value|
646
665
  value.each do |vendor, version|
647
- menu.choice(vendor) do
648
- default_name = random_service_name(vendor)
649
- service_name = ask("Specify the name of the service [#{default_name}]: ")
650
- service_name = default_name if service_name.empty?
651
- create_service_banner(vendor, service_name)
652
- bind_service_banner(service_name, appname)
653
- end
666
+ service_choices << vendor
667
+ end
668
+ end
669
+ service_choices.sort!
670
+ service_choices.each do |vendor|
671
+ menu.choice(vendor) do
672
+ default_name = random_service_name(vendor)
673
+ service_name = ask("Specify the name of the service [#{default_name}]: ")
674
+ service_name = default_name if service_name.empty?
675
+ create_service_banner(vendor, service_name)
676
+ bind_service_banner(service_name, appname)
654
677
  end
655
678
  end
656
679
  end
@@ -6,14 +6,6 @@ module VMC::Cli
6
6
  DEFAULT_MEM = '256M'
7
7
 
8
8
  FRAMEWORKS = {
9
- # 'Rails' => ['rails/1.0', { :mem => '256M', :description => 'Rails Application'}],
10
- # 'Spring' => ['spring_web/1.0', { :mem => '512M', :description => 'Java SpringSource Spring Application'}],
11
- # 'Grails' => ['grails/1.0', { :mem => '512M', :description => 'Java SpringSource Grails Application'}],
12
- # 'Roo' => ['spring_web/1.0', { :mem => '512M', :description => 'Java SpringSource Roo Application'}],
13
- # 'JavaWeb' => ['spring_web/1.0', { :mem => '512M', :description => 'Java Web Application'}],
14
- # 'Sinatra' => [DEFAULT_FRAMEWORK, { :mem => '128M', :description => 'Sinatra Application'}],
15
- # 'Node' => ['nodejs/1.0', { :mem => '64M', :description => 'Node.js Application'}],
16
-
17
9
  'Rails' => ['rails3', { :mem => '256M', :description => 'Rails Application'}],
18
10
  'Spring' => ['spring', { :mem => '512M', :description => 'Java SpringSource Spring Application'}],
19
11
  'Grails' => ['grails', { :mem => '512M', :description => 'Java SpringSource Grails Application'}],
data/lib/cli/runner.rb CHANGED
@@ -407,8 +407,8 @@ class VMC::Cli::Runner
407
407
 
408
408
  def run
409
409
 
410
- trap('TERM') { print "\nInterupted\n"; exit(false)}
411
- trap('INT') { print "\nInterupted\n"; exit(false)}
410
+ trap('TERM') { print "\nInterrupted\n"; exit(false)}
411
+ trap('INT') { print "\nInterrupted\n"; exit(false)}
412
412
 
413
413
  parse_options!
414
414
 
data/lib/cli/version.rb CHANGED
@@ -2,6 +2,6 @@ module VMC
2
2
  module Cli
3
3
  # This version number is used as the RubyGem release version.
4
4
  # The internal VMC version number is VMC::VERSION.
5
- VERSION = '0.3.7'
5
+ VERSION = '0.3.8'
6
6
  end
7
7
  end
data/lib/vmc/client.rb CHANGED
@@ -111,6 +111,11 @@ class VMC::Client
111
111
  json_get("#{VMC::APPS_PATH}/#{name}")
112
112
  end
113
113
 
114
+ def app_update_info(name)
115
+ check_login_status
116
+ json_get("#{VMC::APPS_PATH}/#{name}/update")
117
+ end
118
+
114
119
  def app_stats(name)
115
120
  check_login_status
116
121
  stats_raw = json_get("#{VMC::APPS_PATH}/#{name}/stats")
@@ -345,7 +350,11 @@ class VMC::Client
345
350
  headers = headers.dup
346
351
  headers['AUTHORIZATION'] = @auth_token if @auth_token
347
352
  headers['PROXY-USER'] = @proxy if @proxy
348
- headers['Content-Type'] = content_type if content_type
353
+
354
+ if content_type
355
+ headers['Content-Type'] = content_type
356
+ headers['Accept'] = content_type
357
+ end
349
358
 
350
359
  req = {
351
360
  :method => method, :url => "#{@target}#{path}",
@@ -414,7 +423,8 @@ class VMC::Client
414
423
  if body.nil? || body.empty?
415
424
  "Error (#{status}): No Response Received"
416
425
  else
417
- "Error (JSON #{status}): #{truncate(body)}"
426
+ body_out = trace ? body : truncate(body)
427
+ "Error (JSON #{status}): #{body_out}"
418
428
  end
419
429
  end
420
430
 
data/lib/vmc/const.rb CHANGED
@@ -2,7 +2,7 @@ module VMC
2
2
 
3
3
  # This is the internal VMC version number, and is not necessarily
4
4
  # the same as the RubyGem version (VMC::Cli::VERSION).
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.2'
6
6
 
7
7
  # Targets
8
8
  DEFAULT_TARGET = 'http://api.cloudfoundry.com'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 7
10
- version: 0.3.7
9
+ - 8
10
+ version: 0.3.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - VMware
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-07 00:00:00 -07:00
18
+ date: 2011-04-11 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -165,45 +165,45 @@ files:
165
165
  - LICENSE
166
166
  - README.md
167
167
  - Rakefile
168
- - lib/cli/config.rb
169
- - lib/cli/services_helper.rb
170
168
  - lib/cli/commands/admin.rb
171
- - lib/cli/commands/services.rb
172
- - lib/cli/commands/misc.rb
173
169
  - lib/cli/commands/apps.rb
174
- - lib/cli/commands/user.rb
175
170
  - lib/cli/commands/base.rb
176
- - lib/cli/usage.rb
177
- - lib/cli/frameworks.rb
171
+ - lib/cli/commands/misc.rb
172
+ - lib/cli/commands/services.rb
173
+ - lib/cli/commands/user.rb
174
+ - lib/cli/config.rb
175
+ - lib/cli/core_ext.rb
178
176
  - lib/cli/errors.rb
177
+ - lib/cli/frameworks.rb
178
+ - lib/cli/runner.rb
179
+ - lib/cli/services_helper.rb
180
+ - lib/cli/usage.rb
179
181
  - lib/cli/version.rb
180
182
  - lib/cli/zip_util.rb
181
- - lib/cli/core_ext.rb
182
- - lib/cli/runner.rb
183
+ - lib/cli.rb
183
184
  - lib/vmc/client.rb
184
185
  - lib/vmc/const.rb
185
- - lib/cli.rb
186
186
  - lib/vmc.rb
187
- - spec/unit/client_spec.rb
188
- - spec/unit/cli_opts_spec.rb
189
- - spec/spec_helper.rb
190
- - spec/assets/info_return_bad.txt
191
- - spec/assets/info_return.txt
192
- - spec/assets/service_listings.txt
187
+ - spec/assets/app_info.txt
188
+ - spec/assets/app_listings.txt
189
+ - spec/assets/bad_create_app.txt
193
190
  - spec/assets/delete_app.txt
194
- - spec/assets/user_info.txt
191
+ - spec/assets/global_service_listings.txt
195
192
  - spec/assets/good_create_app.txt
196
- - spec/assets/service_already_exists.txt
193
+ - spec/assets/good_create_service.txt
194
+ - spec/assets/info_authenticated.txt
195
+ - spec/assets/info_return.txt
196
+ - spec/assets/info_return_bad.txt
197
197
  - spec/assets/login_fail.txt
198
- - spec/assets/app_info.txt
199
198
  - spec/assets/login_success.txt
200
- - spec/assets/app_listings.txt
201
- - spec/assets/global_service_listings.txt
202
- - spec/assets/bad_create_app.txt
203
199
  - spec/assets/sample_token.txt
200
+ - spec/assets/service_already_exists.txt
201
+ - spec/assets/service_listings.txt
204
202
  - spec/assets/service_not_found.txt
205
- - spec/assets/info_authenticated.txt
206
- - spec/assets/good_create_service.txt
203
+ - spec/assets/user_info.txt
204
+ - spec/spec_helper.rb
205
+ - spec/unit/cli_opts_spec.rb
206
+ - spec/unit/client_spec.rb
207
207
  - bin/vmc
208
208
  has_rdoc: true
209
209
  homepage: http://vmware.com
@@ -235,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  requirements: []
236
236
 
237
237
  rubyforge_project:
238
- rubygems_version: 1.6.2
238
+ rubygems_version: 1.5.0
239
239
  signing_key:
240
240
  specification_version: 3
241
241
  summary: Client library and CLI that provides access to the VMware Cloud Application Platform.