rhc 0.71.2 → 0.72.29
Sign up to get free protection for your applications and to get access to all the features.
- data/README +33 -5
- data/Rakefile +1 -1
- data/bin/rhc-create-app +24 -29
- data/bin/rhc-create-domain +41 -11
- data/bin/rhc-ctl-app +3 -3
- data/bin/rhc-snapshot +12 -9
- data/bin/rhc-tail-files +11 -9
- data/bin/rhc-user-info +4 -34
- data/lib/rhc-common.rb +45 -42
- metadata +5 -5
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
OpenShift Express (RHC)
|
2
2
|
========
|
3
3
|
|
4
4
|
Please stop by #openshift on irc.freenode.net if you have any questions or
|
@@ -13,16 +13,16 @@ DEPENDENCIES: git
|
|
13
13
|
openssh-clients
|
14
14
|
ruby (1.8.7 or later)
|
15
15
|
rubygems
|
16
|
-
json
|
16
|
+
json_pure gem (native json is fine too)
|
17
17
|
parseconfig gem
|
18
18
|
|
19
19
|
Step 1: Create an rhc domain:
|
20
20
|
|
21
|
-
$
|
21
|
+
$ rhc-create-domain -n desirednamespace -l rhlogin
|
22
22
|
|
23
23
|
Step 2: Create an rhc application:
|
24
24
|
|
25
|
-
$
|
25
|
+
$ rhc-create-app -l rhlogin -a appname -r /path/to/new/git/repo -t <framework Ex: php-5.3>
|
26
26
|
|
27
27
|
Once that's complete, follow the directions printed at the end of running
|
28
28
|
rhc-create-app
|
@@ -38,4 +38,32 @@ $ edit index.php
|
|
38
38
|
$ git commit -a -m "what I did"
|
39
39
|
$ git push
|
40
40
|
|
41
|
-
Then just reload your web page to see the changes
|
41
|
+
Then just reload your web page to see the changes
|
42
|
+
|
43
|
+
-----------
|
44
|
+
OS X Notes:
|
45
|
+
-----------
|
46
|
+
|
47
|
+
git:
|
48
|
+
OS X 10.6 comes w/ ssh and ruby, but not with git, unless you have
|
49
|
+
Xcode 4.0.x installed (as a developer you should have Xcode anyway).
|
50
|
+
Xcode, however, is not free (unless you are a registered Apple
|
51
|
+
Developer) and costs around $5 from the Apple App Store.
|
52
|
+
|
53
|
+
If you do not have Xcode, you can obtain a pre-packaged version
|
54
|
+
of git from:
|
55
|
+
|
56
|
+
http://code.google.com/p/git-osx-installer/
|
57
|
+
|
58
|
+
Installing git from MacPorts/HomeBrew/Fink/etc requires Xcode.
|
59
|
+
|
60
|
+
Now obtain the client code, either via 'git clone' as above
|
61
|
+
or via the rhc gem.
|
62
|
+
|
63
|
+
json_pure gem:
|
64
|
+
The client tools also make use of JSON as the data set for
|
65
|
+
I/O, and therefore needs the json ruby gem. Unless you have
|
66
|
+
Xcode installed, you will need to install json_pure, which
|
67
|
+
is the 100% ruby version of the JSON gem. If you have Xcode,
|
68
|
+
you can elect to install either json_pure or the native
|
69
|
+
json gem.
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ task :default => [:package]
|
|
10
10
|
# Create the gem specification for packaging
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.name = %q{rhc}
|
13
|
-
s.version = /(Version: )(.*)/.match(File.read("
|
13
|
+
s.version = /(Version: )(.*)/.match(File.read("client.spec"))[2]
|
14
14
|
s.author = "Red Hat"
|
15
15
|
s.email = %q{openshift@redhat.com}
|
16
16
|
s.summary = %q{OpenShift Express Client Tools}
|
data/bin/rhc-create-app
CHANGED
@@ -24,16 +24,17 @@
|
|
24
24
|
require 'rhc-common'
|
25
25
|
|
26
26
|
def p_usage
|
27
|
-
|
28
|
-
|
27
|
+
libra_server = get_var('libra_server')
|
28
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
29
|
+
type_keys = RHC::get_cartridge_list(nil, ', ', libra_server, @http, false)
|
29
30
|
puts <<USAGE
|
30
31
|
|
31
32
|
Usage: #{$0}
|
32
|
-
Create an
|
33
|
+
Create an OpenShift Express app.
|
33
34
|
|
34
35
|
-a|--app application Application name (alphanumeric - max #{RHC::Maxdlen} chars) (required)
|
35
36
|
-t|--type type Type of app to create (#{type_keys}) (required)
|
36
|
-
-l|--rhlogin rhlogin
|
37
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
37
38
|
-p|--password password RHLogin password (optional, will prompt)
|
38
39
|
-r|--repo path Git Repo path (defaults to ./$app_name)
|
39
40
|
-n|--nogit Only create remote space, don't pull it locally
|
@@ -89,8 +90,9 @@ if !RHC::check_app(opt['app'])
|
|
89
90
|
p_usage
|
90
91
|
end
|
91
92
|
|
92
|
-
type = RHC::
|
93
|
+
type = RHC::get_cartridge_type(opt['type'])
|
93
94
|
if !type
|
95
|
+
puts 'Type is required'
|
94
96
|
p_usage
|
95
97
|
end
|
96
98
|
|
@@ -103,16 +105,6 @@ if !password
|
|
103
105
|
password = RHC::get_password
|
104
106
|
end
|
105
107
|
|
106
|
-
#
|
107
|
-
# Get UUID from file
|
108
|
-
#
|
109
|
-
|
110
|
-
uuid = get_var(opt["rhlogin"])
|
111
|
-
unless uuid
|
112
|
-
puts "Could not find UUID for '#{opt["rhlogin"]}' in express.conf. Be sure you have successfully ran rhc-create-domain before running rhc-create-app."
|
113
|
-
exit 99
|
114
|
-
end
|
115
|
-
|
116
108
|
opt["repo"] = opt["app"] unless opt["repo"]
|
117
109
|
|
118
110
|
puts "
|
@@ -165,7 +157,7 @@ end
|
|
165
157
|
# Create remote application space
|
166
158
|
#
|
167
159
|
|
168
|
-
puts "
|
160
|
+
puts "Attempting to create remote application space: " + opt['app']
|
169
161
|
|
170
162
|
data = {:cartridge => opt['type'],
|
171
163
|
:action => 'configure',
|
@@ -179,7 +171,7 @@ json_data = JSON.generate(data)
|
|
179
171
|
|
180
172
|
puts "Contacting https://#{libra_server}"
|
181
173
|
|
182
|
-
url = URI.parse("https://#{libra_server}/
|
174
|
+
url = URI.parse("https://#{libra_server}/broker/cartridge")
|
183
175
|
response = RHC::http_post(@http, url, json_data, password)
|
184
176
|
|
185
177
|
if response.code == '200'
|
@@ -198,11 +190,10 @@ at_exit do
|
|
198
190
|
{:cartridge => opt['type'],
|
199
191
|
:action => 'deconfigure',
|
200
192
|
:app_name => opt['app'],
|
201
|
-
:rhlogin => opt['rhlogin']
|
202
|
-
:password => password
|
193
|
+
:rhlogin => opt['rhlogin']
|
203
194
|
})
|
204
195
|
puts "Cleaning up application"
|
205
|
-
url = URI.parse("https://#{libra_server}/
|
196
|
+
url = URI.parse("https://#{libra_server}/broker/cartridge")
|
206
197
|
RHC::http_post(@http, url, json_data, password)
|
207
198
|
end
|
208
199
|
end
|
@@ -215,7 +206,7 @@ puts "Checking ~/.ssh/config"
|
|
215
206
|
|
216
207
|
user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, debug, false)
|
217
208
|
|
218
|
-
|
209
|
+
fqdn = "#{opt['app']}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}"
|
219
210
|
|
220
211
|
found = false
|
221
212
|
|
@@ -287,10 +278,10 @@ sleep 15
|
|
287
278
|
# Now start checking for DNS
|
288
279
|
loop = 0
|
289
280
|
sleep_time = 2
|
290
|
-
while loop < RHC::Maxretries && !RHC::hostexist?(
|
281
|
+
while loop < RHC::Maxretries && !RHC::hostexist?(fqdn)
|
291
282
|
sleep sleep_time
|
292
283
|
loop+=1
|
293
|
-
puts " retry # #{loop} - Waiting for DNS: #{
|
284
|
+
puts " retry # #{loop} - Waiting for DNS: #{fqdn}"
|
294
285
|
sleep_time = RHC::delay(sleep_time)
|
295
286
|
end
|
296
287
|
|
@@ -305,7 +296,12 @@ attempt = 0
|
|
305
296
|
# Pull new repo locally
|
306
297
|
#
|
307
298
|
|
308
|
-
|
299
|
+
app_name = opt['app']
|
300
|
+
namespace = user_info['user_info']['namespace']
|
301
|
+
rhc_domain = user_info['user_info']['rhc_domain']
|
302
|
+
app_uuid = user_info['app_info'][app_name]['uuid']
|
303
|
+
|
304
|
+
git_url = "ssh://#{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain}/~/git/#{app_name}.git/"
|
309
305
|
|
310
306
|
unless opt['nogit']
|
311
307
|
puts "Pulling new repo down"
|
@@ -352,11 +348,10 @@ while attempt < RHC::Maxretries
|
|
352
348
|
page = 'health'
|
353
349
|
if (type == :php)
|
354
350
|
page = 'health_check.php'
|
355
|
-
|
356
|
-
if (type == :perl)
|
351
|
+
elsif (type == :perl)
|
357
352
|
page = 'health_check.pl'
|
358
353
|
end
|
359
|
-
url = URI.parse("http://#{
|
354
|
+
url = URI.parse("http://#{fqdn}/#{page}")
|
360
355
|
begin
|
361
356
|
response = @http.get_response(url)
|
362
357
|
rescue Exception => e
|
@@ -367,14 +362,14 @@ while attempt < RHC::Maxretries
|
|
367
362
|
|
368
363
|
Success! Your application is now published here:
|
369
364
|
|
370
|
-
http://#{
|
365
|
+
http://#{fqdn}/
|
371
366
|
|
372
367
|
The remote repository is located here:
|
373
368
|
|
374
369
|
#{git_url}
|
375
370
|
|
376
371
|
To make changes to your application, commit to #{opt['repo']}/.
|
377
|
-
Then run 'git push' to update your
|
372
|
+
Then run 'git push' to update your OpenShift Express space
|
378
373
|
|
379
374
|
LOOKSGOOD
|
380
375
|
exit 0
|
data/bin/rhc-create-domain
CHANGED
@@ -35,8 +35,8 @@ Bind a registered rhcloud user to a domain in rhcloud.
|
|
35
35
|
NOTE: to change ssh key, please alter your ~/.ssh/libra_id_rsa and
|
36
36
|
~/.ssh/libra_id_rsa.pub key, then re-run with --alter
|
37
37
|
|
38
|
-
-n|--namespace namespace
|
39
|
-
-l|--rhlogin rhlogin Red Hat login (required)
|
38
|
+
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::Maxdlen} chars) (required)
|
39
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (required)
|
40
40
|
-p|--password password RHLogin password (optional, will prompt)
|
41
41
|
-a|--alter Alter namespace (will change urls) and/or ssh key
|
42
42
|
-d|--debug Print Debug info
|
@@ -110,10 +110,6 @@ def add_rhlogin_config(rhlogin, uuid)
|
|
110
110
|
f.puts("default_rhlogin=#{rhlogin}")
|
111
111
|
f.puts("")
|
112
112
|
end
|
113
|
-
unless @local_config.get_value(rhlogin)
|
114
|
-
puts "Adding rhlogin to #{@local_config_path}"
|
115
|
-
f.puts("#{rhlogin}=#{uuid}")
|
116
|
-
end
|
117
113
|
f.close
|
118
114
|
end
|
119
115
|
|
@@ -123,9 +119,9 @@ end
|
|
123
119
|
#
|
124
120
|
|
125
121
|
if File.readable?(libra_kfile)
|
126
|
-
puts "
|
122
|
+
puts "OpenShift Express key found at #{libra_kfile}. Reusing..."
|
127
123
|
else
|
128
|
-
puts "Generating
|
124
|
+
puts "Generating OpenShift Express ssh key to #{libra_kfile}"
|
129
125
|
# Use system for interaction
|
130
126
|
system("ssh-keygen -t rsa -f '#{libra_kfile}'")
|
131
127
|
end
|
@@ -138,6 +134,8 @@ data = {'namespace' => opt['namespace'],
|
|
138
134
|
'ssh' => ssh_key}
|
139
135
|
if (opt['alter'])
|
140
136
|
data['alter'] = "true"
|
137
|
+
not_found_message = "A user with rhlogin '#{opt['rhlogin']}' does not have a registered domain. Be sure to run rhc-create-domain without -a|--alter first."
|
138
|
+
user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, debug, true, not_found_message)
|
141
139
|
end
|
142
140
|
if debug
|
143
141
|
data['debug'] = "true"
|
@@ -145,7 +143,7 @@ end
|
|
145
143
|
RHC::print_post_data(data, debug)
|
146
144
|
json_data = JSON.generate(data)
|
147
145
|
|
148
|
-
url = URI.parse("https://#{libra_server}/
|
146
|
+
url = URI.parse("https://#{libra_server}/broker/domain")
|
149
147
|
response = RHC::http_post(@http, url, json_data, password)
|
150
148
|
|
151
149
|
if response.code == '200'
|
@@ -164,8 +162,40 @@ in #{@local_config_path} which has been created and populated for you.
|
|
164
162
|
|
165
163
|
EOF
|
166
164
|
else
|
167
|
-
|
168
|
-
|
165
|
+
app_info = user_info['app_info']
|
166
|
+
dns_success = true
|
167
|
+
if !app_info.empty? && opt['namespace'] != user_info['user_info']['namespace']
|
168
|
+
#
|
169
|
+
# Confirm that the host(s) exist in DNS
|
170
|
+
#
|
171
|
+
puts "Now your new domain name(s) are being populated worldwide (this might take a minute)..."
|
172
|
+
# Allow DNS to propogate
|
173
|
+
sleep 15
|
174
|
+
app_info.each_key do |appname|
|
175
|
+
fqdn = "#{appname}-#{opt['namespace']}.#{user_info['user_info']['rhc_domain']}"
|
176
|
+
|
177
|
+
# Now start checking for DNS
|
178
|
+
loop = 0
|
179
|
+
sleep_time = 2
|
180
|
+
while loop < RHC::Maxretries && !RHC::hostexist?(fqdn)
|
181
|
+
sleep sleep_time
|
182
|
+
loop+=1
|
183
|
+
puts " retry # #{loop} - Waiting for DNS: #{fqdn}"
|
184
|
+
sleep_time = RHC::delay(sleep_time)
|
185
|
+
end
|
186
|
+
|
187
|
+
if loop >= RHC::Maxretries
|
188
|
+
puts "Host could not be found: #{fqdn}"
|
189
|
+
dns_success = false
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
if dns_success
|
194
|
+
puts "Alteration successful. You can use rhc-user-info to view any url changes."
|
195
|
+
else
|
196
|
+
puts "Alteration successful but at least one of the urls is still updating in DNS. You can use rhc-user-info to view any url changes."
|
197
|
+
end
|
198
|
+
puts ""
|
169
199
|
end
|
170
200
|
exit 0
|
171
201
|
rescue JSON::ParserError
|
data/bin/rhc-ctl-app
CHANGED
@@ -24,14 +24,14 @@
|
|
24
24
|
require 'rhc-common'
|
25
25
|
|
26
26
|
def p_usage
|
27
|
-
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "
|
27
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
28
28
|
puts <<USAGE
|
29
29
|
|
30
30
|
Usage: #{$0}
|
31
31
|
Control an OpenShift express app
|
32
32
|
|
33
33
|
-a|--app application Application name (alphanumeric) (required)
|
34
|
-
-l|--rhlogin rhlogin Red Hat login (#{rhlogin})
|
34
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
35
35
|
-p|--password password RHLogin password (optional, will prompt)
|
36
36
|
-c|--command command (start|stop|restart|reload|status|destroy)
|
37
37
|
-b|--bypass Bypass warnings
|
@@ -146,7 +146,7 @@ json_data = JSON.generate(data)
|
|
146
146
|
|
147
147
|
puts "Contacting https://#{libra_server}"
|
148
148
|
|
149
|
-
url = URI.parse("https://#{libra_server}/
|
149
|
+
url = URI.parse("https://#{libra_server}/broker/cartridge")
|
150
150
|
response = RHC::http_post(@http, url, json_data, password)
|
151
151
|
|
152
152
|
if response.code == '200'
|
data/bin/rhc-snapshot
CHANGED
@@ -27,13 +27,13 @@ require 'rhc-common'
|
|
27
27
|
# print help
|
28
28
|
#
|
29
29
|
def p_usage
|
30
|
-
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "
|
30
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
31
31
|
puts <<USAGE
|
32
32
|
|
33
33
|
Usage: #{$0}
|
34
34
|
Pull down application snapshot for a user
|
35
35
|
|
36
|
-
-l|--rhlogin rhlogin
|
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
38
|
-s|--save Local path to save tarball (default: ./$APPNAME.tar.gz)
|
39
39
|
-p|--password password RHLogin password (optional, will prompt)
|
@@ -93,25 +93,28 @@ user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, de
|
|
93
93
|
app = opt['app']
|
94
94
|
opt['save'] = "#{opt['app']}.tar.gz" unless opt['save']
|
95
95
|
|
96
|
-
|
97
|
-
framework = user_info['app_info'][app]['framework'].split('-')[0]
|
98
|
-
rescue NoMethodError
|
96
|
+
unless user_info['app_info'][app]
|
99
97
|
puts
|
100
|
-
puts "Could not find app '#{
|
98
|
+
puts "Could not find app '#{app}'. Please run rhc-user-info to get a list"
|
101
99
|
puts "of your current running applications"
|
102
100
|
puts
|
103
101
|
exit 101
|
104
102
|
end
|
105
103
|
|
104
|
+
app_uuid = user_info['app_info'][app]['uuid']
|
105
|
+
namespace = user_info['user_info']['namespace']
|
106
|
+
rhc_domain = user_info['user_info']['rhc_domain']
|
107
|
+
ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'snapshot #{app}' > #{opt['save']}"
|
108
|
+
|
106
109
|
puts "Pulling down a snapshot to #{opt['save']}"
|
107
110
|
puts
|
108
|
-
puts
|
109
|
-
git_pull =
|
111
|
+
puts ssh_cmd if debug
|
112
|
+
git_pull = `#{ssh_cmd}`
|
110
113
|
if $?.exitstatus != 0
|
111
114
|
puts
|
112
115
|
puts "Error in trying to save snapshot. You can try to save manually by running:"
|
113
116
|
puts
|
114
|
-
puts
|
117
|
+
puts ssh_cmd
|
115
118
|
puts
|
116
119
|
exit 254
|
117
120
|
end
|
data/bin/rhc-tail-files
CHANGED
@@ -27,13 +27,13 @@ require 'rhc-common'
|
|
27
27
|
# print help
|
28
28
|
#
|
29
29
|
def p_usage
|
30
|
-
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "
|
30
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
31
31
|
puts <<USAGE
|
32
32
|
|
33
33
|
Usage: #{$0}
|
34
34
|
Tail the logs of an application
|
35
35
|
|
36
|
-
-l|--rhlogin rhlogin
|
36
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
37
37
|
-a|--app Target application (required)
|
38
38
|
-f|--files File glob relative to app (default ./logs/*) (optional)
|
39
39
|
-p|--password password RHLogin password (optional, will prompt)
|
@@ -92,9 +92,7 @@ user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, de
|
|
92
92
|
|
93
93
|
app = opt['app']
|
94
94
|
|
95
|
-
|
96
|
-
framework = user_info['app_info'][app]['framework'].split('-')[0]
|
97
|
-
rescue NoMethodError
|
95
|
+
unless user_info['app_info'][app]
|
98
96
|
puts
|
99
97
|
puts "Could not find app '#{opt['app']}'. Please run rhc-user-info to get a list"
|
100
98
|
puts "of your current running applications"
|
@@ -103,18 +101,22 @@ rescue NoMethodError
|
|
103
101
|
end
|
104
102
|
|
105
103
|
opt['files'] = "logs/*" unless opt['files']
|
106
|
-
file_glob = "#{
|
104
|
+
file_glob = "#{opt['app']}/#{opt['files']}"
|
105
|
+
app_uuid = user_info['app_info'][app]['uuid']
|
106
|
+
namespace = user_info['user_info']['namespace']
|
107
|
+
rhc_domain = user_info['user_info']['rhc_domain']
|
108
|
+
ssh_cmd = "ssh #{app_uuid}@#{app}-#{namespace}.#{rhc_domain} 'tail #{file_glob}'"
|
107
109
|
|
108
110
|
puts "Attempting to tail files: #{file_glob}"
|
109
111
|
puts "Use ctl + c to stop"
|
110
112
|
puts
|
111
|
-
puts
|
112
|
-
system(
|
113
|
+
puts ssh_cmd if debug
|
114
|
+
system(ssh_cmd)
|
113
115
|
if $?.exitstatus != 0 and $?.exitstatus != 255
|
114
116
|
puts
|
115
117
|
puts "Error in trying to tail files. You can tail manually by running:"
|
116
118
|
puts
|
117
|
-
puts
|
119
|
+
puts ssh_cmd
|
118
120
|
puts
|
119
121
|
exit 254
|
120
122
|
end
|
data/bin/rhc-user-info
CHANGED
@@ -21,27 +21,19 @@
|
|
21
21
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
22
|
# SOFTWARE.
|
23
23
|
|
24
|
-
require "rubygems"
|
25
|
-
require "uri"
|
26
|
-
require "net/http"
|
27
|
-
require "net/https"
|
28
|
-
require "getoptlong"
|
29
|
-
require "json"
|
30
|
-
require 'parseconfig'
|
31
|
-
require 'fileutils'
|
32
24
|
require 'rhc-common'
|
33
25
|
|
34
26
|
#
|
35
27
|
# print help
|
36
28
|
#
|
37
29
|
def p_usage
|
38
|
-
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "
|
30
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
39
31
|
puts <<USAGE
|
40
32
|
|
41
33
|
Usage: #{$0}
|
42
34
|
Display information about a user
|
43
35
|
|
44
|
-
-l|--rhlogin rhlogin
|
36
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
45
37
|
-p|--password password RHLogin password (optional, will prompt)
|
46
38
|
-a|--apps List applications for rhlogin
|
47
39
|
-i|--info Show user info
|
@@ -52,18 +44,6 @@ USAGE
|
|
52
44
|
exit 255
|
53
45
|
end
|
54
46
|
|
55
|
-
def validate_email(email)
|
56
|
-
if email =~ /([^@]+)@([a-zA-Z0-9\.])+\.([a-zA-Z]{2,3})/
|
57
|
-
if $1 =~ /[^a-zA-Z0-9\.]/
|
58
|
-
return false
|
59
|
-
else
|
60
|
-
return true
|
61
|
-
end
|
62
|
-
else
|
63
|
-
return false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
47
|
begin
|
68
48
|
opts = GetoptLong.new(
|
69
49
|
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
@@ -111,17 +91,6 @@ end
|
|
111
91
|
opt['apps'] = true if not opt['info'] and not opt['apps']
|
112
92
|
user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, @http, debug, true)
|
113
93
|
|
114
|
-
if user_info['user_info']['uuid'] != get_var(opt["rhlogin"])
|
115
|
-
puts "!! WARNING !! WARNING !! WARNING !! WARNING !!"
|
116
|
-
puts
|
117
|
-
puts "The UUID in your #{@conf_name} file is either missing or incorrect."
|
118
|
-
puts "Please ensure the below line exists in #{@local_config_path}"
|
119
|
-
puts
|
120
|
-
puts "#{opt['rhlogin']}=#{user_info['user_info']['uuid']}"
|
121
|
-
puts
|
122
|
-
puts "!! WARNING !! WARNING !! WARNING !! WARNING !!"
|
123
|
-
end
|
124
|
-
|
125
94
|
if opt['info']
|
126
95
|
puts "User Info"
|
127
96
|
puts "========="
|
@@ -140,7 +109,8 @@ if opt['apps']
|
|
140
109
|
puts key
|
141
110
|
puts " Framework: #{val['framework']}"
|
142
111
|
puts " Creation: #{val['creation_time']}"
|
143
|
-
puts "
|
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/"
|
144
114
|
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
145
115
|
puts ""
|
146
116
|
end
|
data/lib/rhc-common.rb
CHANGED
@@ -37,41 +37,53 @@ module RHC
|
|
37
37
|
Maxretries = 10
|
38
38
|
Defaultdelay = 2
|
39
39
|
|
40
|
-
TYPES = {
|
41
|
-
'php-5.3.2' => :php,
|
42
|
-
'perl-5.10.1' => :perl,
|
43
|
-
'rack-1.1.0' => :rack,
|
44
|
-
'wsgi-3.2.1' => :wsgi,
|
45
|
-
'jbossas-7.0.0' => :jbossas
|
46
|
-
}
|
47
|
-
|
48
|
-
SUPPORTED_TYPES = {
|
49
|
-
'php-5.3.2' => :php,
|
50
|
-
'rack-1.1.0' => :rack,
|
51
|
-
'wsgi-3.2.1' => :wsgi
|
52
|
-
}
|
53
|
-
|
54
40
|
def self.delay(time, adj=Defaultdelay)
|
55
41
|
(time*=adj).to_int
|
56
42
|
end
|
57
43
|
|
58
|
-
def self.
|
59
|
-
|
44
|
+
def self.get_cartridges_tbl(libra_server, net_http, debug=true, print_result=nil)
|
45
|
+
puts "Contacting https://#{libra_server} to obtain list of cartridges..."
|
46
|
+
puts " (please excuse the delay)"
|
47
|
+
data = {'cart_types' => "standalone"}
|
48
|
+
if debug
|
49
|
+
data['debug'] = "true"
|
50
|
+
end
|
51
|
+
print_post_data(data, debug)
|
52
|
+
json_data = JSON.generate(data)
|
53
|
+
|
54
|
+
url = URI.parse("https://#{libra_server}/broker/cartlist")
|
55
|
+
response = http_post(net_http, url, json_data, "none")
|
56
|
+
|
57
|
+
unless response.code == '200'
|
58
|
+
print_response_err(response, debug)
|
59
|
+
return []
|
60
|
+
end
|
61
|
+
if print_result
|
62
|
+
print_response_success(response, debug)
|
63
|
+
end
|
64
|
+
begin
|
65
|
+
json_resp = JSON.parse(response.body)
|
66
|
+
carts = (JSON.parse(json_resp['result']))['carts']
|
67
|
+
rescue JSON::ParserError
|
68
|
+
exit 254
|
69
|
+
end
|
70
|
+
carts
|
60
71
|
end
|
61
72
|
|
62
|
-
def self.
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
73
|
+
def self.get_cartridge_list(carts, sep, libra_server, net_http, debug=true, print_result=nil)
|
74
|
+
carts = get_cartridges_tbl(libra_server, net_http, debug, print_result) if carts.nil?
|
75
|
+
carts.join(sep)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.get_cartridge_type(type)
|
79
|
+
if type
|
80
|
+
type = type.split('-')[0]
|
81
|
+
return type.to_sym
|
71
82
|
end
|
72
|
-
|
83
|
+
nil
|
73
84
|
end
|
74
85
|
|
86
|
+
|
75
87
|
# Invalid chars (") ($) (^) (<) (>) (|) (%) (/) (;) (:) (,) (\) (*) (=) (~)
|
76
88
|
def self.check_rhlogin(rhlogin)
|
77
89
|
if rhlogin
|
@@ -114,19 +126,6 @@ module RHC
|
|
114
126
|
true
|
115
127
|
end
|
116
128
|
|
117
|
-
def self.get_cartridge(type)
|
118
|
-
if type
|
119
|
-
if !(RHC::TYPES.has_key?(type))
|
120
|
-
puts 'type must be ' << get_supported_cartridge_types(' or ')
|
121
|
-
else
|
122
|
-
return RHC::TYPES[type]
|
123
|
-
end
|
124
|
-
else
|
125
|
-
puts "Type is required"
|
126
|
-
end
|
127
|
-
nil
|
128
|
-
end
|
129
|
-
|
130
129
|
def self.print_post_data(h, debug)
|
131
130
|
if (debug)
|
132
131
|
puts 'DEBUG: Submitting form:'
|
@@ -144,7 +143,7 @@ module RHC
|
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
147
|
-
def self.get_user_info(libra_server, rhlogin, password, net_http, debug, print_result)
|
146
|
+
def self.get_user_info(libra_server, rhlogin, password, net_http, debug, print_result, not_found_message=nil)
|
148
147
|
|
149
148
|
puts "Contacting https://#{libra_server}"
|
150
149
|
data = {'rhlogin' => rhlogin}
|
@@ -154,12 +153,16 @@ module RHC
|
|
154
153
|
print_post_data(data, debug)
|
155
154
|
json_data = JSON.generate(data)
|
156
155
|
|
157
|
-
url = URI.parse("https://#{libra_server}/
|
156
|
+
url = URI.parse("https://#{libra_server}/broker/userinfo")
|
158
157
|
response = http_post(net_http, url, json_data, password)
|
159
158
|
|
160
159
|
unless response.code == '200'
|
161
160
|
if response.code == '404'
|
162
|
-
|
161
|
+
if not_found_message
|
162
|
+
puts not_found_message
|
163
|
+
else
|
164
|
+
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."
|
165
|
+
end
|
163
166
|
exit 99
|
164
167
|
elsif response.code == '401'
|
165
168
|
puts "Invalid user credentials"
|
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: 261
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 72
|
9
|
+
- 29
|
10
|
+
version: 0.72.29
|
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-06-27 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|