rhc 0.84.15 → 0.85.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -76,7 +76,7 @@ check_cpath(opt)
76
76
  libra_server = get_var('libra_server')
77
77
  debug = get_var('debug') == 'false' ? nil : get_var('debug')
78
78
 
79
- if opt['help'] || !opt['app']
79
+ if opt['help'] || !opt['app'] || 0 != ARGV.length
80
80
  p_usage
81
81
  end
82
82
 
@@ -104,7 +104,7 @@ app = opt['app']
104
104
 
105
105
  unless user_info['app_info'][app]
106
106
  puts
107
- puts "Could not find app '#{opt['app']}'. Please run rhc-user-info to get a list"
107
+ puts "Could not find app '#{opt['app']}'. Please run rhc-domain-info to get a list"
108
108
  puts "of your current running applications"
109
109
  puts
110
110
  exit 101
@@ -29,9 +29,13 @@ puts""
29
29
 
30
30
  args = ""
31
31
  ARGV.each do|a|
32
+ if a.to_s.strip.length == 0; a = "'#{a}'" end
32
33
  args += " #{a}"
33
34
  end
34
35
 
35
36
  system("rhc-domain-info #{args} 2>&1")
37
+ retcode = $?
38
+
39
+ exit 1 if retcode != 0
36
40
 
37
41
  exit 0
data/lib/rhc ADDED
@@ -0,0 +1,135 @@
1
+ # Copyright 2011 Red Hat, Inc.
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person
4
+ # obtaining a copy of this software and associated documentation files
5
+ # (the "Software"), to deal in the Software without restriction,
6
+ # including without limitation the rights to use, copy, modify, merge,
7
+ # publish, distribute, sublicense, and/or sell copies of the Software,
8
+ # and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ #
25
+ # This is the bash auto completion script for the rhc command
26
+ #
27
+ _rhc()
28
+ {
29
+ local cur opts
30
+ COMPREPLY=()
31
+ cur="${COMP_WORDS[COMP_CWORD]}"
32
+
33
+ if [ $COMP_CWORD -eq 1 ]; then
34
+ opts="domain app sshkey help"
35
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
36
+ elif [ $COMP_CWORD -eq 2 ]; then
37
+ case "${COMP_WORDS[1]}" in
38
+ domain)
39
+ opts="create show alter status destroy"
40
+ ;;
41
+ app)
42
+ opts="create show start stop force-stop restart reload status destroy tidy add-alias remove-alias threaddump snapshot tail cartridge"
43
+ ;;
44
+ sshkey)
45
+ opts="add update remove list"
46
+ ;;
47
+ *)
48
+ opts=""
49
+ ;;
50
+ esac
51
+
52
+ elif [ $COMP_CWORD -eq 3 ]; then
53
+ case "${COMP_WORDS[1]}" in
54
+ domain)
55
+ case "${COMP_WORDS[2]}" in
56
+ create | alter | destroy)
57
+ opts="--debug --help --rhlogin --password --namespace --config --timeout"
58
+ ;;
59
+ show | status)
60
+ opts="--debug --help --rhlogin --password --config --timeout"
61
+ ;;
62
+ *)
63
+ ;;
64
+ esac
65
+ ;;
66
+ app)
67
+ case "${COMP_WORDS[2]}" in
68
+ create)
69
+ opts="--debug --help --rhlogin --password --no-dns --nogit --app --repo --type --enable-jenkins --config --timeout"
70
+ ;;
71
+ show | start | stop | force-stop | restart | reload | status | destroy | tidy | add-alias | remove-alias | threaddump | destroy)
72
+ opts="--debug --help --rhlogin --password --app --alias --bypass --config --timeout"
73
+ ;;
74
+ tail)
75
+ opts="--debug --help --rhlogin --password -app --opts --filepath --config --timeout"
76
+ ;;
77
+ snapshot)
78
+ opts="save restore"
79
+ ;;
80
+ cartridge)
81
+ opts="add remove stop start restart status reload list"
82
+ ;;
83
+ *)
84
+ ;;
85
+ esac
86
+ ;;
87
+ sshkey)
88
+ case "${COMP_WORDS[2]}" in
89
+ add | update)
90
+ opts="--debug --help --rhlogin --password --identifier --ssh --config --timeout"
91
+ ;;
92
+ remove)
93
+ opts="--debug --help --rhlogin --password --identifier --config --timeout"
94
+ ;;
95
+ list)
96
+ opts="--debug --help --rhlogin --password --config --timeout"
97
+ ;;
98
+ *)
99
+ ;;
100
+ esac
101
+ ;;
102
+ esac
103
+
104
+ elif [ $COMP_CWORD -eq 4 ]; then
105
+ case "${COMP_WORDS[1]}" in
106
+ app)
107
+ case "${COMP_WORDS[2]}" in
108
+ snapshot)
109
+ case "${COMP_WORDS[3]}" in
110
+ save | restore)
111
+ opts="--debug --help --rhlogin --password -app --filepath --config --timeout"
112
+ ;;
113
+ *)
114
+ ;;
115
+ esac
116
+ ;;
117
+ cartridge)
118
+ case "${COMP_WORDS[3]}" in
119
+ add | remove | stop | start | restart | status | reload | list)
120
+ opts="--debug --help --rhlogin --password -app --cartridge --config --timeout"
121
+ ;;
122
+ *)
123
+ ;;
124
+ esac
125
+ ;;
126
+ esac
127
+ ;;
128
+ esac
129
+
130
+ fi
131
+
132
+ if [ ${#opts[@]} -gt 0 ]; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ); fi
133
+ return 0
134
+ }
135
+ complete -o default -F _rhc rhc
@@ -1,4 +1,4 @@
1
- # Copyright 2010 Red Hat, Inc.
1
+ # Copyright 2011 Red Hat, Inc.
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person
4
4
  # obtaining a copy of this software and associated documentation files
@@ -219,7 +219,7 @@ module RHC
219
219
  if not_found_message
220
220
  puts not_found_message
221
221
  else
222
- puts "A user with rhlogin '#{rhlogin}' does not have a registered domain. Be sure to run rhc-create-domain before using the other rhc tools."
222
+ puts "A user with rhlogin '#{rhlogin}' does not have a registered domain. Be sure to run 'rhc domain create' before using the other rhc tools."
223
223
  end
224
224
  exit 99
225
225
  elsif response.code == '401'
@@ -274,7 +274,7 @@ module RHC
274
274
  end
275
275
  update_server_api_v(json_resp)
276
276
  begin
277
- ssh_keys = (JSON.parse(json_resp['data'].to_s))['keys']
277
+ ssh_keys = (JSON.parse(json_resp['data'].to_s))
278
278
  rescue JSON::ParserError
279
279
  exit 1
280
280
  end
@@ -320,7 +320,7 @@ module RHC
320
320
  rescue Exception => e
321
321
  puts "There was a problem communicating with the server. Response message: #{e.message}"
322
322
  puts "If you were disconnected it is possible the operation finished without being able to report success."
323
- puts "You can use rhc-user-info and rhc-ctl-app to learn about the status of your user and application(s)."
323
+ puts "You can use 'rhc domain show' and 'rhc app status' to learn about the status of your user and application(s)."
324
324
  exit 219
325
325
  end
326
326
  end
@@ -415,6 +415,7 @@ module RHC
415
415
  data = {:cartridge => app_type,
416
416
  :action => 'configure',
417
417
  :app_name => app_name,
418
+ :node_profile => 'large',
418
419
  :rhlogin => rhlogin
419
420
  }
420
421
  if @mydebug
@@ -505,7 +506,7 @@ clone your git repository.
505
506
  If you can't get your application '#{app_name}' running in the browser, you can
506
507
  also try destroying and recreating the application as well using:
507
508
 
508
- rhc-ctl-app -c destroy -a #{app_name} -l #{rhlogin}
509
+ rhc app destroy -a #{app_name} -l #{rhlogin}
509
510
 
510
511
  If this doesn't work for you, let us know in the forums or in IRC and we'll
511
512
  make sure to get you up and running.
@@ -719,7 +720,7 @@ LOOKSGOOD
719
720
  end
720
721
 
721
722
  json_data = generate_json(data)
722
-
723
+ puts json_data
723
724
  url = nil
724
725
  if embedded
725
726
  url = URI.parse("https://#{libra_server}/broker/embed_cartridge")
@@ -735,7 +736,7 @@ LOOKSGOOD
735
736
  print_response_err(response)
736
737
  end
737
738
  end
738
-
739
+
739
740
  end
740
741
 
741
742
  # provide a hook for performing actions before rhc-* commands exit
@@ -845,7 +846,7 @@ end
845
846
  def kfile_not_found
846
847
  puts <<KFILE_NOT_FOUND
847
848
  Your SSH keys are created either by running ssh-keygen (password optional)
848
- or by having the rhc-create-domain command do it for you. If you created
849
+ or by having the 'rhc domain create' command do it for you. If you created
849
850
  them on your own (or want to use an existing keypair), be sure to paste
850
851
  your public key into the express console at http://www.openshift.com.
851
852
  The client tools use the value of 'ssh_key_file' in express.conf to find
@@ -889,4 +890,90 @@ def get_kpfile(kfile, check_exists=true)
889
890
  kfile_not_found
890
891
  end
891
892
  return kpfile
892
- end
893
+ end
894
+
895
+ # Add a new namespace to configs
896
+ def self.add_rhlogin_config(rhlogin, uuid)
897
+ f = open(File.expand_path(config_path), 'a')
898
+ unless config.get_value('default_rhlogin')
899
+ f.puts("# Default rhlogin to use if none is specified")
900
+ f.puts("default_rhlogin=#{rhlogin}")
901
+ f.puts("")
902
+ end
903
+ f.close
904
+ end
905
+
906
+ # Check / add new host to ~/.ssh/config
907
+ def self.add_ssh_config_host(rhc_domain, ssh_key_file_path, ssh_config, ssh_config_d)
908
+
909
+ puts "Checking ~/.ssh/config"
910
+ ssh_key_file_name = File.basename(ssh_key_file_path)
911
+ if ssh_key_file_path =~ /^#{ENV['HOME']}/
912
+ ssh_key_file_path = ssh_key_file_path[ENV['HOME'].length..-1]
913
+ if ssh_key_file_path =~ /^\// || ssh_key_file_path =~ /^\\/
914
+ ssh_key_file_path = '~' + ssh_key_file_path
915
+ else
916
+ ssh_key_file_path = '~/' + ssh_key_file_path
917
+ end
918
+ end
919
+ if (ssh_key_file_name != 'id_rsa')
920
+ found = false
921
+
922
+ begin
923
+ File.open(ssh_config, "r") do |sline|
924
+ while(line = sline.gets)
925
+ if line.to_s.index("Host *.#{rhc_domain}") == 0
926
+ found = true
927
+ break
928
+ end
929
+ end
930
+ end
931
+ rescue Errno::EACCES
932
+ puts "Could not read from #{ssh_config}"
933
+ puts "Reason: " + $!
934
+ puts
935
+ puts "Please correct this first. Then run rerun."
936
+ puts
937
+ exit 213
938
+ rescue Errno::ENOENT
939
+ puts "Could not find #{ssh_config}. This is ok, continuing"
940
+ end
941
+ if found
942
+ puts "Found #{rhc_domain} in ~/.ssh/config... No need to adjust"
943
+ else
944
+ puts " Adding #{rhc_domain} to ~/.ssh/config"
945
+ begin
946
+ f = File.open(ssh_config, "a")
947
+ f.puts <<SSH
948
+
949
+ # Added by 'rhc domain create' on #{`date`}
950
+ Host *.#{rhc_domain}
951
+ IdentityFile #{ssh_key_file_path}
952
+ VerifyHostKeyDNS yes
953
+ StrictHostKeyChecking no
954
+ UserKnownHostsFile ~/.ssh/libra_known_hosts
955
+
956
+ SSH
957
+ f.close
958
+ rescue Errno::EACCES
959
+ puts "Could not write to #{ssh_config}"
960
+ puts "Reason: " + $!
961
+ puts
962
+ puts "Please correct this first. Then run rerun."
963
+ puts
964
+ exit 214
965
+ rescue Errno::ENOENT
966
+ # Make directory and config if they do not exist
967
+ puts "Could not find directory: " + $!
968
+ puts "creating"
969
+ FileUtils.mkdir_p ssh_config_d
970
+ file = File.open(ssh_config, 'w')
971
+ file.close
972
+ retry
973
+ end
974
+ end
975
+
976
+ File.chmod(0700, ssh_config_d)
977
+ File.chmod(0600, ssh_config)
978
+ end
979
+ 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: 337
4
+ hash: 339
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 84
9
- - 15
10
- version: 0.84.15
8
+ - 85
9
+ - 12
10
+ version: 0.85.12
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-01-17 00:00:00 Z
18
+ date: 2012-02-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json_pure
@@ -48,6 +48,10 @@ dependencies:
48
48
  description: The client tools for the OpenShift Express platform that allow for application management.
49
49
  email: openshift@redhat.com
50
50
  executables:
51
+ - rhc
52
+ - rhc-domain
53
+ - rhc-app
54
+ - rhc-sshkey
51
55
  - rhc-chk
52
56
  - rhc-create-app
53
57
  - rhc-create-domain
@@ -57,21 +61,28 @@ executables:
57
61
  - rhc-domain-info
58
62
  - rhc-user-info
59
63
  - rhc-tail-files
64
+ - rhc-port-forward
60
65
  extensions: []
61
66
 
62
67
  extra_rdoc_files: []
63
68
 
64
69
  files:
65
70
  - lib/rhc-common.rb
71
+ - lib/rhc
72
+ - bin/rhc-ctl-domain
73
+ - bin/rhc-port-forward
66
74
  - bin/rhc-ctl-app
67
- - bin/rhc-create-app
68
- - bin/rhc-chk
69
- - bin/rhc-create-domain
70
- - bin/rhc-domain-info
75
+ - bin/rhc-tail-files
71
76
  - bin/rhc-user-info
72
77
  - bin/rhc-snapshot
73
- - bin/rhc-tail-files
74
- - bin/rhc-ctl-domain
78
+ - bin/rhc-domain-info
79
+ - bin/rhc-chk
80
+ - bin/rhc-domain
81
+ - bin/rhc-create-app
82
+ - bin/rhc
83
+ - bin/rhc-app
84
+ - bin/rhc-create-domain
85
+ - bin/rhc-sshkey
75
86
  - conf/express.conf
76
87
  - LICENSE
77
88
  - README