rhc 1.10.7 → 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,11 +8,11 @@ _rhc()
8
8
  cur="${COMP_WORDS[COMP_CWORD]}"
9
9
  if [ $COMP_CWORD -eq 1 ]; then
10
10
  if [[ "$cur" == -* ]]; then
11
- opts="--clean --config --debug --insecure --mock --noprompt --password --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
11
+ opts="--always-prefix --clean --config --debug --insecure --limit --mock --noprompt --password --raw --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
12
12
  elif [ -z $cur ]; then
13
- opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
13
+ opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
14
14
  else
15
- opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-show domain-update force-stop-app git-clone list-alias list-cartridge list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh ssh-app sshkey sshkey-add sshkey-delete sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app update-cert-alias update-domain"
15
+ opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-show domain-update force-stop-app git-clone list-alias list-authorization list-cartridge list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-delete sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app update-cert-alias update-domain"
16
16
  fi
17
17
  else
18
18
  prev="${COMP_WORDS[@]:0:COMP_CWORD}"
@@ -164,11 +164,19 @@ _rhc()
164
164
  fi
165
165
  ;;
166
166
 
167
+ "rhc aliases")
168
+ if [[ "$cur" == -* ]]; then
169
+ opts="--app --namespace"
170
+ else
171
+ opts=""
172
+ fi
173
+ ;;
174
+
167
175
  "rhc app")
168
176
  if [[ "$cur" == -* ]]; then
169
177
  opts=""
170
178
  else
171
- opts="create delete start stop force-stop restart reload tidy show ssh"
179
+ opts="snapshot create delete start stop force-stop restart reload tidy show"
172
180
  fi
173
181
  ;;
174
182
 
@@ -222,7 +230,7 @@ _rhc()
222
230
 
223
231
  "rhc app snapshot")
224
232
  if [[ "$cur" == -* ]]; then
225
- opts=""
233
+ opts="--app --filepath --namespace"
226
234
  else
227
235
  opts=""
228
236
  fi
@@ -230,7 +238,7 @@ _rhc()
230
238
 
231
239
  "rhc app ssh")
232
240
  if [[ "$cur" == -* ]]; then
233
- opts="--app --namespace --ssh"
241
+ opts="--app --gears --limit --namespace --raw --ssh"
234
242
  else
235
243
  opts=""
236
244
  fi
@@ -310,7 +318,7 @@ _rhc()
310
318
 
311
319
  "rhc app-snapshot")
312
320
  if [[ "$cur" == -* ]]; then
313
- opts=""
321
+ opts="--app --filepath --namespace"
314
322
  else
315
323
  opts=""
316
324
  fi
@@ -318,7 +326,7 @@ _rhc()
318
326
 
319
327
  "rhc app-ssh")
320
328
  if [[ "$cur" == -* ]]; then
321
- opts="--app --namespace --ssh"
329
+ opts="--app --gears --limit --namespace --raw --ssh"
322
330
  else
323
331
  opts=""
324
332
  fi
@@ -360,7 +368,7 @@ _rhc()
360
368
  if [[ "$cur" == -* ]]; then
361
369
  opts=""
362
370
  else
363
- opts="add delete delete-all"
371
+ opts="list add delete delete-all"
364
372
  fi
365
373
  ;;
366
374
 
@@ -388,6 +396,14 @@ _rhc()
388
396
  fi
389
397
  ;;
390
398
 
399
+ "rhc authorization list")
400
+ if [[ "$cur" == -* ]]; then
401
+ opts=""
402
+ else
403
+ opts=""
404
+ fi
405
+ ;;
406
+
391
407
  "rhc authorization-add")
392
408
  if [[ "$cur" == -* ]]; then
393
409
  opts="--expires-in --note --scopes"
@@ -412,6 +428,14 @@ _rhc()
412
428
  fi
413
429
  ;;
414
430
 
431
+ "rhc authorization-list")
432
+ if [[ "$cur" == -* ]]; then
433
+ opts=""
434
+ else
435
+ opts=""
436
+ fi
437
+ ;;
438
+
415
439
  "rhc authorizations")
416
440
  if [[ "$cur" == -* ]]; then
417
441
  opts=""
@@ -764,6 +788,14 @@ _rhc()
764
788
  fi
765
789
  ;;
766
790
 
791
+ "rhc list-authorization")
792
+ if [[ "$cur" == -* ]]; then
793
+ opts=""
794
+ else
795
+ opts=""
796
+ fi
797
+ ;;
798
+
767
799
  "rhc list-cartridge")
768
800
  if [[ "$cur" == -* ]]; then
769
801
  opts="--verbose"
@@ -790,7 +822,7 @@ _rhc()
790
822
 
791
823
  "rhc port-forward")
792
824
  if [[ "$cur" == -* ]]; then
793
- opts="--app --namespace"
825
+ opts="--app --gear --namespace"
794
826
  else
795
827
  opts=""
796
828
  fi
@@ -966,15 +998,7 @@ _rhc()
966
998
 
967
999
  "rhc ssh")
968
1000
  if [[ "$cur" == -* ]]; then
969
- opts="--app --namespace --ssh"
970
- else
971
- opts=""
972
- fi
973
- ;;
974
-
975
- "rhc ssh-app")
976
- if [[ "$cur" == -* ]]; then
977
- opts="--app --namespace --ssh"
1001
+ opts="--app --gears --limit --namespace --raw --ssh"
978
1002
  else
979
1003
  opts=""
980
1004
  fi
@@ -1118,7 +1142,7 @@ _rhc()
1118
1142
 
1119
1143
  "rhc tail")
1120
1144
  if [[ "$cur" == -* ]]; then
1121
- opts="--app --files --namespace --opts"
1145
+ opts="--app --files --gear --namespace --opts"
1122
1146
  else
1123
1147
  opts=""
1124
1148
  fi
@@ -13,6 +13,19 @@ module Commander
13
13
  root.present?
14
14
  end
15
15
 
16
+ #
17
+ # Force proxy_option_struct to default to nil for values,
18
+ # backported for Commander 4.0.3
19
+ #
20
+ def proxy_option_struct
21
+ proxy_options.inject Options.new do |options, (option, value)|
22
+ # options that are present will evaluate to true
23
+ value = true if value.nil?
24
+ options.__send__ :"#{option}=", value
25
+ options
26
+ end
27
+ end
28
+
16
29
  def deprecated(as_alias=nil)
17
30
  return false unless info
18
31
  return info[:deprecated] if info[:deprecated]
@@ -84,7 +84,7 @@ module RHC::Commands
84
84
  rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
85
85
  rest_cartridge = rest_app.add_cartridge(cart)
86
86
 
87
- success "Success"
87
+ success "done"
88
88
 
89
89
  paragraph{ display_cart(rest_cartridge) }
90
90
  paragraph{ rest_cartridge.messages.each { |msg| success msg } }
@@ -131,11 +131,11 @@ module RHC::Commands
131
131
  summary "Start a cartridge"
132
132
  syntax "<cartridge> [--namespace NAME] [--app NAME]"
133
133
  argument :cart_type, "The name of the cartridge you are stopping", ["-c", "--cartridge cartridge"]
134
- option ["-n", "--namespace NAME"], "Namespace of the application the cartrdige belongs to", :context => :namespace_context, :required => true
134
+ option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
135
135
  option ["-a", "--app NAME"], "Application the cartridge", :context => :app_context, :required => true
136
136
  alias_action :"app cartridge start", :root_command => true, :deprecated => true
137
137
  def start(cartridge)
138
- cartridge_action(cartridge, :start){ |_, c| results{ say "#{c.name} started" } }
138
+ cartridge_action(cartridge, :start, 'Starting %s ... ')
139
139
  0
140
140
  end
141
141
 
@@ -143,10 +143,10 @@ module RHC::Commands
143
143
  syntax "<cartridge> [--namespace NAME] [--app NAME]"
144
144
  argument :cart_type, "The name of the cartridge you are stopping", ["-c", "--cartridge cartridge"]
145
145
  option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
146
- option ["-a", "--app NAME"], "Application you the cartridge belongs to", :context => :app_context, :required => true
146
+ option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
147
147
  alias_action :"app cartridge stop", :root_command => true, :deprecated => true
148
148
  def stop(cartridge)
149
- cartridge_action(cartridge, :stop){ |_, c| results{ say "#{c.name} stopped" } }
149
+ cartridge_action(cartridge, :stop, 'Stopping %s ... ')
150
150
  0
151
151
  end
152
152
 
@@ -157,7 +157,7 @@ module RHC::Commands
157
157
  option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
158
158
  alias_action :"app cartridge restart", :root_command => true, :deprecated => true
159
159
  def restart(cartridge)
160
- cartridge_action(cartridge, :restart){ |_, c| results{ say "#{c.name} restarted" } }
160
+ cartridge_action(cartridge, :restart, 'Restarting %s ... ')
161
161
  0
162
162
  end
163
163
 
@@ -181,7 +181,7 @@ module RHC::Commands
181
181
  option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
182
182
  alias_action :"app cartridge reload", :root_command => true, :deprecated => true
183
183
  def reload(cartridge)
184
- cartridge_action(cartridge, :reload){ |_, c| results{ say "#{c.name} reloaded" } }
184
+ cartridge_action(cartridge, :reload, 'Reloading %s ... ')
185
185
  0
186
186
  end
187
187
 
@@ -305,12 +305,16 @@ module RHC::Commands
305
305
  private
306
306
  include RHC::CartridgeHelpers
307
307
 
308
- def cartridge_action(cartridge, action, &block)
308
+ def cartridge_action(cartridge, action, message=nil)
309
309
  rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
310
310
  rest_cartridge = check_cartridges(cartridge, :from => rest_app.cartridges).first
311
- result = rest_cartridge.send action
311
+ say message % [rest_cartridge.name] if message
312
+ result = rest_cartridge.send(action)
312
313
  resp = [result, rest_cartridge, rest_app]
313
- yield resp if block_given?
314
+ if message
315
+ success "done"
316
+ result.messages.each{ |s| paragraph{ say s } }
317
+ end
314
318
  resp
315
319
  end
316
320
  end
@@ -30,6 +30,8 @@ module RHC::Commands
30
30
  raise ArgumentError, "--gears requires a command" if options.gears && command.blank?
31
31
  raise ArgumentError, "--limit must be an integer greater than zero" if options.limit && options.limit < 1
32
32
  raise OptionParser::InvalidOption, "No system SSH available. Please use the --ssh option to specify the path to your SSH executable, or install SSH." unless options.ssh or has_ssh?
33
+ raise OptionParser::InvalidOption, "SSH executable '#{options.ssh}' does not exist." if options.ssh and not File.exist?(options.ssh)
34
+ raise OptionParser::InvalidOption, "SSH executable '#{options.ssh}' is not executable." if options.ssh and not File.executable?(options.ssh)
33
35
 
34
36
  if options.gears
35
37
  groups = rest_client.find_application_gear_groups(options.namespace, app_name)
@@ -212,7 +212,7 @@ module RHC
212
212
  #
213
213
 
214
214
  def interactive?
215
- $stdout.tty? and not options.noprompt
215
+ $stdin.tty? and $stdout.tty? and not options.noprompt
216
216
  end
217
217
 
218
218
  def debug(*args)
@@ -242,9 +242,20 @@ module RHC
242
242
  warn "Warning: #{msg}\n" % ['a warning','an error',1]
243
243
  end
244
244
 
245
+ #
246
+ # By default, agree should take a single character in interactive
247
+ #
248
+ def agree(*args, &block)
249
+ #args.push(interactive?.presence) if args.length == 1
250
+ block = lambda do |q|
251
+ q.validate = /\A(?:y|yes|n|no)\Z/i
252
+ end unless block_given?
253
+ super *args, &block
254
+ end
255
+
245
256
  def confirm_action(question)
246
257
  return if options.confirm
247
- return if !options.noprompt && paragraph{ agree("#{question} (yes|no): ") }
258
+ return if !options.noprompt && paragraph{ agree "#{question} (yes|no): " }
248
259
  raise RHC::ConfirmationError
249
260
  end
250
261
 
@@ -15,6 +15,17 @@ class HighLineExtension < HighLine
15
15
  end
16
16
  end
17
17
 
18
+ if HighLine::CHARACTER_MODE == 'stty'
19
+ def raw_no_echo_mode
20
+ @state = `stty -g 2>/dev/null`
21
+ `stty raw -echo -icanon isig 2>&1`
22
+ end
23
+
24
+ def restore_mode
25
+ `stty #{@state} 2>&1`
26
+ end
27
+ end
28
+
18
29
  def debug(msg)
19
30
  $stderr.puts "DEBUG: #{msg}" if debug?
20
31
  end
@@ -37,7 +48,7 @@ class HighLineExtension < HighLine
37
48
  statement = template.result(binding)
38
49
 
39
50
  if @wrap_at
40
- statement = statement.textwrap_ansi(@wrap_at, false)
51
+ statement = statement.chomp.textwrap_ansi(@wrap_at, false)
41
52
  if @last_line_open && statement.length > 1
42
53
  @last_line_open = false
43
54
  @output.puts
@@ -52,7 +63,8 @@ class HighLineExtension < HighLine
52
63
  if statement[-1, 1] == " " or statement[-1, 1] == "\t"
53
64
  @output.print(statement)
54
65
  @output.flush
55
- statement.strip_ansi.length + (@last_line_open || 0)
66
+ #statement.strip_ansi.length + (@last_line_open || 0)
67
+ true
56
68
  else
57
69
  @output.puts(statement)
58
70
  false
@@ -152,7 +152,7 @@ module RHC
152
152
  options = name
153
153
  name = options[:name]
154
154
  end
155
- aliases.each { |a| return a if a.is_a?(String) || a.id == name }
155
+ aliases.each { |a| return a if a.is_a?(String) || a.id == name.downcase }
156
156
  raise RHC::AliasNotFoundException.new("Alias #{name} can't be found in application #{@name}.")
157
157
  end
158
158
 
@@ -443,8 +443,8 @@ module RHC
443
443
 
444
444
  # Copy messages to each object
445
445
  messages = Array(result['messages']).map do |m|
446
- m['text'] if m['field'].nil? or m['field'] == 'result' or m['severity'] == 'result'
447
- end.compact
446
+ m['text'] if (m['field'] == 'result' || m['severity'] == 'result') && (m['severity'] != 'debug' || debug?)
447
+ end.compact.map!(&:chomp)
448
448
  data.each{ |d| d['messages'] = messages } if data.is_a?(Array)
449
449
  data['messages'] = messages if data.is_a?(Hash)
450
450
 
@@ -5,7 +5,7 @@ module RHC
5
5
 
6
6
  #Add Application to this domain
7
7
  # options
8
- # cartrdige
8
+ # cartridge
9
9
  # template
10
10
  # scale
11
11
  # gear_profile
@@ -382,11 +382,11 @@ module RHC
382
382
  warn "none"
383
383
 
384
384
  paragraph do
385
- say "Your namespace is unique to your account and is the suffix of the " \
386
- "public URLs we assign to your applications. You may configure your " \
387
- "namespace here or leave it blank and use 'rhc create-domain' to " \
388
- "create a namespace later. You will not be able to create " \
389
- "applications without first creating a namespace."
385
+ say [
386
+ "Your namespace is unique to your account and is the suffix of the public URLs we assign to your applications.",
387
+ ("You may configure your namespace here or leave it blank and use 'rhc create-domain' to create a namespace later." if namespace_optional?),
388
+ "You will not be able to create applications without first creating a namespace.",
389
+ ].compact.join(' ')
390
390
  end
391
391
 
392
392
  ask_for_namespace
@@ -486,7 +486,11 @@ module RHC
486
486
  applications.take(1).each do |app|
487
487
  begin
488
488
  ssh = Net::SSH.start(app.host, app.uuid, :timeout => 60)
489
- rescue => e
489
+ rescue Interrupt => e
490
+ debug_error(e)
491
+ raise "Connection attempt to #{app.host} was interrupted"
492
+ rescue ::Exception => e
493
+ debug_error(e)
490
494
  raise "An SSH connection could not be established to #{app.host}. Your SSH configuration may not be correct, or the application may not be responding. #{e.message} (#{e.class})"
491
495
  ensure
492
496
  ssh.close if ssh
@@ -592,6 +596,11 @@ EOF
592
596
  def finalize_stage
593
597
  true
594
598
  end
599
+
600
+ protected
601
+ def namespace_optional?
602
+ false
603
+ end
595
604
  end
596
605
 
597
606
  class DomainWizard < Wizard
@@ -163,7 +163,7 @@ describe RHC::Commands::App do
163
163
  before{ rest_client.domains.clear }
164
164
  let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1'] }
165
165
  # skips login stage and insecure check because of mock rest client, doesn't check keys
166
- it { run_output(['mydomain', 'y', 'mykey']).should match(/This wizard.*Checking your namespace.*Your domain name 'mydomain' has been successfully created.*Creating application.*Your public SSH key.*Uploading key 'mykey'.*Your application 'app1' is now available.*Cloned to/m) }
166
+ it { run_output(['mydomain', 'y', 'mykey']).should match(/This wizard.*Checking your namespace.*assign to your applications\. You will not be able to create applications without first creating a namespace.*Your domain name 'mydomain' has been successfully created.*Creating application.*Your public SSH key.*Uploading key 'mykey'.*Your application 'app1' is now available.*Cloned to/m) }
167
167
  end
168
168
 
169
169
  context 'when run without a cart' do
@@ -523,7 +523,7 @@ describe RHC::Commands::App do
523
523
  })
524
524
  end
525
525
 
526
- it("should display info returned by the server"){ run_output.should match "Removed foo" }
526
+ it("should display info returned by the server"){ run_output.should match "Deleting application 'foo'" }
527
527
  it("should display results returned by the server"){ run_output.should match "Job URL changed" }
528
528
  it('should exit successfully'){ expect{ run }.to exit_with_code(0) }
529
529
  end
@@ -10,7 +10,7 @@ describe RHC::Commands::Cartridge do
10
10
  run_output.should match(message) if message
11
11
  end
12
12
 
13
- def succeed_with_message(message = "Success")
13
+ def succeed_with_message(message = "done")
14
14
  exit_with_code_and_message(0,message)
15
15
  end
16
16
 
@@ -237,7 +237,8 @@ describe RHC::Commands::Cartridge do
237
237
  })
238
238
  end
239
239
 
240
- it("should display info returned by the server"){ run_output.should match "Removed Jenkins" }
240
+ it("should not display info returned by the server"){ run_output.should_not match "Removed Jenkins" }
241
+ it("should display prefix returned by the server"){ run_output.should match "Removing jenkins-1.4" }
241
242
  it("should display results returned by the server"){ run_output.should match "Job URL changed" }
242
243
  it('should exit successfully'){ expect{ run }.to exit_with_code(0) }
243
244
  end
@@ -273,7 +274,7 @@ describe RHC::Commands::Cartridge do
273
274
  app = domain.add_application("app1", "mock_type")
274
275
  app.add_cartridge('mock_cart-1')
275
276
  end
276
- it { run_output.should match('start') }
277
+ it { run_output.should match(/Starting mock_cart-1 .*done/) }
277
278
  end
278
279
  end
279
280
 
@@ -287,7 +288,7 @@ describe RHC::Commands::Cartridge do
287
288
  app = domain.add_application("app1", "mock_type")
288
289
  app.add_cartridge('mock_cart-1')
289
290
  end
290
- it { run_output.should match('stop') }
291
+ it { run_output.should match(/Stopping mock_cart-1 .*done/) }
291
292
  end
292
293
  end
293
294
 
@@ -301,7 +302,7 @@ describe RHC::Commands::Cartridge do
301
302
  app = domain.add_application("app1", "mock_type")
302
303
  app.add_cartridge('mock_cart-1')
303
304
  end
304
- it { run_output.should match('restart') }
305
+ it { run_output.should match(/Restarting mock_cart-1 .*done/) }
305
306
  end
306
307
  end
307
308
 
@@ -315,7 +316,7 @@ describe RHC::Commands::Cartridge do
315
316
  app = domain.add_application("app1", "mock_type")
316
317
  app.add_cartridge('mock_cart-1')
317
318
  end
318
- it { run_output.should match('reload') }
319
+ it { run_output.should match(/Reloading mock_cart-1 .*done/) }
319
320
  end
320
321
  end
321
322