rhc 0.72.29 → 0.73.14
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 +9 -4
- data/bin/rhc-create-app +10 -13
- data/bin/rhc-create-domain +3 -3
- data/bin/rhc-ctl-app +41 -9
- data/bin/rhc-tail-files +3 -3
- data/bin/rhc-user-info +14 -5
- data/lib/rhc-common.rb +18 -27
- metadata +6 -6
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'rake'
|
5
5
|
require 'rake/clean'
|
6
|
-
require '
|
6
|
+
require 'rubygems/package_task'
|
7
7
|
|
8
8
|
task :default => [:package]
|
9
9
|
|
@@ -15,16 +15,21 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
s.email = %q{openshift@redhat.com}
|
16
16
|
s.summary = %q{OpenShift Express Client Tools}
|
17
17
|
s.homepage = %q{https://openshift.redhat.com/app/express}
|
18
|
-
s.description = %q{OpenShift Express
|
18
|
+
s.description = %q{The client tools for the OpenShift Express platform that allow for application management.}
|
19
19
|
s.files = FileList['lib/**/*.rb', 'bin/*', 'conf/*'].to_a
|
20
20
|
s.files += %w(LICENSE README Rakefile)
|
21
21
|
s.executables = ['rhc-create-app', 'rhc-create-domain', 'rhc-ctl-app', 'rhc-snapshot', 'rhc-user-info', 'rhc-tail-files']
|
22
|
-
|
22
|
+
# Use Ruby version to target F13, RHEL5, Windows and OSX (assume no Xcode)
|
23
|
+
if RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/
|
24
|
+
s.add_dependency('json_pure')
|
25
|
+
else
|
26
|
+
s.add_dependency('json')
|
27
|
+
end
|
23
28
|
s.add_dependency('parseconfig')
|
24
29
|
end
|
25
30
|
|
26
31
|
# Define a :package task that bundles the gem
|
27
|
-
|
32
|
+
Gem::PackageTask.new(spec) do |pkg|
|
28
33
|
pkg.need_tar = false
|
29
34
|
end
|
30
35
|
|
data/bin/rhc-create-app
CHANGED
@@ -26,7 +26,7 @@ require 'rhc-common'
|
|
26
26
|
def p_usage
|
27
27
|
libra_server = get_var('libra_server')
|
28
28
|
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
29
|
-
type_keys = RHC::
|
29
|
+
type_keys = RHC::get_cartridge_listing(nil, ', ', libra_server, @http, 'standalone', false)
|
30
30
|
puts <<USAGE
|
31
31
|
|
32
32
|
Usage: #{$0}
|
@@ -90,8 +90,7 @@ if !RHC::check_app(opt['app'])
|
|
90
90
|
p_usage
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
if !type
|
93
|
+
if !opt['type']
|
95
94
|
puts 'Type is required'
|
96
95
|
p_usage
|
97
96
|
end
|
@@ -175,7 +174,10 @@ url = URI.parse("https://#{libra_server}/broker/cartridge")
|
|
175
174
|
response = RHC::http_post(@http, url, json_data, password)
|
176
175
|
|
177
176
|
if response.code == '200'
|
178
|
-
|
177
|
+
json_resp = JSON.parse(response.body)
|
178
|
+
RHC::print_response_success(json_resp, debug, true)
|
179
|
+
json_data = JSON.parse(json_resp['data'])
|
180
|
+
health_check_path = json_data['health_check_path']
|
179
181
|
else
|
180
182
|
RHC::print_response_err(response, debug)
|
181
183
|
end
|
@@ -213,7 +215,7 @@ found = false
|
|
213
215
|
begin
|
214
216
|
File.open(ssh_config, "r") do |sline|
|
215
217
|
while(line = sline.gets)
|
216
|
-
if line.to_s.
|
218
|
+
if line.to_s.index("Host *.#{user_info['user_info']['rhc_domain']}") == 0
|
217
219
|
found = true
|
218
220
|
break
|
219
221
|
end
|
@@ -307,7 +309,8 @@ unless opt['nogit']
|
|
307
309
|
puts "Pulling new repo down"
|
308
310
|
|
309
311
|
puts "git clone --quiet #{git_url} #{opt['repo']}" if debug
|
310
|
-
|
312
|
+
quiet = (debug ? ' ' : '--quiet ')
|
313
|
+
git_pull = %x<git clone #{quiet} #{git_url} #{opt['repo']}>
|
311
314
|
if $?.exitstatus != 0
|
312
315
|
puts "Error in git pull"
|
313
316
|
puts git_pull
|
@@ -345,13 +348,7 @@ puts "Confirming application #{opt['app']} is available"
|
|
345
348
|
while attempt < RHC::Maxretries
|
346
349
|
attempt+=1
|
347
350
|
puts " Attempt # #{attempt}"
|
348
|
-
|
349
|
-
if (type == :php)
|
350
|
-
page = 'health_check.php'
|
351
|
-
elsif (type == :perl)
|
352
|
-
page = 'health_check.pl'
|
353
|
-
end
|
354
|
-
url = URI.parse("http://#{fqdn}/#{page}")
|
351
|
+
url = URI.parse("http://#{fqdn}/#{health_check_path}")
|
355
352
|
begin
|
356
353
|
response = @http.get_response(url)
|
357
354
|
rescue Exception => e
|
data/bin/rhc-create-domain
CHANGED
@@ -148,9 +148,9 @@ response = RHC::http_post(@http, url, json_data, password)
|
|
148
148
|
|
149
149
|
if response.code == '200'
|
150
150
|
begin
|
151
|
-
|
152
|
-
json_resp
|
153
|
-
json_rhlogininfo = JSON.parse(json_resp['
|
151
|
+
json_resp = JSON.parse(response.body)
|
152
|
+
RHC::print_response_success(json_resp, debug)
|
153
|
+
json_rhlogininfo = JSON.parse(json_resp['data'])
|
154
154
|
add_rhlogin_config(json_rhlogininfo['rhlogin'], json_rhlogininfo['uuid'])
|
155
155
|
|
156
156
|
if opt['alter'] != ''
|
data/bin/rhc-ctl-app
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
require 'rhc-common'
|
25
25
|
|
26
|
+
embed_mapper = { 'add' => 'configure', 'remove' => 'deconfigure' }
|
27
|
+
|
26
28
|
def p_usage
|
27
29
|
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
28
30
|
puts <<USAGE
|
@@ -34,6 +36,8 @@ Control an OpenShift express app
|
|
34
36
|
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
35
37
|
-p|--password password RHLogin password (optional, will prompt)
|
36
38
|
-c|--command command (start|stop|restart|reload|status|destroy)
|
39
|
+
-L|--embedded-list List supported embedded cartridges
|
40
|
+
-e|--embed (add-$cartridge|remove-$cartridge) eg: add-mysql-5.1
|
37
41
|
-b|--bypass Bypass warnings
|
38
42
|
-d|--debug Print Debug info
|
39
43
|
-h|--help Show Usage info
|
@@ -42,15 +46,28 @@ USAGE
|
|
42
46
|
exit 255
|
43
47
|
end
|
44
48
|
|
49
|
+
def p_embedded_list
|
50
|
+
libra_server = get_var('libra_server')
|
51
|
+
puts ""
|
52
|
+
puts "List of supported embedded cartridges:"
|
53
|
+
puts ""
|
54
|
+
type_keys = RHC::get_cartridge_listing(nil, ', ', libra_server, @http, 'embedded', false)
|
55
|
+
puts type_keys
|
56
|
+
puts ""
|
57
|
+
exit 255
|
58
|
+
end
|
59
|
+
|
45
60
|
begin
|
46
61
|
opts = GetoptLong.new(
|
47
62
|
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
48
63
|
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
49
64
|
["--bypass", "-b", GetoptLong::NO_ARGUMENT],
|
50
|
-
["--
|
65
|
+
["--embedded-list", "-L", GetoptLong::NO_ARGUMENT],
|
66
|
+
["--rhlogin", "-l", GetoptLong::OPTIONAL_ARGUMENT],
|
67
|
+
["--embed", "-e", GetoptLong::OPTIONAL_ARGUMENT],
|
51
68
|
["--password", "-p", GetoptLong::OPTIONAL_ARGUMENT],
|
52
|
-
["--app",
|
53
|
-
["--command",
|
69
|
+
["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
|
70
|
+
["--command", "-c", GetoptLong::REQUIRED_ARGUMENT]
|
54
71
|
)
|
55
72
|
opt = {}
|
56
73
|
opts.each do |o, a|
|
@@ -67,6 +84,9 @@ debug = get_var('debug') == 'false' ? nil : get_var('debug')
|
|
67
84
|
ssh_config = "#{ENV['HOME']}/.ssh/config"
|
68
85
|
ssh_config_d = "#{ENV['HOME']}/.ssh/"
|
69
86
|
|
87
|
+
if opt["embedded-list"]
|
88
|
+
p_embedded_list
|
89
|
+
end
|
70
90
|
if opt["help"]
|
71
91
|
p_usage
|
72
92
|
end
|
@@ -85,12 +105,12 @@ if !RHC::check_app(opt['app'])
|
|
85
105
|
p_usage
|
86
106
|
end
|
87
107
|
|
88
|
-
unless
|
89
|
-
puts "Command is required"
|
108
|
+
unless opt["embed"] or (opt["command"] and opt["command"] =~ /(start|stop|restart|reload|status|destroy)/)
|
109
|
+
puts "Command or embed is required"
|
90
110
|
p_usage
|
91
111
|
end
|
92
112
|
|
93
|
-
|
113
|
+
unless opt['rhlogin'] && opt['app'] && (opt['command'] || opt['embed'])
|
94
114
|
p_usage
|
95
115
|
end
|
96
116
|
|
@@ -133,8 +153,19 @@ WARNING
|
|
133
153
|
end
|
134
154
|
end
|
135
155
|
|
156
|
+
if opt['embed']
|
157
|
+
action = opt['embed'].split('-')[0]
|
158
|
+
# override action if it's in the mapper
|
159
|
+
action = embed_mapper[opt['embed'].split('-')[0]] if embed_mapper[opt['embed'].split('-')[0]]
|
160
|
+
framework = opt['embed'].split('-')[1..-1].join('-')
|
161
|
+
url = URI.parse("https://#{libra_server}/broker/embed_cartridge")
|
162
|
+
else
|
163
|
+
action = opt['command']
|
164
|
+
url = URI.parse("https://#{libra_server}/broker/cartridge")
|
165
|
+
end
|
166
|
+
|
136
167
|
data = {:cartridge => framework,
|
137
|
-
:action =>
|
168
|
+
:action => action,
|
138
169
|
:app_name => "#{opt['app']}",
|
139
170
|
:rhlogin => "#{opt['rhlogin']}"
|
140
171
|
}
|
@@ -143,14 +174,15 @@ if debug
|
|
143
174
|
end
|
144
175
|
|
145
176
|
json_data = JSON.generate(data)
|
177
|
+
puts "Submitting form: #{json_data}" if debug
|
146
178
|
|
147
179
|
puts "Contacting https://#{libra_server}"
|
148
180
|
|
149
|
-
url = URI.parse("https://#{libra_server}/broker/cartridge")
|
150
181
|
response = RHC::http_post(@http, url, json_data, password)
|
151
182
|
|
152
183
|
if response.code == '200'
|
153
|
-
|
184
|
+
json_resp = JSON.parse(response.body)
|
185
|
+
RHC::print_response_success(json_resp, debug, true)
|
154
186
|
else
|
155
187
|
RHC::print_response_err(response, debug)
|
156
188
|
end
|
data/bin/rhc-tail-files
CHANGED
@@ -35,7 +35,7 @@ Tail the logs of an application
|
|
35
35
|
|
36
36
|
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
37
37
|
-a|--app Target application (required)
|
38
|
-
-f|--files File glob relative to app (default
|
38
|
+
-f|--files File glob relative to app (default <application_name>/logs/*) (optional)
|
39
39
|
-p|--password password RHLogin password (optional, will prompt)
|
40
40
|
-d|--debug Print Debug info
|
41
41
|
-h|--help Show Usage info
|
@@ -100,8 +100,8 @@ unless user_info['app_info'][app]
|
|
100
100
|
exit 101
|
101
101
|
end
|
102
102
|
|
103
|
-
opt['files'] = "logs/*" unless opt['files']
|
104
|
-
file_glob = "#{opt['
|
103
|
+
opt['files'] = "#{opt['app']}/logs/*" unless opt['files']
|
104
|
+
file_glob = "#{opt['files']}"
|
105
105
|
app_uuid = user_info['app_info'][app]['uuid']
|
106
106
|
namespace = user_info['user_info']['namespace']
|
107
107
|
rhc_domain = user_info['user_info']['rhc_domain']
|
data/bin/rhc-user-info
CHANGED
@@ -107,11 +107,20 @@ if opt['apps']
|
|
107
107
|
puts "================"
|
108
108
|
user_info['app_info'].each do |key, val|
|
109
109
|
puts key
|
110
|
-
puts "
|
111
|
-
puts "
|
112
|
-
puts "
|
113
|
-
puts "
|
114
|
-
puts "
|
110
|
+
puts " Framework: #{val['framework']}"
|
111
|
+
puts " Creation: #{val['creation_time']}"
|
112
|
+
puts " UUID: #{val['uuid']}"
|
113
|
+
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
114
|
+
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
115
|
+
puts ""
|
116
|
+
puts " Embedded: "
|
117
|
+
if val['embedded']
|
118
|
+
val['embedded'].each do |embed_key, embed_val|
|
119
|
+
puts " #{embed_key} - #{embed_val['info']}"
|
120
|
+
end
|
121
|
+
else
|
122
|
+
puts " None"
|
123
|
+
end
|
115
124
|
puts ""
|
116
125
|
end
|
117
126
|
|
data/lib/rhc-common.rb
CHANGED
@@ -41,10 +41,10 @@ module RHC
|
|
41
41
|
(time*=adj).to_int
|
42
42
|
end
|
43
43
|
|
44
|
-
def self.
|
44
|
+
def self.get_cartridges_list(libra_server, net_http, cart_type="standalone", debug=true, print_result=nil)
|
45
45
|
puts "Contacting https://#{libra_server} to obtain list of cartridges..."
|
46
46
|
puts " (please excuse the delay)"
|
47
|
-
data = {'
|
47
|
+
data = {'cart_type' => cart_type}
|
48
48
|
if debug
|
49
49
|
data['debug'] = "true"
|
50
50
|
end
|
@@ -58,31 +58,23 @@ module RHC
|
|
58
58
|
print_response_err(response, debug)
|
59
59
|
return []
|
60
60
|
end
|
61
|
+
json_resp = JSON.parse(response.body)
|
61
62
|
if print_result
|
62
|
-
print_response_success(
|
63
|
+
print_response_success(json_resp, debug)
|
63
64
|
end
|
64
65
|
begin
|
65
|
-
|
66
|
-
carts = (JSON.parse(json_resp['result']))['carts']
|
66
|
+
carts = (JSON.parse(json_resp['data']))['carts']
|
67
67
|
rescue JSON::ParserError
|
68
68
|
exit 254
|
69
69
|
end
|
70
70
|
carts
|
71
71
|
end
|
72
72
|
|
73
|
-
def self.
|
74
|
-
carts =
|
73
|
+
def self.get_cartridge_listing(carts, sep, libra_server, net_http, cart_type="standalone", debug=true, print_result=nil)
|
74
|
+
carts = get_cartridges_list(libra_server, net_http, cart_type, debug, print_result) if carts.nil?
|
75
75
|
carts.join(sep)
|
76
76
|
end
|
77
77
|
|
78
|
-
def self.get_cartridge_type(type)
|
79
|
-
if type
|
80
|
-
type = type.split('-')[0]
|
81
|
-
return type.to_sym
|
82
|
-
end
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
|
86
78
|
|
87
79
|
# Invalid chars (") ($) (^) (<) (>) (|) (%) (/) (;) (:) (,) (\) (*) (=) (~)
|
88
80
|
def self.check_rhlogin(rhlogin)
|
@@ -128,7 +120,7 @@ module RHC
|
|
128
120
|
|
129
121
|
def self.print_post_data(h, debug)
|
130
122
|
if (debug)
|
131
|
-
puts '
|
123
|
+
puts 'Submitting form:'
|
132
124
|
h.each do |k,v|
|
133
125
|
if k.to_s != 'password'
|
134
126
|
puts "#{k.to_s}: #{v.to_s}"
|
@@ -172,12 +164,12 @@ module RHC
|
|
172
164
|
end
|
173
165
|
exit 254
|
174
166
|
end
|
167
|
+
json_resp = JSON.parse(response.body)
|
175
168
|
if print_result
|
176
|
-
print_response_success(
|
169
|
+
print_response_success(json_resp, debug)
|
177
170
|
end
|
178
171
|
begin
|
179
|
-
|
180
|
-
user_info = JSON.parse(json_resp['result'].to_s)
|
172
|
+
user_info = JSON.parse(json_resp['data'].to_s)
|
181
173
|
rescue JSON::ParserError
|
182
174
|
exit 254
|
183
175
|
end
|
@@ -231,7 +223,8 @@ module RHC
|
|
231
223
|
end
|
232
224
|
exit_code = 254
|
233
225
|
if response.content_type == 'application/json'
|
234
|
-
|
226
|
+
json_resp = JSON.parse(response.body)
|
227
|
+
exit_code = print_json_body(json_resp, debug)
|
235
228
|
elsif debug
|
236
229
|
puts "HTTP response from server is #{response.body}"
|
237
230
|
end
|
@@ -248,20 +241,18 @@ module RHC
|
|
248
241
|
end
|
249
242
|
end
|
250
243
|
|
251
|
-
def self.print_response_success(
|
244
|
+
def self.print_response_success(json_resp, debug, always_print_result=false)
|
252
245
|
if debug
|
253
246
|
puts "Response from server:"
|
254
|
-
print_json_body(
|
247
|
+
print_json_body(json_resp, debug)
|
255
248
|
elsif always_print_result
|
256
|
-
print_json_body(
|
249
|
+
print_json_body(json_resp, debug)
|
257
250
|
else
|
258
|
-
json_resp = JSON.parse(response.body)
|
259
251
|
print_response_messages(json_resp)
|
260
252
|
end
|
261
253
|
end
|
262
254
|
|
263
|
-
def self.print_json_body(
|
264
|
-
json_resp = JSON.parse(response.body)
|
255
|
+
def self.print_json_body(json_resp, debug)
|
265
256
|
print_response_messages(json_resp)
|
266
257
|
exit_code = json_resp['exit_code']
|
267
258
|
if debug
|
@@ -273,7 +264,7 @@ module RHC
|
|
273
264
|
puts "Exit Code: #{exit_code}"
|
274
265
|
if (json_resp.length > 3)
|
275
266
|
json_resp.each do |k,v|
|
276
|
-
if (k != 'result' && k != 'debug' && k != 'exit_code' && k != 'messages')
|
267
|
+
if (k != 'result' && k != 'debug' && k != 'exit_code' && k != 'messages' && k != 'data')
|
277
268
|
puts "#{k.to_s}: #{v.to_s}"
|
278
269
|
end
|
279
270
|
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:
|
4
|
+
hash: 295
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 73
|
9
|
+
- 14
|
10
|
+
version: 0.73.14
|
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: 2011-
|
18
|
+
date: 2011-07-11 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: "0"
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id002
|
49
|
-
description: OpenShift Express
|
49
|
+
description: The client tools for the OpenShift Express platform that allow for application management.
|
50
50
|
email: openshift@redhat.com
|
51
51
|
executables:
|
52
52
|
- rhc-create-app
|