rhc 0.88.9 → 0.90.6
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.
- data/Rakefile +8 -11
- data/bin/rhc +4 -0
- data/bin/rhc-app +13 -14
- data/bin/rhc-chk +4 -4
- data/bin/rhc-create-app +10 -3
- data/bin/rhc-create-domain +2 -2
- data/bin/rhc-ctl-app +1 -1
- data/bin/rhc-ctl-domain +1 -1
- data/bin/rhc-domain +18 -7
- data/bin/rhc-domain-info +13 -4
- data/bin/rhc-port-forward +3 -3
- data/bin/rhc-snapshot +9 -4
- data/bin/rhc-sshkey +1 -1
- data/bin/rhc-tail-files +2 -2
- data/ext/mkrf_conf.rb +26 -0
- data/lib/rhc +4 -1
- data/lib/rhc-common.rb +40 -22
- metadata +24 -21
data/Rakefile
CHANGED
@@ -26,18 +26,15 @@ spec = Gem::Specification.new do |s|
|
|
26
26
|
s.files = FileList['lib/**/*.rb', 'lib/rhc', 'bin/*', 'conf/*'].to_a
|
27
27
|
s.files += %w(LICENSE COPYRIGHT README Rakefile)
|
28
28
|
s.executables = ['rhc', 'rhc-domain', 'rhc-app', 'rhc-sshkey', 'rhc-chk', 'rhc-create-app', 'rhc-create-domain', 'rhc-ctl-domain', 'rhc-ctl-app', 'rhc-snapshot', 'rhc-domain-info', 'rhc-user-info', 'rhc-tail-files', 'rhc-port-forward']
|
29
|
-
begin
|
30
|
-
# Use Ruby version to target F13, RHEL5, Windows and OSX (assume no Xcode)
|
31
|
-
if ENV['JSON_PURE'] or (RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/)
|
32
|
-
s.add_dependency('json_pure')
|
33
|
-
else
|
34
|
-
s.add_dependency('json')
|
35
|
-
end
|
36
|
-
end
|
37
29
|
s.add_dependency('parseconfig')
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
s.add_dependency('rhc-rest', ">= 0.0.11")
|
31
|
+
|
32
|
+
|
33
|
+
# Adding install time dependencies for
|
34
|
+
# - test-unit (Ruby 1.9)
|
35
|
+
# - json_pure (Ruby (Ruby 1.8.6, Windows, Mac) / json (everything else)
|
36
|
+
# http://en.wikibooks.org/wiki/Ruby_Programming/RubyGems
|
37
|
+
s.extensions << 'ext/mkrf_conf.rb'
|
41
38
|
end
|
42
39
|
|
43
40
|
# Define a :package task that bundles the gem
|
data/bin/rhc
CHANGED
@@ -12,6 +12,7 @@ List of resources
|
|
12
12
|
domain Manage the namespace for the registered rhcloud user.
|
13
13
|
app Manage applications within the rhcloud account.
|
14
14
|
sshkey Manage multiple keys for the registered rhcloud user.
|
15
|
+
port-forward Forward remote ports to the workstation
|
15
16
|
|
16
17
|
See 'rhc <resource> --help' for more applicable commands and argumments on a specific resource.
|
17
18
|
|
@@ -40,6 +41,9 @@ when "app"
|
|
40
41
|
when "sshkey"
|
41
42
|
system("rhc-sshkey #{get_args} 2>&1")
|
42
43
|
retcode = $?
|
44
|
+
when "port-forward"
|
45
|
+
system("rhc-port-forward #{get_args} 2>&1")
|
46
|
+
retcode = $?
|
43
47
|
when "-h", "--help", "help", nil
|
44
48
|
p_usage
|
45
49
|
else
|
data/bin/rhc-app
CHANGED
@@ -14,7 +14,7 @@ def p_usage
|
|
14
14
|
puts <<USAGE
|
15
15
|
|
16
16
|
Usage: rhc app (<command> | cartridge <cartridge-action> | --help) [<args>]
|
17
|
-
Create and manage an OpenShift
|
17
|
+
Create and manage an OpenShift application.
|
18
18
|
|
19
19
|
List of commands
|
20
20
|
create Bind a registered rhcloud user to a domain in rhcloud.
|
@@ -45,12 +45,13 @@ List of cartridge actions
|
|
45
45
|
reload Reloads embedded application configuration
|
46
46
|
|
47
47
|
List of arguments
|
48
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
48
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
49
49
|
-p|--password password RHLogin password (optional, will prompt)
|
50
50
|
-a|--app application Application name (alphanumeric - max #{RHC::APP_NAME_MAX_LENGTH} chars) (required)
|
51
51
|
-t|--type type Type of app to create (#{type_keys}) (required for creating an application)
|
52
52
|
-c|--cartridge cartridge The embedded cartrige to manage (required for the cartridge command)
|
53
53
|
-g|--gear-size size The size of the gear for this app ([small|medium|large], defaults to small)
|
54
|
+
-s|--scaling Enable scaling for this app
|
54
55
|
-r|--repo path Git Repo path (defaults to ./$app_name)
|
55
56
|
-n|--nogit Only create remote space, don't pull it locally
|
56
57
|
--no-dns Skip DNS check. Must be used in combination with --nogit
|
@@ -62,10 +63,7 @@ List of arguments
|
|
62
63
|
--alias alias Specify server alias (when using add/remove-alias)
|
63
64
|
--config path Path of alternate config file
|
64
65
|
--timeout # Timeout, in seconds, for connection
|
65
|
-
--enable-jenkins [name] Indicates to create a Jenkins application (if not already available)
|
66
|
-
and embed the Jenkins client into this application. The default
|
67
|
-
name will be 'jenkins' if not specified. Note that --no-dns is ignored
|
68
|
-
for the creation of the Jenkins application.
|
66
|
+
--enable-jenkins [name] Indicates to create a Jenkins application (if not already available) and embed the Jenkins client into this application. The default name will be 'jenkins' if not specified. Note that --no-dns is ignored for the creation of the Jenkins application.
|
69
67
|
USAGE
|
70
68
|
exit 255
|
71
69
|
end
|
@@ -109,7 +107,7 @@ def create_app
|
|
109
107
|
app_info = user_info['app_info']
|
110
108
|
|
111
109
|
if app_info[$opt['app']]
|
112
|
-
puts "An application named '#{$opt['app']}' in namespace '#{user_info['user_info']['namespace']}' already exists"
|
110
|
+
puts "An application named '#{$opt['app']}' in namespace '#{user_info['user_info']['domains'][0]['namespace']}' already exists"
|
113
111
|
exit 255
|
114
112
|
end
|
115
113
|
|
@@ -228,7 +226,7 @@ currently being created: '#{$opt['app']}'
|
|
228
226
|
#
|
229
227
|
# Create remote application space
|
230
228
|
#
|
231
|
-
main_app = RHC::create_app($libra_server, @http, user_info, $opt['app'], $opt['type'], $opt['rhlogin'], $password, $opt['repo'], $opt['no-dns'], $opt['nogit'], false, $opt['gear-size'])
|
229
|
+
main_app = RHC::create_app($libra_server, @http, user_info, $opt['app'], $opt['type'], $opt['rhlogin'], $password, $opt['repo'], $opt['no-dns'], $opt['nogit'], false, $opt['gear-size'], $opt['scaling'])
|
232
230
|
if jenkins_app_name
|
233
231
|
puts "Now embedding the jenkins client into '#{$opt['app']}'..."
|
234
232
|
RHC::ctl_app($libra_server, @http, $opt['app'], $opt['rhlogin'], $password, 'configure', true, 'jenkins-client-1.4', nil, false)
|
@@ -268,8 +266,8 @@ def show_app
|
|
268
266
|
puts " Framework: #{val['framework']}"
|
269
267
|
puts " Creation: #{val['creation_time']}"
|
270
268
|
puts " UUID: #{val['uuid']}"
|
271
|
-
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
272
|
-
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
269
|
+
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
270
|
+
puts " Public URL: http://#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
273
271
|
if val['aliases'] && !val['aliases'].empty?
|
274
272
|
puts " Aliases: #{val['aliases'].join(', ')}"
|
275
273
|
end
|
@@ -368,7 +366,7 @@ def save_or_restore_snapshot(command)
|
|
368
366
|
user_info = RHC::get_user_info($libra_server, $opt['rhlogin'], $password, @http, @mydebug, false)
|
369
367
|
|
370
368
|
app = $opt['app']
|
371
|
-
$opt['filepath'] = "#{$opt['app']}.tar.gz"
|
369
|
+
$opt['filepath'] = "#{$opt['app']}.tar.gz" unless $opt['filepath']
|
372
370
|
|
373
371
|
unless user_info['app_info'][app]
|
374
372
|
puts
|
@@ -379,7 +377,7 @@ def save_or_restore_snapshot(command)
|
|
379
377
|
end
|
380
378
|
|
381
379
|
app_uuid = user_info['app_info'][app]['uuid']
|
382
|
-
namespace = user_info['user_info']['namespace']
|
380
|
+
namespace = user_info['user_info']['domains'][0]['namespace']
|
383
381
|
rhc_domain = user_info['user_info']['rhc_domain']
|
384
382
|
if command == 'save'
|
385
383
|
ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'snapshot' > #{$opt['filepath']}"
|
@@ -400,7 +398,7 @@ def save_or_restore_snapshot(command)
|
|
400
398
|
puts "Restoring from snapshot #{$opt['filepath']}"
|
401
399
|
end
|
402
400
|
else
|
403
|
-
puts "Archive not found: #{$opt['filepath']}"
|
401
|
+
puts "Archive not found: #{$opt['filepath']} - you may specify a path to the archive using the -f option"
|
404
402
|
exit 255
|
405
403
|
end
|
406
404
|
end
|
@@ -442,7 +440,7 @@ def show_logs
|
|
442
440
|
$opt['filepath'] = "#{$opt['app']}/logs/*" unless $opt['filepath']
|
443
441
|
file_glob = "#{$opt['filepath']}"
|
444
442
|
app_uuid = user_info['app_info'][app]['uuid']
|
445
|
-
namespace = user_info['user_info']['namespace']
|
443
|
+
namespace = user_info['user_info']['domains'][0]['namespace']
|
446
444
|
rhc_domain = user_info['user_info']['rhc_domain']
|
447
445
|
|
448
446
|
# -t to force PTY and avoid daemons
|
@@ -486,6 +484,7 @@ begin
|
|
486
484
|
["--repo", "-r", GetoptLong::REQUIRED_ARGUMENT],
|
487
485
|
["--type", "-t", GetoptLong::REQUIRED_ARGUMENT],
|
488
486
|
["--enable-jenkins", GetoptLong::OPTIONAL_ARGUMENT],
|
487
|
+
["--scaling", "-s", GetoptLong::OPTIONAL_ARGUMENT],
|
489
488
|
["--config", GetoptLong::REQUIRED_ARGUMENT],
|
490
489
|
["--timeout", GetoptLong::REQUIRED_ARGUMENT]
|
491
490
|
)
|
data/bin/rhc-chk
CHANGED
@@ -26,7 +26,7 @@ Usage: rhc domain status
|
|
26
26
|
Run a simple check on local configs and credentials to confirm tools are
|
27
27
|
properly setup. Often run to troubleshoot connection issues.
|
28
28
|
|
29
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
29
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
30
30
|
-p|--password password Red Hat password (for RHN or OpenShift)
|
31
31
|
-d|--debug Print Debug info
|
32
32
|
-h|--help Show Usage info
|
@@ -273,6 +273,7 @@ class Test3_SSH < Test::Unit::TestCase
|
|
273
273
|
end
|
274
274
|
|
275
275
|
def test_01_ssh_private_key
|
276
|
+
$remote_ssh_pubkeys = []
|
276
277
|
check_permissions(@libra_kfile, /[4-7]00/) # Needs to at least be readable by user and nobody else
|
277
278
|
|
278
279
|
# Derive the public key from the private key
|
@@ -282,11 +283,10 @@ class Test3_SSH < Test::Unit::TestCase
|
|
282
283
|
assert_not_nil @@local_derived_ssh_pubkey, error_for(:no_derive)
|
283
284
|
assert_not_nil $user_info, error_for(:no_account)
|
284
285
|
|
285
|
-
$remote_ssh_pubkeys = []
|
286
286
|
ssh_keys = RHC::get_ssh_keys($libra_server, $rhlogin, $password, $http)
|
287
287
|
my_keys = [ssh_keys['ssh_key'], ssh_keys['keys'].values.map{|k| k['key']}].flatten
|
288
288
|
my_keys.delete_if{|x| x.length == 0 }
|
289
|
-
$remote_ssh_pubkeys = my_keys
|
289
|
+
$remote_ssh_pubkeys = my_keys unless my_keys.nil?
|
290
290
|
|
291
291
|
# Ensure that the user has ssh keys
|
292
292
|
assert(!$remote_ssh_pubkeys.empty?, error_for(:no_remote_pub_keys ) )
|
@@ -328,7 +328,7 @@ class Test3_SSH < Test::Unit::TestCase
|
|
328
328
|
host_template = "%s@%s-%s.%s"
|
329
329
|
$user_info['app_info'].each do |k,v|
|
330
330
|
uuid = v['uuid']
|
331
|
-
host = sprintf("%s-%s",k,$user_info['user_info']['namespace'])
|
331
|
+
host = sprintf("%s-%s",k,$user_info['user_info']['domains'][0]['namespace'])
|
332
332
|
domain = $user_info['user_info']['rhc_domain']
|
333
333
|
ssh_command = sprintf("ssh %s@%s.%s true &> /dev/null", uuid, host, domain)
|
334
334
|
system(ssh_command)
|
data/bin/rhc-create-app
CHANGED
@@ -26,12 +26,13 @@ def p_usage
|
|
26
26
|
puts <<USAGE
|
27
27
|
|
28
28
|
Usage: #{$0}
|
29
|
-
Create an OpenShift
|
29
|
+
Create an OpenShift app.
|
30
30
|
|
31
31
|
-a|--app application Application name (alphanumeric - max #{RHC::APP_NAME_MAX_LENGTH} chars) (required)
|
32
32
|
-t|--type type Type of app to create (#{type_keys}) (required)
|
33
33
|
-g|--gear-size size The size of the gear for this app ([small|medium|large], defaults to small)
|
34
|
-
-
|
34
|
+
-s|--scaling Enable scaling for this app
|
35
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
35
36
|
-p|--password password RHLogin password (optional, will prompt)
|
36
37
|
-r|--repo path Git Repo path (defaults to ./$app_name)
|
37
38
|
-n|--nogit Only create remote space, don't pull it locally
|
@@ -132,7 +133,7 @@ user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, fa
|
|
132
133
|
app_info = user_info['app_info']
|
133
134
|
|
134
135
|
if app_info[opt['app']]
|
135
|
-
puts "An application named '#{opt['app']}' in namespace '#{user_info['user_info']['namespace']}' already exists"
|
136
|
+
puts "An application named '#{opt['app']}' in namespace '#{user_info['user_info']['domains'][0]['namespace']}' already exists"
|
136
137
|
exit 255
|
137
138
|
end
|
138
139
|
|
@@ -246,6 +247,12 @@ end
|
|
246
247
|
# Create remote application space
|
247
248
|
#
|
248
249
|
main_app = RHC::create_app(libra_server, @http, user_info, opt['app'], opt['type'], opt['rhlogin'], password, opt['repo'], opt['no-dns'], opt['nogit'], false, gear_size, opt['scaling'])
|
250
|
+
|
251
|
+
if !main_app
|
252
|
+
puts "Create app failed"
|
253
|
+
exit 1
|
254
|
+
end
|
255
|
+
|
249
256
|
if jenkins_app_name
|
250
257
|
puts "Now embedding the jenkins client into '#{opt['app']}'..."
|
251
258
|
RHC::ctl_app(libra_server, @http, opt['app'], opt['rhlogin'], password, 'configure', true, 'jenkins-client-1.4', nil, false)
|
data/bin/rhc-create-domain
CHANGED
@@ -15,7 +15,7 @@ Bind a registered rhcloud user to a domain in rhcloud.
|
|
15
15
|
<id_rsa>.pub keys, then re-run with --alter
|
16
16
|
|
17
17
|
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required)
|
18
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
18
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
19
19
|
-p|--password password RHLogin password (optional, will prompt)
|
20
20
|
-a|--alter Alter namespace (will change urls) and/or ssh key
|
21
21
|
-d|--debug Print Debug info
|
@@ -235,7 +235,7 @@ EOF
|
|
235
235
|
else
|
236
236
|
app_info = user_info['app_info']
|
237
237
|
dns_success = true
|
238
|
-
if !app_info.empty? && opt['namespace'] != user_info['user_info']['namespace']
|
238
|
+
if !app_info.empty? && opt['namespace'] != user_info['user_info']['domains'][0]['namespace']
|
239
239
|
#
|
240
240
|
# Confirm that the host(s) exist in DNS
|
241
241
|
#
|
data/bin/rhc-ctl-app
CHANGED
@@ -11,7 +11,7 @@ Usage: #{$0}
|
|
11
11
|
Control an OpenShift express app
|
12
12
|
|
13
13
|
-a|--app application Application name (alphanumeric) (required)
|
14
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
14
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
15
15
|
-p|--password password RHLogin password (optional, will prompt)
|
16
16
|
-c|--command command (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)
|
17
17
|
-L|--embedded-list List supported embedded cartridges
|
data/bin/rhc-ctl-domain
CHANGED
@@ -13,7 +13,7 @@ Manage multiple keys for the registered rhcloud user.
|
|
13
13
|
|
14
14
|
rhc-ctl-domain [-l rhlogin] [-p password] [-d] [-h] [-n namespace] (-a key-name [-k ssh-pubkey] | -u key-name [-k ssh-pubkey] | -r key-name | --destroy)
|
15
15
|
|
16
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
16
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
17
17
|
-p|--password password RHLogin password (optional, will prompt)
|
18
18
|
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required for destroying domain)
|
19
19
|
-a|--add-ssh-key key-name Add SSH key to the user account (key-name is the user-specified identifier for the key)
|
data/bin/rhc-domain
CHANGED
@@ -19,7 +19,7 @@ List of commands
|
|
19
19
|
destroy Destroys the domain and any added ssh keys
|
20
20
|
|
21
21
|
List of arguments
|
22
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
22
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
23
23
|
-p|--password password RHLogin password (optional, will prompt)
|
24
24
|
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required for creating or destroying domain)
|
25
25
|
-d|--debug Print Debug info
|
@@ -73,9 +73,9 @@ def create_or_alter_domain(alter=false)
|
|
73
73
|
|
74
74
|
# Check to see if a ssh_key_file_path exists, if not create it.
|
75
75
|
if File.readable?(ssh_key_file_path)
|
76
|
-
puts "OpenShift
|
76
|
+
puts "OpenShift key found at #{ssh_key_file_path}. Reusing..."
|
77
77
|
else
|
78
|
-
puts "Generating OpenShift
|
78
|
+
puts "Generating OpenShift ssh key to #{ssh_key_file_path}"
|
79
79
|
# Use system for interaction
|
80
80
|
system("ssh-keygen -t rsa -f '#{ssh_key_file_path}'")
|
81
81
|
end
|
@@ -126,7 +126,7 @@ EOF
|
|
126
126
|
else
|
127
127
|
app_info = user_info['app_info']
|
128
128
|
dns_success = true
|
129
|
-
if !app_info.empty? && $opt['namespace'] != user_info['user_info']['namespace']
|
129
|
+
if !app_info.empty? && $opt['namespace'] != user_info['user_info']['domains'][0]['namespace']
|
130
130
|
#
|
131
131
|
# Confirm that the host(s) exist in DNS
|
132
132
|
#
|
@@ -207,10 +207,21 @@ def show_domain_info()
|
|
207
207
|
|
208
208
|
user_info = RHC::get_user_info($libra_server, $opt['rhlogin'], $password, @http, true)
|
209
209
|
|
210
|
+
domains = user_info['user_info']['domains']
|
211
|
+
num_domains = domains.length
|
212
|
+
|
210
213
|
puts ""
|
211
214
|
puts "User Info"
|
212
215
|
puts "========="
|
213
|
-
|
216
|
+
|
217
|
+
if num_domains == 0
|
218
|
+
puts "Namespace: No namespaces found. You can use 'rhc domain create -n <namespace>' to create a namespace for your applications."
|
219
|
+
elsif num_domains == 1
|
220
|
+
puts "Namespace: #{domains[0]['namespace']}"
|
221
|
+
else
|
222
|
+
domains.each_index { |i| puts "Namespace(#{i}): #{domains[i]['namespace']}" }
|
223
|
+
end
|
224
|
+
|
214
225
|
#puts " UUID: #{user_info['user_info']['uuid']}"
|
215
226
|
puts " RHLogin: #{user_info['user_info']['rhlogin']}"
|
216
227
|
|
@@ -224,8 +235,8 @@ def show_domain_info()
|
|
224
235
|
puts " Framework: #{val['framework']}"
|
225
236
|
puts " Creation: #{val['creation_time']}"
|
226
237
|
puts " UUID: #{val['uuid']}"
|
227
|
-
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
228
|
-
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
238
|
+
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
239
|
+
puts " Public URL: http://#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
229
240
|
if val['aliases'] && !val['aliases'].empty?
|
230
241
|
puts " Aliases: #{val['aliases'].join(', ')}"
|
231
242
|
end
|
data/bin/rhc-domain-info
CHANGED
@@ -11,7 +11,7 @@ def p_usage
|
|
11
11
|
Usage: #{$0}
|
12
12
|
Display information about a user
|
13
13
|
|
14
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
14
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
15
15
|
-p|--password password RHLogin password (optional, will prompt)
|
16
16
|
-a|--apps List applications for rhlogin
|
17
17
|
-i|--info Show user info
|
@@ -79,9 +79,18 @@ user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, tr
|
|
79
79
|
if opt['info']
|
80
80
|
ssh_keys = RHC::get_ssh_keys(libra_server, opt['rhlogin'], password, @http)
|
81
81
|
|
82
|
+
domains = user_info['user_info']['domains']
|
83
|
+
num_domains = domains.length
|
84
|
+
|
82
85
|
puts "User Info"
|
83
86
|
puts "========="
|
84
|
-
|
87
|
+
if num_domains == 0
|
88
|
+
puts "Namespace: No namespaces found. You can use 'rhc domain create -n <namespace>' to create a namespace for your applications."
|
89
|
+
elsif num_domains == 1
|
90
|
+
puts "Namespace: #{domains[0]['namespace']}"
|
91
|
+
else
|
92
|
+
domains.each_index { |i| puts "Namespace(#{i}): #{domains[i]['namespace']}" }
|
93
|
+
end
|
85
94
|
#puts " UUID: #{user_info['user_info']['uuid']}"
|
86
95
|
puts " RHLogin: #{user_info['user_info']['rhlogin']}"
|
87
96
|
puts "Primary SSH key: #{user_info['user_info']['ssh_key']}"
|
@@ -113,8 +122,8 @@ if opt['apps']
|
|
113
122
|
puts " Framework: #{val['framework']}"
|
114
123
|
puts " Creation: #{val['creation_time']}"
|
115
124
|
puts " UUID: #{val['uuid']}"
|
116
|
-
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
117
|
-
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
125
|
+
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
126
|
+
puts " Public URL: http://#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
118
127
|
if val['aliases'] && !val['aliases'].empty?
|
119
128
|
puts " Aliases: #{val['aliases'].join(', ')}"
|
120
129
|
end
|
data/bin/rhc-port-forward
CHANGED
@@ -8,10 +8,10 @@ def p_usage
|
|
8
8
|
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
9
9
|
puts <<USAGE
|
10
10
|
|
11
|
-
Usage:
|
11
|
+
Usage: rhc port-forward
|
12
12
|
Forward remote ports to the workstation
|
13
13
|
|
14
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
14
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
15
15
|
-a|--app Target application (required)
|
16
16
|
-p|--password password RHLogin password (optional, will prompt)
|
17
17
|
-d|--debug Print Debug info
|
@@ -84,7 +84,7 @@ unless user_info['app_info'][app_name]
|
|
84
84
|
end
|
85
85
|
|
86
86
|
app_uuid = user_info['app_info'][app_name]['uuid']
|
87
|
-
namespace = user_info['user_info']['namespace']
|
87
|
+
namespace = user_info['user_info']['domains'][0]['namespace']
|
88
88
|
rhc_domain = user_info['user_info']['rhc_domain']
|
89
89
|
|
90
90
|
puts "Checking available ports..."
|
data/bin/rhc-snapshot
CHANGED
@@ -11,7 +11,7 @@ def p_usage
|
|
11
11
|
Usage: #{$0}
|
12
12
|
Pull down application snapshot for a user
|
13
13
|
|
14
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
14
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
15
15
|
-a|--app Target application to snapshot (required)
|
16
16
|
-r|--restore Local path of the tarball to restore (restores git and application data folders found in archive)
|
17
17
|
-s|--save Local path to save tarball (default: ./$APPNAME.tar.gz)
|
@@ -46,6 +46,11 @@ rescue Exception => e
|
|
46
46
|
p_usage
|
47
47
|
end
|
48
48
|
|
49
|
+
# check for gnutar - gnu tar is called tar on linux and cygwin but gnutar on
|
50
|
+
# BSD based systems like MacOS X
|
51
|
+
TAR_BIN = 'tar'
|
52
|
+
TAR_BIN = '/usr/bin/gnutar' if File.executable?('/usr/bin/gnutar')
|
53
|
+
|
49
54
|
# If provided a config path, check it
|
50
55
|
check_cpath(opt)
|
51
56
|
|
@@ -89,14 +94,14 @@ unless user_info['app_info'][app]
|
|
89
94
|
end
|
90
95
|
|
91
96
|
app_uuid = user_info['app_info'][app]['uuid']
|
92
|
-
namespace = user_info['user_info']['namespace']
|
97
|
+
namespace = user_info['user_info']['domains'][0]['namespace']
|
93
98
|
rhc_domain = user_info['user_info']['rhc_domain']
|
94
99
|
if opt['save']
|
95
100
|
ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'snapshot' > #{opt['save']}"
|
96
101
|
puts "Pulling down a snapshot to #{opt['save']}"
|
97
102
|
else
|
98
103
|
if File.exists? opt['restore']
|
99
|
-
|
104
|
+
`#{TAR_BIN} --wildcards -tf #{opt['restore']} './*/#{app}'`
|
100
105
|
if $?.exitstatus != 0
|
101
106
|
puts "Archive at #{opt['restore']} does not contain the target application: ./*/#{app}"
|
102
107
|
puts "If you created this archive rather than exported with rhc-snapshot, be sure"
|
@@ -104,7 +109,7 @@ else
|
|
104
109
|
puts "i.e.: tar -czvf <app_name>.tar.gz ./<app_uuid>/"
|
105
110
|
exit 255
|
106
111
|
else
|
107
|
-
|
112
|
+
`#{TAR_BIN} --wildcards -tf #{opt['restore']} './*/git'`
|
108
113
|
include_git = $?.exitstatus == 0
|
109
114
|
ssh_cmd = "cat #{opt['restore']} | ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
|
110
115
|
puts "Restoring from snapshot #{opt['restore']}"
|
data/bin/rhc-sshkey
CHANGED
@@ -18,7 +18,7 @@ List of commands
|
|
18
18
|
remove Remove SSH key from the user account
|
19
19
|
|
20
20
|
List of arguments
|
21
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
21
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
22
22
|
-p|--password password RHLogin password (optional, will prompt)
|
23
23
|
-i|--identifier key-name User-specified identifier for the key
|
24
24
|
-k|--ssh key-filepath SSH public key filepath
|
data/bin/rhc-tail-files
CHANGED
@@ -12,7 +12,7 @@ def p_usage
|
|
12
12
|
Usage: #{$0}
|
13
13
|
Tail the logs of an application
|
14
14
|
|
15
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login
|
15
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login) (#{rhlogin})
|
16
16
|
-a|--app Target application (required)
|
17
17
|
-f|--files File glob relative to app (default <application_name>/logs/*) (optional)
|
18
18
|
-o|--opts Options to pass to the server-side (linux based) tail command (-f is implicit. See the linux tail man page full list of options.) (Ex: --opts '-n 100')
|
@@ -91,7 +91,7 @@ end
|
|
91
91
|
opt['files'] = "#{opt['app']}/logs/*" unless opt['files']
|
92
92
|
file_glob = "#{opt['files']}"
|
93
93
|
app_uuid = user_info['app_info'][app]['uuid']
|
94
|
-
namespace = user_info['user_info']['namespace']
|
94
|
+
namespace = user_info['user_info']['domains'][0]['namespace']
|
95
95
|
rhc_domain = user_info['user_info']['rhc_domain']
|
96
96
|
|
97
97
|
# -t to force PTY and avoid daemons
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/command.rb'
|
3
|
+
require 'rubygems/dependency_installer.rb'
|
4
|
+
begin
|
5
|
+
Gem::Command.build_args = ARGV
|
6
|
+
rescue NoMethodError
|
7
|
+
end
|
8
|
+
inst = Gem::DependencyInstaller.new
|
9
|
+
begin
|
10
|
+
if RUBY_VERSION > "1.9"
|
11
|
+
inst.install "test-unit"
|
12
|
+
end
|
13
|
+
|
14
|
+
if ENV['JSON_PURE'] or (RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/)
|
15
|
+
inst.install('json_pure')
|
16
|
+
else
|
17
|
+
inst.install('json')
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue
|
21
|
+
exit(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
25
|
+
f.write("task :default\n")
|
26
|
+
f.close
|
data/lib/rhc
CHANGED
@@ -8,7 +8,7 @@ _rhc()
|
|
8
8
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
9
9
|
|
10
10
|
if [ $COMP_CWORD -eq 1 ]; then
|
11
|
-
opts="domain app sshkey help"
|
11
|
+
opts="domain app sshkey port-forward help"
|
12
12
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
13
13
|
elif [ $COMP_CWORD -eq 2 ]; then
|
14
14
|
case "${COMP_WORDS[1]}" in
|
@@ -21,6 +21,9 @@ _rhc()
|
|
21
21
|
sshkey)
|
22
22
|
opts="add update remove list"
|
23
23
|
;;
|
24
|
+
port-forward)
|
25
|
+
opts="--debug --help --rhlogin --password --namespace --config --timeout --app"
|
26
|
+
;;
|
24
27
|
*)
|
25
28
|
opts=""
|
26
29
|
;;
|
data/lib/rhc-common.rb
CHANGED
@@ -9,6 +9,7 @@ require 'open3'
|
|
9
9
|
require 'parseconfig'
|
10
10
|
require 'resolv'
|
11
11
|
require 'uri'
|
12
|
+
require 'rhc-rest'
|
12
13
|
|
13
14
|
module RHC
|
14
15
|
|
@@ -278,6 +279,7 @@ module RHC
|
|
278
279
|
req.set_form_data({'json_data' => json_data, 'password' => password})
|
279
280
|
http = http.new(url.host, url.port)
|
280
281
|
http.open_timeout = @mytimeout
|
282
|
+
http.read_timeout = @mytimeout
|
281
283
|
if url.scheme == "https"
|
282
284
|
http.use_ssl = true
|
283
285
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -305,7 +307,9 @@ module RHC
|
|
305
307
|
puts "Re-run with -d for more information."
|
306
308
|
end
|
307
309
|
exit_code = 1
|
308
|
-
if response.
|
310
|
+
if response.class.inspect == "Struct::FakeResponse"
|
311
|
+
print_response_message(response.body)
|
312
|
+
elsif response.content_type == 'application/json'
|
309
313
|
begin
|
310
314
|
json_resp = JSON.parse(response.body)
|
311
315
|
exit_code = print_json_body(json_resp)
|
@@ -320,14 +324,18 @@ module RHC
|
|
320
324
|
|
321
325
|
def self.print_response_messages(json_resp)
|
322
326
|
messages = json_resp['messages']
|
323
|
-
|
327
|
+
print_response_message(messages)
|
328
|
+
end
|
329
|
+
|
330
|
+
def self.print_response_message(message)
|
331
|
+
if (message && !message.empty?)
|
324
332
|
puts ''
|
325
333
|
puts 'MESSAGES:'
|
326
|
-
puts
|
334
|
+
puts message
|
327
335
|
puts ''
|
328
336
|
end
|
329
337
|
end
|
330
|
-
|
338
|
+
|
331
339
|
def self.print_response_success(json_resp, print_result=false)
|
332
340
|
if @mydebug
|
333
341
|
print "Response from server:"
|
@@ -381,8 +389,17 @@ module RHC
|
|
381
389
|
end
|
382
390
|
|
383
391
|
def self.create_app(libra_server, net_http, user_info, app_name, app_type, rhlogin, password, repo_dir=nil, no_dns=false, no_git=false, is_embedded_jenkins=false, gear_size='small',scale=false)
|
384
|
-
|
385
|
-
|
392
|
+
|
393
|
+
# Need to have a fake HTTPResponse object for passing to print_reponse_err
|
394
|
+
Struct.new('FakeResponse',:body,:code,:content_type)
|
395
|
+
|
396
|
+
domains = user_info['user_info']['domains']
|
397
|
+
if domains.empty?
|
398
|
+
emessage = "Please create a domain with 'rhc domain create -n <namespace>' before creating applications."
|
399
|
+
print_response_err(Struct::FakeResponse.new(emessage,403))
|
400
|
+
end
|
401
|
+
namespace = domains[0]['namespace']
|
402
|
+
puts "Creating application: #{app_name} in #{namespace}"
|
386
403
|
data = {:cartridge => app_type,
|
387
404
|
:action => 'configure',
|
388
405
|
:node_profile => gear_size,
|
@@ -397,22 +414,15 @@ module RHC
|
|
397
414
|
# We'll need to then get the new application using the existing
|
398
415
|
# API in order to access the rest of the logic in this function
|
399
416
|
if scale
|
400
|
-
|
401
|
-
require 'rhc-rest'
|
402
|
-
# Need to have a fake HTTPResponse object for passing to print_reponse_err
|
403
|
-
Struct.new('FakeResponse',:body,:code,:content_type)
|
404
|
-
|
405
|
-
# TODO: This logic should be checked by broker
|
406
|
-
unscalable = ['haproxy-1.4','jenkins-1.4','diy-0.1']
|
407
|
-
print_response_err(Struct::FakeResponse.new("Can not create a scaling app of type #{app_type}",403)) if unscalable.include?(app_type)
|
408
|
-
|
409
|
-
end_point = "https://#{libra_server}/broker/rest"
|
417
|
+
end_point = "https://#{libra_server}/broker/rest/api"
|
410
418
|
client = Rhc::Rest::Client.new(end_point, rhlogin, password)
|
411
419
|
|
412
|
-
domain = client.find_domain(user_info['user_info']['namespace']).first
|
420
|
+
domain = client.find_domain(user_info['user_info']['domains'][0]['namespace']).first
|
421
|
+
|
422
|
+
namespace = domain.id
|
413
423
|
# Catch errors
|
414
424
|
begin
|
415
|
-
application = domain.add_application(app_name,app_type,scale)
|
425
|
+
application = domain.add_application(app_name,{:cartridge => app_type, :scale => true})
|
416
426
|
|
417
427
|
# Variables that are needed for the rest of the function
|
418
428
|
app_uuid = application.uuid
|
@@ -421,17 +431,26 @@ module RHC
|
|
421
431
|
# Since health_check_path is not returned, we need to fudge it for now
|
422
432
|
health_check_path =
|
423
433
|
case app_type
|
424
|
-
when
|
434
|
+
when /^php/
|
425
435
|
"health_check.php"
|
426
|
-
when
|
436
|
+
when /^perl/
|
427
437
|
"health_check.pl"
|
428
|
-
|
438
|
+
else
|
429
439
|
"health"
|
430
440
|
end
|
431
441
|
|
432
442
|
puts "DEBUG: '#{app_name}' creation returned success." if @mydebug
|
443
|
+
rescue Rhc::Rest::ResourceAccessException => e
|
444
|
+
print_response_err(Struct::FakeResponse.new(e.message,e.code))
|
433
445
|
rescue Rhc::Rest::ValidationException => e
|
434
446
|
print_response_err(Struct::FakeResponse.new(e.message,406))
|
447
|
+
rescue Rhc::Rest::ServerErrorException => e
|
448
|
+
if e.message =~ /^Failed to create application .* due to:Scalable app cannot be of type/
|
449
|
+
puts "Can not create a scaling app of type #{app_type}, either disable scaling or choose another app type"
|
450
|
+
exit 1
|
451
|
+
else
|
452
|
+
raise e
|
453
|
+
end
|
435
454
|
end
|
436
455
|
else
|
437
456
|
json_data = generate_json(data)
|
@@ -463,7 +482,6 @@ module RHC
|
|
463
482
|
end
|
464
483
|
end
|
465
484
|
|
466
|
-
namespace = user_info['user_info']['namespace']
|
467
485
|
rhc_domain = user_info['user_info']['rhc_domain']
|
468
486
|
|
469
487
|
fqdn = "#{app_name}-#{namespace}.#{rhc_domain}"
|
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:
|
4
|
+
hash: 379
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 90
|
9
|
+
- 6
|
10
|
+
version: 0.90.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-04-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: parseconfig
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -32,17 +32,19 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: rhc-rest
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 9
|
43
43
|
segments:
|
44
44
|
- 0
|
45
|
-
|
45
|
+
- 0
|
46
|
+
- 11
|
47
|
+
version: 0.0.11
|
46
48
|
type: :runtime
|
47
49
|
version_requirements: *id002
|
48
50
|
description: The client tools for the OpenShift Express platform that allow for application management.
|
@@ -62,32 +64,33 @@ executables:
|
|
62
64
|
- rhc-user-info
|
63
65
|
- rhc-tail-files
|
64
66
|
- rhc-port-forward
|
65
|
-
extensions:
|
66
|
-
|
67
|
+
extensions:
|
68
|
+
- ext/mkrf_conf.rb
|
67
69
|
extra_rdoc_files: []
|
68
70
|
|
69
71
|
files:
|
70
72
|
- lib/rhc-common.rb
|
71
73
|
- lib/rhc
|
74
|
+
- bin/rhc-ctl-domain
|
75
|
+
- bin/rhc-port-forward
|
72
76
|
- bin/rhc-ctl-app
|
73
|
-
- bin/rhc-
|
74
|
-
- bin/rhc-
|
75
|
-
- bin/rhc-
|
76
|
-
- bin/rhc-chk
|
77
|
-
- bin/rhc-create-domain
|
77
|
+
- bin/rhc-tail-files
|
78
|
+
- bin/rhc-user-info
|
79
|
+
- bin/rhc-snapshot
|
78
80
|
- bin/rhc-domain-info
|
81
|
+
- bin/rhc-chk
|
82
|
+
- bin/rhc-domain
|
83
|
+
- bin/rhc-create-app
|
79
84
|
- bin/rhc
|
80
|
-
- bin/rhc-
|
85
|
+
- bin/rhc-app
|
86
|
+
- bin/rhc-create-domain
|
81
87
|
- bin/rhc-sshkey
|
82
|
-
- bin/rhc-port-forward
|
83
|
-
- bin/rhc-snapshot
|
84
|
-
- bin/rhc-tail-files
|
85
|
-
- bin/rhc-ctl-domain
|
86
88
|
- conf/express.conf
|
87
89
|
- LICENSE
|
88
90
|
- COPYRIGHT
|
89
91
|
- README
|
90
92
|
- Rakefile
|
93
|
+
- ext/mkrf_conf.rb
|
91
94
|
homepage: https://openshift.redhat.com/app/express
|
92
95
|
licenses: []
|
93
96
|
|