rhc 0.85.12 → 0.86.7

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.
@@ -186,7 +186,7 @@ module TestBase
186
186
  ensure
187
187
  $debuginfo['fetches'] ||= []
188
188
  body = JSON.parse(response.body)
189
- body['data'] = body['data'] ? JSON.parse(body['data']) : ''
189
+ body['data'] = body['data'] && body['data'] != '' ? JSON.parse(body['data']) : ''
190
190
  $debuginfo['fetches'] << {url.to_s => {
191
191
  'body' => body,
192
192
  'header' => response.instance_variable_get(:@header)
@@ -205,16 +205,29 @@ end
205
205
  #####################################################
206
206
  # Tests start here #
207
207
  #####################################################
208
- # #
209
- # Note: Tests and testcases are run alphabetically #
210
- # #
208
+ # #
209
+ # Note: Tests and testcases are run alphabetically #
210
+ # #
211
211
  #####################################################
212
212
 
213
213
  def error_for(name,*args)
214
214
  if name.kind_of? String
215
215
  name = name.downcase.to_sym
216
216
  end
217
- sprintf($messages[name],*args)
217
+ message = sprintf(get_message(:errors,name),*args)
218
+ solution = get_message(:solutions,name)
219
+ if solution
220
+ message << "\n" << sprintf(solution,*args)
221
+ end
222
+ message
223
+ end
224
+
225
+ def get_message(type,name)
226
+ val = $messages[type][name]
227
+ if val.is_a? Symbol
228
+ val = get_message(type,val)
229
+ end
230
+ val
218
231
  end
219
232
 
220
233
  class Test1_Connectivity < Test::Unit::TestCase
@@ -292,14 +305,13 @@ class Test3_SSH < Test::Unit::TestCase
292
305
  assert_not_nil $user_info, error_for(:no_account)
293
306
 
294
307
  $remote_ssh_pubkeys = []
295
- additional_ssh_keys = RHC::get_ssh_keys($libra_server, $rhlogin, $password, $http)
296
- if additional_ssh_keys['keys'] && additional_ssh_keys['keys'].kind_of?(Hash)
297
- additional_ssh_keys['keys'].each do |name, sshkey|
298
- $remote_ssh_pubkeys.push(sshkey['key'])
299
- end
300
- end
308
+ ssh_keys = RHC::get_ssh_keys($libra_server, $rhlogin, $password, $http)
309
+ my_keys = [ssh_keys['ssh_key'], ssh_keys['keys'].values.map{|k| k['key']}].flatten
310
+ my_keys.delete_if{|x| x.length == 0 }
311
+ $remote_ssh_pubkeys = my_keys
301
312
 
302
- $remote_ssh_pubkeys.push($user_info["user_info"]["ssh_key"])
313
+ # Ensure that the user has ssh keys
314
+ assert(!$remote_ssh_pubkeys.empty?, error_for(:no_remote_pub_keys ) )
303
315
  assert $remote_ssh_pubkeys.include?(@@local_derived_ssh_pubkey), error_for(:no_match_pub, @libra_kfile)
304
316
  end
305
317
 
@@ -313,6 +325,7 @@ class Test3_SSH < Test::Unit::TestCase
313
325
  assert_not_nil @@local_ssh_pubkey, error_for(:no_pubkey, 'the remote key')
314
326
 
315
327
  # Test public key and remote key
328
+ assert_not_nil $user_info, error_for(:no_account)
316
329
  assert $remote_ssh_pubkeys.include?(@@local_ssh_pubkey), error_for(:no_match_pub, @libra_kfile)
317
330
  ensure
318
331
  fp.close if fp
@@ -327,7 +340,7 @@ class Test3_SSH < Test::Unit::TestCase
327
340
  # Make sure we can load keys from ssh-agent
328
341
  assert !loaded_keys.empty?, error_for(:no_keys_loaded)
329
342
  loaded_keys.map!{|key| key.split(' ')[1]}
330
-
343
+
331
344
  assert_not_nil @@local_ssh_pubkey, error_for(:no_pubkey, 'the keys in ssh-agent')
332
345
  assert loaded_keys.include?(@@local_ssh_pubkey),error_for(:pubkey_not_loaded)
333
346
  end
@@ -366,7 +379,7 @@ class CheckRunner < Test::Unit::UI::Console::TestRunner
366
379
  def initialize(*args)
367
380
  super
368
381
  @output_level = 1
369
- puts $messages[:started]
382
+ puts get_message(:status,:started)
370
383
  end
371
384
 
372
385
  def add_fault(fault)
@@ -402,9 +415,9 @@ class CheckRunner < Test::Unit::UI::Console::TestRunner
402
415
  $debuginfo['errors'] = @faults
403
416
 
404
417
  if @faults.empty?
405
- print_underlined $messages[:passed]
418
+ print_underlined get_message(:status,:passed)
406
419
  else
407
- print_underlined $messages[:failed]
420
+ print_underlined get_message(:status,:failed)
408
421
  @errors = []
409
422
  # Need to separate the failures from the errors
410
423
 
@@ -420,7 +433,7 @@ class CheckRunner < Test::Unit::UI::Console::TestRunner
420
433
  # Errors mean something in the test is broken, not just failed
421
434
  unless @errors.empty?
422
435
  @num = 0
423
- print_underlined $messages[:error]
436
+ print_underlined get_message(:status,:error)
424
437
  @errors.each do |e|
425
438
  lines = e.long_display.to_a[1..-1]
426
439
  puts "#{@num+=1}) #{lines.shift}"
@@ -445,24 +458,45 @@ Test::Unit::AutoRunner::RUNNERS[:console] = proc do |r|
445
458
  CheckRunner
446
459
  end
447
460
 
461
+ ############################
462
+ # The following are the error messages to be used for different tests
463
+ # You need to specify a value in :errors
464
+ # If there is a solution, it may also be specified in :solutions
465
+ #
466
+ # Values in may be reused by specifying another symbol as the value
467
+ # for instance the following will use the solution for :bar as the solution for :foo
468
+ #
469
+ # :solutions
470
+ # :foo: :bar
471
+ ############################
448
472
  $messages = YAML.load <<-EOF
449
473
  ---
474
+ :status:
450
475
  :started: Analyzing system
451
476
  :passed: Congratulations, your system has passed all tests
452
477
  :failed: Your system did not pass all of the tests
453
478
  :error: Something went wrong, and not all tests completed
454
- :no_derive: "We were unable to derive your public SSH key and compare it to the remote\n FIX: ???"
455
- :no_connectivity: "Cannot connect to server, therefore most tests will not work\n FIX: Ensure that you are able to connect to %s"
479
+ :errors:
480
+ :no_derive: "We were unable to derive your public SSH key and compare it to the remote"
481
+ :no_connectivity: "Cannot connect to server, therefore most tests will not work"
456
482
  :no_account: You must have an account on the server in order to test SSH key matches
457
483
  :cant_connect: You need to be able to connect to the server in order to test authentication
458
- :no_match_pub: "Local %s does not match remote pub key, SSH auth will not work\n FIX: Perhaps you should regenerate your public key, or run 'rhc sshkey add' to add your new key"
459
- :_404: "The user %s does not have an account on this server\n FIX: Please ensure that you've entered the correct username"
484
+ :no_match_pub: "Local %s does not match remote pub key, SSH auth will not work"
485
+ :_404: "The user %s does not have an account on this server"
460
486
  :no_pubkey: We were unable to read your public SSH key to compare to %s
461
- :_401: "Invalid user credentials for %s\n FIX: Please ensure you used the correct password"
487
+ :_401: "Invalid user credentials for %s"
462
488
  :file_not_found: File %s does not exist, cannot check permissions
463
489
  :_other_http: "There was an error communicating with the server: %s"
464
- :bad_permissions: "File %s has incorrect permissions %s\n FIX: Permissions should match %s"
490
+ :bad_permissions: "File %s has incorrect permissions %s"
465
491
  :no_keys_loaded: Either ssh-agent is not running or you do not have any keys loaded
466
492
  :pubkey_not_loaded: Your public key is not loaded into a running ssh-agent
467
493
  :cant_ssh: "Cannot SSH into your app: %s"
468
- EOF
494
+ :no_remote_pub_keys: "It appears you do not have any public ssh keys."
495
+ :solutions:
496
+ :no_connectivity: "Ensure that you are able to connect to %s"
497
+ :no_match_pub: "Perhaps you should regenerate your public key, or run 'rhc sshkey add' to add your new key"
498
+ :_404: "Please ensure that you've entered the correct username or that you've created an account"
499
+ :_401: "Please ensure you used the correct password"
500
+ :bad_permissions: "Permissions should match %s"
501
+ :no_remote_pub_keys: "You should try to add your ssh-key by running 'rhc sshkey add'"
502
+ EOF
@@ -43,10 +43,10 @@ Create an OpenShift Express app.
43
43
  --no-dns Skip DNS check. Must be used in combination with --nogit
44
44
  --config path Path of alternate config file
45
45
  --timeout # Timeout, in seconds, for connection
46
- --enable-jenkins [name] Indicates to create a Jenkins application (if not already available)
47
- and embed the Jenkins client into this application. The default
48
- name will be 'jenkins' if not specified. Note that --no-dns is ignored
49
- for the creation of the Jenkins application.
46
+ --enable-jenkins [name] Create a Jenkins application (see Note 1)
47
+
48
+ Notes:
49
+ 1. Jenkins applications will have Jenkins embedded. Their default name will be 'jenkins' if not specified and the '--no-dns' flag is ignored.
50
50
 
51
51
  USAGE
52
52
  exit 255
@@ -247,4 +247,4 @@ unless opt['no-dns']
247
247
  puts "Unable to access your new application."
248
248
  exit 1
249
249
  end
250
- end
250
+ end
@@ -123,8 +123,8 @@ unless opt["embed"] or opt["command"]
123
123
  end
124
124
 
125
125
  if opt["command"]
126
- unless opt["command"] =~ /^(start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)$/
127
- puts "Invalid command '#{opt["command"]}' specified. Valid commands are (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)"
126
+ unless opt["command"] =~ /^(start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump|expose-port|conceal-port)$/
127
+ puts "Invalid command '#{opt["command"]}' specified. Valid commands are (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump|expose-port|conceal-port)"
128
128
  p_usage
129
129
  end
130
130
  elsif opt["embed"]
@@ -118,7 +118,7 @@ if opt['save']
118
118
  puts "Pulling down a snapshot to #{opt['save']}"
119
119
  else
120
120
  if File.exists? opt['restore']
121
- `tar -tf #{opt['restore']} './*/#{app}'`
121
+ `tar --wildcards -tf #{opt['restore']} './*/#{app}'`
122
122
  if $?.exitstatus != 0
123
123
  puts "Archive at #{opt['restore']} does not contain the target application: ./*/#{app}"
124
124
  puts "If you created this archive rather than exported with rhc-snapshot, be sure"
@@ -126,7 +126,7 @@ else
126
126
  puts "i.e.: tar -czvf <app_name>.tar.gz ./<app_uuid>/"
127
127
  exit 255
128
128
  else
129
- `tar -tf #{opt['restore']} './*/git'`
129
+ `tar --wildcards -tf #{opt['restore']} './*/git'`
130
130
  include_git = $?.exitstatus == 0
131
131
  ssh_cmd = "cat #{opt['restore']} | ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
132
132
  puts "Restoring from snapshot #{opt['restore']}"
@@ -156,4 +156,4 @@ end
156
156
  exit 1
157
157
  end
158
158
  puts output if opt['restore'] && debug
159
- exit 0
159
+ exit 0
@@ -127,7 +127,11 @@ puts "Use ctl + c to stop"
127
127
  puts
128
128
  puts ssh_cmd if debug
129
129
  begin
130
- exec ssh_cmd
130
+ if opt['files'] == 'system-messages'
131
+ RHC::ctl_app(libra_server, @http, opt['app'], opt['rhlogin'], password, 'system-messages', false, nil, nil)
132
+ else
133
+ exec ssh_cmd
134
+ end
131
135
  rescue SystemCallError
132
136
  puts
133
137
  puts "Error in trying to tail files. You can tail manually by running:"
data/lib/rhc CHANGED
@@ -68,11 +68,11 @@ _rhc()
68
68
  create)
69
69
  opts="--debug --help --rhlogin --password --no-dns --nogit --app --repo --type --enable-jenkins --config --timeout"
70
70
  ;;
71
- show | start | stop | force-stop | restart | reload | status | destroy | tidy | add-alias | remove-alias | threaddump | destroy)
71
+ show | start | stop | force-stop | restart | reload | status | destroy | tidy | add-alias | remove-alias | threaddump | destroy | expose-port | conceal-port )
72
72
  opts="--debug --help --rhlogin --password --app --alias --bypass --config --timeout"
73
73
  ;;
74
74
  tail)
75
- opts="--debug --help --rhlogin --password -app --opts --filepath --config --timeout"
75
+ opts="--debug --help --rhlogin --password --app --opts --filepath --config --timeout"
76
76
  ;;
77
77
  snapshot)
78
78
  opts="save restore"
@@ -108,7 +108,7 @@ _rhc()
108
108
  snapshot)
109
109
  case "${COMP_WORDS[3]}" in
110
110
  save | restore)
111
- opts="--debug --help --rhlogin --password -app --filepath --config --timeout"
111
+ opts="--debug --help --rhlogin --password --app --filepath --config --timeout"
112
112
  ;;
113
113
  *)
114
114
  ;;
@@ -117,7 +117,7 @@ _rhc()
117
117
  cartridge)
118
118
  case "${COMP_WORDS[3]}" in
119
119
  add | remove | stop | start | restart | status | reload | list)
120
- opts="--debug --help --rhlogin --password -app --cartridge --config --timeout"
120
+ opts="--debug --help --rhlogin --password --app --cartridge --config --timeout"
121
121
  ;;
122
122
  *)
123
123
  ;;
@@ -43,7 +43,6 @@ module RHC
43
43
  PATTERN_VERSION=/\A\d+\.\d+\.\d+\z/
44
44
  @mytimeout = 10
45
45
  @mydebug = false
46
- @@broker_version = "?.?.?"
47
46
  @@api_version = "?.?.?"
48
47
 
49
48
  # reset lines
@@ -59,8 +58,7 @@ module RHC
59
58
  'exit_code' => nil,
60
59
  'messages' => nil,
61
60
  'data' => nil,
62
- 'api' => nil,
63
- 'broker' => nil
61
+ 'api' => nil
64
62
  }
65
63
 
66
64
  def self.timeout(val)
@@ -78,9 +76,6 @@ module RHC
78
76
  end
79
77
 
80
78
  def self.update_server_api_v(dict)
81
- if !dict['broker'].nil? && (dict['broker'] =~ PATTERN_VERSION)
82
- @@broker_version = dict['broker']
83
- end
84
79
  if !dict['api'].nil? && (dict['api'] =~ PATTERN_VERSION)
85
80
  @@api_version = dict['api']
86
81
  end
@@ -387,9 +382,6 @@ module RHC
387
382
  if json_resp['api']
388
383
  puts "API version: #{json_resp['api']}"
389
384
  end
390
- if json_resp['broker']
391
- puts "Broker version: #{json_resp['broker']}"
392
- end
393
385
  end
394
386
  if print_result && json_resp['result']
395
387
  puts ''
@@ -415,7 +407,6 @@ module RHC
415
407
  data = {:cartridge => app_type,
416
408
  :action => 'configure',
417
409
  :app_name => app_name,
418
- :node_profile => 'large',
419
410
  :rhlogin => rhlogin
420
411
  }
421
412
  if @mydebug
@@ -674,13 +665,19 @@ LOOKSGOOD
674
665
 
675
666
  stderr.each { |line|
676
667
  line = line.chomp
668
+
669
+ if line.downcase =~ /permission denied/
670
+ puts line
671
+ exit 1
672
+ end
673
+
677
674
  if line.index(ip_and_port_simple_regex)
678
675
  hosts_and_ports_descriptions << line
679
676
  end
680
677
  }
681
678
 
682
679
  }
683
-
680
+
684
681
  #hosts_and_ports_descriptions = stderr.gets.chomp.split(/\n/)
685
682
  #hosts_and_ports = stdout.gets.chomp.split(/\n/)
686
683
 
@@ -720,7 +717,7 @@ LOOKSGOOD
720
717
  end
721
718
 
722
719
  json_data = generate_json(data)
723
- puts json_data
720
+
724
721
  url = nil
725
722
  if embedded
726
723
  url = URI.parse("https://#{libra_server}/broker/embed_cartridge")
@@ -735,8 +732,8 @@ LOOKSGOOD
735
732
  else
736
733
  print_response_err(response)
737
734
  end
735
+ JSON.parse(response.body)
738
736
  end
739
-
740
737
  end
741
738
 
742
739
  # provide a hook for performing actions before rhc-* commands exit
@@ -976,4 +973,4 @@ SSH
976
973
  File.chmod(0700, ssh_config_d)
977
974
  File.chmod(0600, ssh_config)
978
975
  end
979
- end
976
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 339
4
+ hash: 329
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 85
9
- - 12
10
- version: 0.85.12
8
+ - 86
9
+ - 7
10
+ version: 0.86.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Red Hat
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-07 00:00:00 Z
18
+ date: 2012-02-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json_pure
@@ -69,20 +69,20 @@ extra_rdoc_files: []
69
69
  files:
70
70
  - lib/rhc-common.rb
71
71
  - lib/rhc
72
- - bin/rhc-ctl-domain
73
- - bin/rhc-port-forward
74
72
  - bin/rhc-ctl-app
75
- - bin/rhc-tail-files
76
- - bin/rhc-user-info
77
- - bin/rhc-snapshot
78
- - bin/rhc-domain-info
79
- - bin/rhc-chk
80
- - bin/rhc-domain
81
- - bin/rhc-create-app
82
- - bin/rhc
83
73
  - bin/rhc-app
74
+ - bin/rhc-create-app
75
+ - bin/rhc-domain
76
+ - bin/rhc-chk
84
77
  - bin/rhc-create-domain
78
+ - bin/rhc-domain-info
79
+ - bin/rhc
80
+ - bin/rhc-user-info
85
81
  - bin/rhc-sshkey
82
+ - bin/rhc-port-forward
83
+ - bin/rhc-snapshot
84
+ - bin/rhc-tail-files
85
+ - bin/rhc-ctl-domain
86
86
  - conf/express.conf
87
87
  - LICENSE
88
88
  - README