rhc 0.74.6 → 0.75.9
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/bin/rhc-chk +207 -0
- data/bin/rhc-create-app +53 -15
- data/bin/rhc-create-domain +2 -2
- data/bin/rhc-ctl-app +1 -1
- data/bin/rhc-snapshot +32 -4
- data/lib/rhc-common.rb +51 -12
- metadata +6 -5
data/bin/rhc-chk
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright 2011 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation files
|
6
|
+
# (the "Software"), to deal in the Software without restriction,
|
7
|
+
# including without limitation the rights to use, copy, modify, merge,
|
8
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
9
|
+
# and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
19
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
20
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'rhc-common'
|
25
|
+
require 'net/http'
|
26
|
+
require 'net/https'
|
27
|
+
require 'rbconfig'
|
28
|
+
|
29
|
+
|
30
|
+
#
|
31
|
+
# print help
|
32
|
+
#
|
33
|
+
def p_usage
|
34
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
35
|
+
puts <<USAGE
|
36
|
+
|
37
|
+
Usage: #{$0}
|
38
|
+
Run a simple check on local configs and credentials to confirm tools are
|
39
|
+
properly setup. Often run to troubleshoot connection issues.
|
40
|
+
|
41
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
42
|
+
-p|--password password Red Hat password (for RHN or OpenShift)
|
43
|
+
-d|--debug Print Debug info
|
44
|
+
-h|--help Show Usage info
|
45
|
+
|
46
|
+
USAGE
|
47
|
+
exit 255
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
opts = GetoptLong.new(
|
52
|
+
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
53
|
+
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
54
|
+
["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
|
55
|
+
["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
|
56
|
+
)
|
57
|
+
opt = {}
|
58
|
+
opts.each do |o, a|
|
59
|
+
opt[o[2..-1]] = a.to_s
|
60
|
+
end
|
61
|
+
rescue Exception => e
|
62
|
+
#puts e.message
|
63
|
+
p_usage
|
64
|
+
end
|
65
|
+
|
66
|
+
# Pull in configs from files
|
67
|
+
@libra_server = get_var('libra_server')
|
68
|
+
@debug = get_var('debug') == 'false' ? nil : get_var('debug')
|
69
|
+
|
70
|
+
libra_kfile = "#{ENV['HOME']}/.ssh/libra_id_rsa"
|
71
|
+
libra_kpfile = "#{ENV['HOME']}/.ssh/libra_id_rsa.pub"
|
72
|
+
|
73
|
+
if opt["help"]
|
74
|
+
p_usage
|
75
|
+
end
|
76
|
+
|
77
|
+
if opt["debug"]
|
78
|
+
@debug = true
|
79
|
+
end
|
80
|
+
|
81
|
+
opt["rhlogin"] = get_var('default_rhlogin') unless opt["rhlogin"]
|
82
|
+
if !RHC::check_rhlogin(opt['rhlogin'])
|
83
|
+
p_usage
|
84
|
+
end
|
85
|
+
@rhlogin = opt["rhlogin"]
|
86
|
+
|
87
|
+
@password = opt['password']
|
88
|
+
if !@password
|
89
|
+
@password = RHC::get_password
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Generic Info
|
94
|
+
#
|
95
|
+
puts "Ruby Version: #{RUBY_VERSION}"
|
96
|
+
puts "host_alias: #{Config::CONFIG['host_alias']}"
|
97
|
+
|
98
|
+
#
|
99
|
+
# Check for proxy environment
|
100
|
+
#
|
101
|
+
if ENV['http_proxy']
|
102
|
+
host, port = ENV['http_proxy'].split(':')
|
103
|
+
@http = Net::HTTP::Proxy(host, port)
|
104
|
+
puts "Proxy being used: #{host}:#{port}"
|
105
|
+
else
|
106
|
+
@http = Net::HTTP
|
107
|
+
puts "Proxy being used: none"
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_url_json(uri, data)
|
111
|
+
json_data = RHC::generate_json(data)
|
112
|
+
url = URI.parse("https://#{@libra_server}#{uri}")
|
113
|
+
puts " Contacting URL: https://#{@libra_server}#{uri}" if @debug
|
114
|
+
puts " json_data: #{json_data}" if @debug
|
115
|
+
req = @http::Post.new(url.path)
|
116
|
+
req.set_form_data({'json_data' => json_data, 'password' => @password})
|
117
|
+
http = @http.new(url.host, url.port)
|
118
|
+
http.open_timeout = 10
|
119
|
+
if url.scheme == "https"
|
120
|
+
http.use_ssl = true
|
121
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
122
|
+
end
|
123
|
+
begin
|
124
|
+
response = http.start {|http| http.request(req)}
|
125
|
+
puts " Raw Response: #{response.body}" if @debug
|
126
|
+
rescue Exception => e
|
127
|
+
puts " ERROR: #{e.message}"
|
128
|
+
return nil
|
129
|
+
end
|
130
|
+
return response
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Checking Connectivity / cart list
|
135
|
+
#
|
136
|
+
puts
|
137
|
+
puts "TEST1: Confirming connection to OpenShift"
|
138
|
+
data = {'cart_type' => 'standalone'}
|
139
|
+
|
140
|
+
response = test_url_json("/broker/cartlist", data)
|
141
|
+
if response
|
142
|
+
puts " Code: #{response.code}"
|
143
|
+
puts " Message: #{response.message}"
|
144
|
+
resp_json = JSON.parse(response.body)
|
145
|
+
puts " Cart Info: #{resp_json["data"]}"
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
#
|
150
|
+
# Checking Authentication
|
151
|
+
#
|
152
|
+
|
153
|
+
puts
|
154
|
+
puts "TEST2: Authentication (RHN account) / user info"
|
155
|
+
data = {'rhlogin' => @rhlogin}
|
156
|
+
|
157
|
+
response = test_url_json("/broker/userinfo", data)
|
158
|
+
if response
|
159
|
+
puts " Code: #{response.code}"
|
160
|
+
puts " Message: #{response.message}"
|
161
|
+
body = JSON.parse(response.body)
|
162
|
+
@user_info = JSON.parse(body['data'].to_s)
|
163
|
+
puts " rhlogin: #{@user_info["user_info"]["rhlogin"]}"
|
164
|
+
puts " namespace: #{@user_info["user_info"]["namespace"]}"
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Checking ssh key
|
169
|
+
#
|
170
|
+
puts
|
171
|
+
puts "TEST3: SSH Key check"
|
172
|
+
remote_ssh_pubkey = @user_info["user_info"]["ssh_key"]
|
173
|
+
if File.exists?("#{ENV['HOME']}/.ssh/libra_id_rsa")
|
174
|
+
puts " OK: ~/.ssh/libra_id_rsa - Found"
|
175
|
+
key_dump = `ssh-keygen -f ~/.ssh/libra_id_rsa -y`
|
176
|
+
local_derived_ssh_pubkey = key_dump.to_s.strip.split(' ')[1]
|
177
|
+
else
|
178
|
+
puts " ERROR: ~/.ssh/libra_id_rsa - Not Found!"
|
179
|
+
end
|
180
|
+
|
181
|
+
if File.exists?("#{ENV['HOME']}/.ssh/libra_id_rsa.pub")
|
182
|
+
puts " OK: ~/.ssh/libra_id_rsa.pub Found"
|
183
|
+
fp = File.open("#{ENV['HOME']}/.ssh/libra_id_rsa.pub")
|
184
|
+
local_ssh_pubkey = fp.gets.split(' ')[1]
|
185
|
+
fp.close
|
186
|
+
else
|
187
|
+
puts " WARNING: ~/.ssh/libra_id_rsa.pub Not Found! (non fatal error)"
|
188
|
+
end
|
189
|
+
|
190
|
+
if local_ssh_pubkey.to_s.strip == remote_ssh_pubkey.to_s.strip
|
191
|
+
puts " OK: Remote and ~/.ssh/libra_id_rsa.pub - match"
|
192
|
+
else
|
193
|
+
puts " WARNING: Remote and ~/.ssh/libra_id_rsa key do not match. (have you changed machines or ssh keys?)"
|
194
|
+
end
|
195
|
+
|
196
|
+
if local_derived_ssh_pubkey.to_s.strip == remote_ssh_pubkey.to_s.strip
|
197
|
+
puts " OK: local ~/.ssh/libra_id_rsa should auth with openshift"
|
198
|
+
else
|
199
|
+
puts " WARNING: local ~/.ssh/libra_id_rsa DOES NOT match remote pub key, ssh auth cannot continue"
|
200
|
+
puts " FIX: Perhaps you should regenerate your public key, or run rhc-create-domain with -a to alter the remote key"
|
201
|
+
end
|
202
|
+
|
203
|
+
puts "remote_ssh_pubkey: #{remote_ssh_pubkey}" if @debug
|
204
|
+
puts "local_ssh_pubkey: #{local_ssh_pubkey}" if @debug
|
205
|
+
puts "local_derived_ssh_pubkey: #{local_derived_ssh_pubkey}" if @debug
|
206
|
+
|
207
|
+
exit 0
|
data/bin/rhc-create-app
CHANGED
@@ -145,10 +145,15 @@ end
|
|
145
145
|
#
|
146
146
|
unless File.exists?("#{ssh_config_d}/libra_id_rsa")
|
147
147
|
puts
|
148
|
-
puts "Could not find #{ssh_config_d}/libra_id_rsa
|
149
|
-
puts "
|
150
|
-
puts "
|
151
|
-
puts
|
148
|
+
puts "Could not find #{ssh_config_d}/libra_id_rsa. Unable to continue."
|
149
|
+
puts "Your SSH keys are created either by running ssh-keygen (password optional)"
|
150
|
+
puts "or by having the rhc-create-domain command do it for you. If you created"
|
151
|
+
puts "them on your own (or want to use an existing keypair), be sure to paste"
|
152
|
+
puts "your public key into the dashboard page at http://www.openshift.com."
|
153
|
+
puts "The client tools expect libra_id_rsa[.pub] so in the event that you are"
|
154
|
+
puts "using existing keys, you can symlink libra_id_rsa -> id_rsa and"
|
155
|
+
puts "libra_id_rsa.pub -> id_rsa.pub"
|
156
|
+
puts "Also, make sure you never give out your secret key!"
|
152
157
|
exit 212
|
153
158
|
end
|
154
159
|
|
@@ -166,7 +171,7 @@ data = {:cartridge => opt['type'],
|
|
166
171
|
if debug
|
167
172
|
data['debug'] = "true"
|
168
173
|
end
|
169
|
-
json_data =
|
174
|
+
json_data = RHC::generate_json(data)
|
170
175
|
|
171
176
|
puts "Contacting https://#{libra_server}"
|
172
177
|
|
@@ -188,7 +193,7 @@ end
|
|
188
193
|
#
|
189
194
|
at_exit do
|
190
195
|
unless $!.nil? || $!.is_a?(SystemExit) && $!.success?
|
191
|
-
json_data =
|
196
|
+
json_data = RHC::generate_json(
|
192
197
|
{:cartridge => opt['type'],
|
193
198
|
:action => 'deconfigure',
|
194
199
|
:app_name => opt['app'],
|
@@ -272,7 +277,7 @@ File.chmod(0600, ssh_config)
|
|
272
277
|
#
|
273
278
|
# Confirm that the host exists in DNS
|
274
279
|
#
|
275
|
-
puts "Now your new domain name is being
|
280
|
+
puts "Now your new domain name is being propagated worldwide (this might take a minute)..."
|
276
281
|
|
277
282
|
# Allow DNS to propogate
|
278
283
|
sleep 15
|
@@ -287,13 +292,9 @@ while loop < RHC::Maxretries && !RHC::hostexist?(fqdn)
|
|
287
292
|
sleep_time = RHC::delay(sleep_time)
|
288
293
|
end
|
289
294
|
|
290
|
-
if loop >= RHC::Maxretries
|
291
|
-
puts "Host could not be created and/or found..."
|
292
|
-
exit 215
|
293
|
-
end
|
294
|
-
|
295
295
|
sleep_time = 2
|
296
296
|
attempt = 0
|
297
|
+
|
297
298
|
#
|
298
299
|
# Pull new repo locally
|
299
300
|
#
|
@@ -305,15 +306,52 @@ app_uuid = user_info['app_info'][app_name]['uuid']
|
|
305
306
|
|
306
307
|
git_url = "ssh://#{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain}/~/git/#{app_name}.git/"
|
307
308
|
|
309
|
+
# If the hostname couldn't be resolved, print out the git URL
|
310
|
+
# and exit cleanly. This will help solve issues where DNS times
|
311
|
+
# out in APAC, etc on resolution.
|
312
|
+
if loop >= RHC::Maxretries
|
313
|
+
puts <<WARNING
|
314
|
+
|
315
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
316
|
+
WARNING: We weren't able to lookup your hostname (#{fqdn})
|
317
|
+
in a reasonable amount of time. This can happen periodically and will just
|
318
|
+
take an extra minute or two to propagate depending on where you are in the
|
319
|
+
world. Once you are able to access your application in a browser, you can then
|
320
|
+
clone your git repository.
|
321
|
+
|
322
|
+
Application URL: http://#{fqdn}
|
323
|
+
|
324
|
+
Git Repository URL: #{git_url}
|
325
|
+
|
326
|
+
Git Clone command:
|
327
|
+
git clone #{git_url} #{opt['repo']}
|
328
|
+
|
329
|
+
If you can't get your application running in the browser, you can also try
|
330
|
+
destroying and recreating the application as well using:
|
331
|
+
|
332
|
+
rhc-ctl-app -c destroy -a #{opt['app']} -l #{opt["rhlogin"]}
|
333
|
+
|
334
|
+
If this doesn't work for you, let us know in the forums or in IRC and we'll
|
335
|
+
make sure to get you up and running.
|
336
|
+
|
337
|
+
Forums: https://www.redhat.com/openshift/forums/express
|
338
|
+
|
339
|
+
IRC: #openshift (on Freenode)
|
340
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
341
|
+
|
342
|
+
WARNING
|
343
|
+
exit 0
|
344
|
+
end
|
345
|
+
|
308
346
|
unless opt['nogit']
|
309
347
|
puts "Pulling new repo down"
|
310
348
|
|
311
349
|
puts "git clone --quiet #{git_url} #{opt['repo']}" if debug
|
312
350
|
quiet = (debug ? ' ' : '--quiet ')
|
313
|
-
|
351
|
+
git_clone = %x<git clone #{quiet} #{git_url} #{opt['repo']}>
|
314
352
|
if $?.exitstatus != 0
|
315
|
-
puts "Error in git
|
316
|
-
puts
|
353
|
+
puts "Error in git clone"
|
354
|
+
puts git_clone
|
317
355
|
exit 216
|
318
356
|
end
|
319
357
|
else
|
data/bin/rhc-create-domain
CHANGED
@@ -141,7 +141,7 @@ if debug
|
|
141
141
|
data['debug'] = "true"
|
142
142
|
end
|
143
143
|
RHC::print_post_data(data, debug)
|
144
|
-
json_data =
|
144
|
+
json_data = RHC::generate_json(data)
|
145
145
|
|
146
146
|
url = URI.parse("https://#{libra_server}/broker/domain")
|
147
147
|
response = RHC::http_post(@http, url, json_data, password)
|
@@ -168,7 +168,7 @@ EOF
|
|
168
168
|
#
|
169
169
|
# Confirm that the host(s) exist in DNS
|
170
170
|
#
|
171
|
-
puts "Now your new domain name(s) are being
|
171
|
+
puts "Now your new domain name(s) are being propagated worldwide (this might take a minute)..."
|
172
172
|
# Allow DNS to propogate
|
173
173
|
sleep 15
|
174
174
|
app_info.each_key do |appname|
|
data/bin/rhc-ctl-app
CHANGED
data/bin/rhc-snapshot
CHANGED
@@ -35,6 +35,7 @@ Pull down application snapshot for a user
|
|
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 to snapshot (required)
|
38
|
+
-r|--restore Local path of the tarball to restore (restores git and application data folders found in archive)
|
38
39
|
-s|--save Local path to save tarball (default: ./$APPNAME.tar.gz)
|
39
40
|
-p|--password password RHLogin password (optional, will prompt)
|
40
41
|
-d|--debug Print Debug info
|
@@ -50,6 +51,7 @@ begin
|
|
50
51
|
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
51
52
|
["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
|
52
53
|
["--save", "-s", GetoptLong::REQUIRED_ARGUMENT],
|
54
|
+
["--restore", "-r", GetoptLong::REQUIRED_ARGUMENT],
|
53
55
|
["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
|
54
56
|
["--password", "-p", GetoptLong::REQUIRED_ARGUMENT]
|
55
57
|
)
|
@@ -91,7 +93,7 @@ end
|
|
91
93
|
user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, debug, false)
|
92
94
|
|
93
95
|
app = opt['app']
|
94
|
-
opt['save'] = "#{opt['app']}.tar.gz" unless opt['save']
|
96
|
+
opt['save'] = "#{opt['app']}.tar.gz" unless opt['save'] || opt['restore']
|
95
97
|
|
96
98
|
unless user_info['app_info'][app]
|
97
99
|
puts
|
@@ -104,18 +106,44 @@ end
|
|
104
106
|
app_uuid = user_info['app_info'][app]['uuid']
|
105
107
|
namespace = user_info['user_info']['namespace']
|
106
108
|
rhc_domain = user_info['user_info']['rhc_domain']
|
107
|
-
|
109
|
+
if opt['save']
|
110
|
+
ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'snapshot' > #{opt['save']}"
|
111
|
+
puts "Pulling down a snapshot to #{opt['save']}"
|
112
|
+
else
|
113
|
+
if File.exists? opt['restore']
|
114
|
+
`tar -tf #{opt['restore']} './*/#{app}'`
|
115
|
+
if $?.exitstatus != 0
|
116
|
+
puts "Archive at #{opt['restore']} does not contain the target application: ./#{app}"
|
117
|
+
exit 255
|
118
|
+
else
|
119
|
+
`tar -tf #{opt['restore']} './*/git'`
|
120
|
+
include_git = $?.exitstatus == 0
|
121
|
+
ssh_cmd = "cat #{opt['restore']} | ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
|
122
|
+
puts "Restoring from snapshot #{opt['restore']}"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
puts "Archive not found: #{opt['restore']}"
|
126
|
+
exit 255
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
108
130
|
|
109
|
-
puts "Pulling down a snapshot to #{opt['save']}"
|
110
131
|
puts
|
111
132
|
puts ssh_cmd if debug
|
112
|
-
|
133
|
+
output = `#{ssh_cmd}`
|
134
|
+
puts
|
113
135
|
if $?.exitstatus != 0
|
136
|
+
puts output
|
114
137
|
puts
|
138
|
+
if opt['save']
|
115
139
|
puts "Error in trying to save snapshot. You can try to save manually by running:"
|
140
|
+
else
|
141
|
+
puts "Error in trying to restore snapshot. You can try to restore manually by running:"
|
142
|
+
end
|
116
143
|
puts
|
117
144
|
puts ssh_cmd
|
118
145
|
puts
|
119
146
|
exit 254
|
120
147
|
end
|
148
|
+
puts output if opt['restore'] && debug
|
121
149
|
exit 0
|
data/lib/rhc-common.rb
CHANGED
@@ -34,13 +34,31 @@ require 'uri'
|
|
34
34
|
module RHC
|
35
35
|
|
36
36
|
Maxdlen = 16
|
37
|
-
Maxretries =
|
37
|
+
Maxretries = 7
|
38
38
|
Defaultdelay = 2
|
39
|
+
API = "1.1.1"
|
40
|
+
broker_version = "?.?.?"
|
41
|
+
api_version = "?.?.?"
|
42
|
+
|
43
|
+
def self.update_server_api_v(dict)
|
44
|
+
if !dict['broker'].nil? && (dict['broker'] =~ /\A\d+\.\d+\.\d+\z/)
|
45
|
+
broker_version = dict['broker']
|
46
|
+
end
|
47
|
+
if !dict['api'].nil? && (dict['api'] =~ /\A\d+\.\d+\.\d+\z/)
|
48
|
+
api_version = dict['api']
|
49
|
+
end
|
50
|
+
end
|
39
51
|
|
40
52
|
def self.delay(time, adj=Defaultdelay)
|
41
53
|
(time*=adj).to_int
|
42
54
|
end
|
43
|
-
|
55
|
+
|
56
|
+
def self.generate_json(data)
|
57
|
+
data['api'] = API
|
58
|
+
json = JSON.generate(data)
|
59
|
+
json
|
60
|
+
end
|
61
|
+
|
44
62
|
def self.get_cartridges_list(libra_server, net_http, cart_type="standalone", debug=true, print_result=nil)
|
45
63
|
puts "Contacting https://#{libra_server} to obtain list of cartridges..."
|
46
64
|
puts " (please excuse the delay)"
|
@@ -49,7 +67,7 @@ module RHC
|
|
49
67
|
data['debug'] = "true"
|
50
68
|
end
|
51
69
|
print_post_data(data, debug)
|
52
|
-
json_data =
|
70
|
+
json_data = generate_json(data)
|
53
71
|
|
54
72
|
url = URI.parse("https://#{libra_server}/broker/cartlist")
|
55
73
|
response = http_post(net_http, url, json_data, "none")
|
@@ -58,7 +76,12 @@ module RHC
|
|
58
76
|
print_response_err(response, debug)
|
59
77
|
return []
|
60
78
|
end
|
61
|
-
|
79
|
+
begin
|
80
|
+
json_resp = JSON.parse(response.body)
|
81
|
+
rescue JSON::ParserError
|
82
|
+
exit 254
|
83
|
+
end
|
84
|
+
update_server_api_v(json_resp)
|
62
85
|
if print_result
|
63
86
|
print_response_success(json_resp, debug)
|
64
87
|
end
|
@@ -143,7 +166,7 @@ module RHC
|
|
143
166
|
data['debug'] = "true"
|
144
167
|
end
|
145
168
|
print_post_data(data, debug)
|
146
|
-
json_data =
|
169
|
+
json_data = generate_json(data)
|
147
170
|
|
148
171
|
url = URI.parse("https://#{libra_server}/broker/userinfo")
|
149
172
|
response = http_post(net_http, url, json_data, password)
|
@@ -164,7 +187,12 @@ module RHC
|
|
164
187
|
end
|
165
188
|
exit 254
|
166
189
|
end
|
167
|
-
|
190
|
+
begin
|
191
|
+
json_resp = JSON.parse(response.body)
|
192
|
+
rescue JSON::ParserError
|
193
|
+
exit 254
|
194
|
+
end
|
195
|
+
update_server_api_v(json_resp)
|
168
196
|
if print_result
|
169
197
|
print_response_success(json_resp, debug)
|
170
198
|
end
|
@@ -223,15 +251,20 @@ module RHC
|
|
223
251
|
end
|
224
252
|
exit_code = 254
|
225
253
|
if response.content_type == 'application/json'
|
226
|
-
|
227
|
-
|
254
|
+
puts "JSON response:"
|
255
|
+
begin
|
256
|
+
json_resp = JSON.parse(response.body)
|
257
|
+
exit_code = print_json_body(json_resp, debug)
|
258
|
+
rescue JSON::ParserError
|
259
|
+
exit_code = 254
|
260
|
+
end
|
228
261
|
elsif debug
|
229
262
|
puts "HTTP response from server is #{response.body}"
|
230
263
|
end
|
231
264
|
exit exit_code.nil? ? 666 : exit_code
|
232
265
|
end
|
233
|
-
|
234
|
-
def self.print_response_messages(json_resp)
|
266
|
+
|
267
|
+
def self.print_response_messages(json_resp)
|
235
268
|
messages = json_resp['messages']
|
236
269
|
if (messages && !messages.empty?)
|
237
270
|
puts ''
|
@@ -271,6 +304,12 @@ module RHC
|
|
271
304
|
end
|
272
305
|
end
|
273
306
|
end
|
307
|
+
if json_resp['api']
|
308
|
+
puts "API version: #{json_resp['api']}"
|
309
|
+
end
|
310
|
+
if json_resp['broker']
|
311
|
+
puts "Broker version: #{json_resp['broker']}"
|
312
|
+
end
|
274
313
|
if json_resp['result']
|
275
314
|
puts ''
|
276
315
|
puts 'RESULT:'
|
@@ -308,7 +347,7 @@ if !File.exists? local_config_path
|
|
308
347
|
FileUtils.touch local_config_path
|
309
348
|
puts ""
|
310
349
|
puts "Created local config file: " + local_config_path
|
311
|
-
puts "express.conf contains user configuration and can be transferred across clients."
|
350
|
+
puts "express.conf contains user configuration and can be transferred across clients."
|
312
351
|
puts ""
|
313
352
|
end
|
314
353
|
|
@@ -331,7 +370,7 @@ else
|
|
331
370
|
end
|
332
371
|
|
333
372
|
#
|
334
|
-
# Check for local var in
|
373
|
+
# Check for local var in
|
335
374
|
# 1) ~/.openshift/express.conf
|
336
375
|
# 2) /etc/openshift/express.conf
|
337
376
|
# 3) $GEM/../conf/express.conf
|
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: 289
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 75
|
9
|
+
- 9
|
10
|
+
version: 0.75.9
|
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-08-
|
18
|
+
date: 2011-08-22 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
|
62
62
|
files:
|
63
63
|
- lib/rhc-common.rb
|
64
|
+
- bin/rhc-chk
|
64
65
|
- bin/rhc-create-domain
|
65
66
|
- bin/rhc-tail-files
|
66
67
|
- bin/rhc-create-app
|