rhc 0.84.15 → 0.85.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -3
- data/bin/rhc +70 -0
- data/bin/rhc-app +602 -0
- data/bin/rhc-chk +5 -5
- data/bin/rhc-create-app +1 -1
- data/bin/rhc-create-domain +6 -6
- data/bin/rhc-ctl-app +1 -1
- data/bin/rhc-ctl-domain +4 -4
- data/bin/rhc-domain +348 -0
- data/bin/rhc-domain-info +4 -4
- data/bin/rhc-port-forward +146 -0
- data/bin/rhc-snapshot +2 -2
- data/bin/rhc-sshkey +258 -0
- data/bin/rhc-tail-files +2 -2
- data/bin/rhc-user-info +4 -0
- data/lib/rhc +135 -0
- data/lib/rhc-common.rb +96 -9
- metadata +22 -11
data/bin/rhc-chk
CHANGED
@@ -44,7 +44,7 @@ def p_usage
|
|
44
44
|
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
45
45
|
puts <<USAGE
|
46
46
|
|
47
|
-
Usage:
|
47
|
+
Usage: rhc domain status
|
48
48
|
Run a simple check on local configs and credentials to confirm tools are
|
49
49
|
properly setup. Often run to troubleshoot connection issues.
|
50
50
|
|
@@ -77,7 +77,7 @@ rescue Exception => e
|
|
77
77
|
p_usage
|
78
78
|
end
|
79
79
|
|
80
|
-
if $opt["help"]
|
80
|
+
if $opt["help"] || 0 != ARGV.length
|
81
81
|
p_usage
|
82
82
|
end
|
83
83
|
|
@@ -293,8 +293,8 @@ class Test3_SSH < Test::Unit::TestCase
|
|
293
293
|
|
294
294
|
$remote_ssh_pubkeys = []
|
295
295
|
additional_ssh_keys = RHC::get_ssh_keys($libra_server, $rhlogin, $password, $http)
|
296
|
-
if additional_ssh_keys && additional_ssh_keys.kind_of?(Hash)
|
297
|
-
additional_ssh_keys.each do |name, sshkey|
|
296
|
+
if additional_ssh_keys['keys'] && additional_ssh_keys['keys'].kind_of?(Hash)
|
297
|
+
additional_ssh_keys['keys'].each do |name, sshkey|
|
298
298
|
$remote_ssh_pubkeys.push(sshkey['key'])
|
299
299
|
end
|
300
300
|
end
|
@@ -455,7 +455,7 @@ $messages = YAML.load <<-EOF
|
|
455
455
|
:no_connectivity: "Cannot connect to server, therefore most tests will not work\n FIX: Ensure that you are able to connect to %s"
|
456
456
|
:no_account: You must have an account on the server in order to test SSH key matches
|
457
457
|
:cant_connect: You need to be able to connect to the server in order to test authentication
|
458
|
-
:no_match_pub: "Local %s does not match remote pub key, SSH auth will not work\n FIX: Perhaps you should regenerate your public key, or run rhc
|
458
|
+
:no_match_pub: "Local %s does not match remote pub key, SSH auth will not work\n FIX: Perhaps you should regenerate your public key, or run 'rhc sshkey add' to add your new key"
|
459
459
|
:_404: "The user %s does not have an account on this server\n FIX: Please ensure that you've entered the correct username"
|
460
460
|
:no_pubkey: We were unable to read your public SSH key to compare to %s
|
461
461
|
:_401: "Invalid user credentials for %s\n FIX: Please ensure you used the correct password"
|
data/bin/rhc-create-app
CHANGED
data/bin/rhc-create-domain
CHANGED
@@ -27,7 +27,7 @@ require 'rhc-common'
|
|
27
27
|
# print help
|
28
28
|
#
|
29
29
|
def p_usage
|
30
|
-
|
30
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
31
31
|
puts <<USAGE
|
32
32
|
|
33
33
|
Usage: #{$0}
|
@@ -37,14 +37,14 @@ Bind a registered rhcloud user to a domain in rhcloud.
|
|
37
37
|
<id_rsa>.pub keys, then re-run with --alter
|
38
38
|
|
39
39
|
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required)
|
40
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (
|
40
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
41
41
|
-p|--password password RHLogin password (optional, will prompt)
|
42
42
|
-a|--alter Alter namespace (will change urls) and/or ssh key
|
43
43
|
-d|--debug Print Debug info
|
44
44
|
-h|--help Show Usage info
|
45
45
|
--config path Path of alternate config file
|
46
46
|
--timeout # Timeout, in seconds, for connection
|
47
|
-
|
47
|
+
|
48
48
|
USAGE
|
49
49
|
exit 255
|
50
50
|
end
|
@@ -76,7 +76,7 @@ check_cpath(opt)
|
|
76
76
|
# Pull in configs from files
|
77
77
|
libra_server = get_var('libra_server')
|
78
78
|
debug = get_var('debug') == 'false' ? nil : get_var('debug')
|
79
|
-
|
79
|
+
opt['rhlogin'] = get_var('default_rhlogin') unless opt['rhlogin']
|
80
80
|
|
81
81
|
ssh_key_file_path = get_kfile(false)
|
82
82
|
ssh_pub_key_file_path = get_kpfile(ssh_key_file_path, opt['alter'])
|
@@ -84,7 +84,7 @@ ssh_pub_key_file_path = get_kpfile(ssh_key_file_path, opt['alter'])
|
|
84
84
|
ssh_config = "#{ENV['HOME']}/.ssh/config"
|
85
85
|
ssh_config_d = "#{ENV['HOME']}/.ssh/"
|
86
86
|
|
87
|
-
if opt["help"]
|
87
|
+
if opt["help"] || 0 != ARGV.length
|
88
88
|
p_usage
|
89
89
|
end
|
90
90
|
|
@@ -282,7 +282,7 @@ EOF
|
|
282
282
|
dns_success = false
|
283
283
|
end
|
284
284
|
end
|
285
|
-
puts "You can use rhc-
|
285
|
+
puts "You can use rhc-domain-info to view any url changes. Be sure to update any links"
|
286
286
|
puts "including the url in your local git config: <local_git_repo>/.git/config"
|
287
287
|
end
|
288
288
|
if dns_success
|
data/bin/rhc-ctl-app
CHANGED
data/bin/rhc-ctl-domain
CHANGED
@@ -27,15 +27,15 @@ require 'rhc-common'
|
|
27
27
|
# print help
|
28
28
|
#
|
29
29
|
def p_usage
|
30
|
-
|
30
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
31
31
|
puts <<USAGE
|
32
32
|
|
33
33
|
Usage: #{$0}
|
34
34
|
Manage multiple keys for the registered rhcloud user.
|
35
35
|
|
36
|
-
rhc-ctl-domain -l
|
36
|
+
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)
|
37
37
|
|
38
|
-
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (
|
38
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
39
39
|
-p|--password password RHLogin password (optional, will prompt)
|
40
40
|
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required for destroying domain)
|
41
41
|
-a|--add-ssh-key key-name Add SSH key to the user account (key-name is the user-specified identifier for the key)
|
@@ -90,7 +90,7 @@ libra_server = get_var('libra_server')
|
|
90
90
|
debug = get_var('debug') == 'false' ? nil : get_var('debug')
|
91
91
|
opt['rhlogin'] = get_var('default_rhlogin') unless opt['rhlogin']
|
92
92
|
|
93
|
-
if opt['help']
|
93
|
+
if opt['help'] || 0 != ARGV.length
|
94
94
|
p_usage
|
95
95
|
end
|
96
96
|
|
data/bin/rhc-domain
ADDED
@@ -0,0 +1,348 @@
|
|
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
|
+
|
25
|
+
require 'rhc-common'
|
26
|
+
|
27
|
+
#
|
28
|
+
# print help
|
29
|
+
#
|
30
|
+
def p_usage
|
31
|
+
rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
|
32
|
+
puts <<USAGE
|
33
|
+
|
34
|
+
Usage: rhc domain (<command> | --help) [<args>]
|
35
|
+
Manage a domain in rhcloud for a registered rhcloud user.
|
36
|
+
|
37
|
+
List of commands
|
38
|
+
create Bind a registered rhcloud user to a domain in rhcloud.
|
39
|
+
show Display domain information and list the applications within the domain
|
40
|
+
alter Alter namespace (will change urls).
|
41
|
+
status Run a simple check on local configs and credentials to confirm tools are properly setup.
|
42
|
+
destroy Destroys the domain and any added ssh keys
|
43
|
+
|
44
|
+
List of arguments
|
45
|
+
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
46
|
+
-p|--password password RHLogin password (optional, will prompt)
|
47
|
+
-n|--namespace namespace Namespace for your application(s) (alphanumeric - max #{RHC::DEFAULT_MAX_LENGTH} chars) (required for creating or destroying domain)
|
48
|
+
-d|--debug Print Debug info
|
49
|
+
-h|--help Show Usage info
|
50
|
+
--config path Path of alternate config file
|
51
|
+
--timeout # Timeout, in seconds, for connection
|
52
|
+
|
53
|
+
USAGE
|
54
|
+
exit 255
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def get_args()
|
59
|
+
args = ""
|
60
|
+
$opt.each do |o, a|
|
61
|
+
if a.length > 0 && a.to_s.strip.length == 0; a = "'#{a}'" end
|
62
|
+
args += " --#{o} #{a}"
|
63
|
+
end
|
64
|
+
args
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate_args(val_namespace=true, val_timeout=true)
|
68
|
+
# If provided a config path, check it
|
69
|
+
check_cpath($opt)
|
70
|
+
|
71
|
+
# Pull in configs from files
|
72
|
+
$libra_server = get_var('libra_server')
|
73
|
+
debug = get_var('debug') == 'false' ? nil : get_var('debug')
|
74
|
+
|
75
|
+
$opt['rhlogin'] = get_var('default_rhlogin') unless $opt['rhlogin']
|
76
|
+
p_usage if !RHC::check_rhlogin($opt['rhlogin'])
|
77
|
+
|
78
|
+
p_usage if (val_namespace && !RHC::check_namespace($opt['namespace']))
|
79
|
+
|
80
|
+
debug = $opt["debug"] ? true : false
|
81
|
+
RHC::debug(debug)
|
82
|
+
|
83
|
+
RHC::timeout($opt["timeout"] ? $opt["timeout"] : get_var('timeout')) if val_timeout
|
84
|
+
|
85
|
+
$password = $opt['password'] ? $opt['password'] : RHC::get_password
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_or_alter_domain(alter=false)
|
89
|
+
validate_args()
|
90
|
+
|
91
|
+
ssh_key_file_path = get_kfile(false)
|
92
|
+
ssh_pub_key_file_path = get_kpfile(ssh_key_file_path, alter)
|
93
|
+
|
94
|
+
ssh_config = "#{ENV['HOME']}/.ssh/config"
|
95
|
+
ssh_config_d = "#{ENV['HOME']}/.ssh/"
|
96
|
+
|
97
|
+
# Check to see if a ssh_key_file_path exists, if not create it.
|
98
|
+
if File.readable?(ssh_key_file_path)
|
99
|
+
puts "OpenShift Express key found at #{ssh_key_file_path}. Reusing..."
|
100
|
+
else
|
101
|
+
puts "Generating OpenShift Express ssh key to #{ssh_key_file_path}"
|
102
|
+
# Use system for interaction
|
103
|
+
system("ssh-keygen -t rsa -f '#{ssh_key_file_path}'")
|
104
|
+
end
|
105
|
+
|
106
|
+
ssh_keyfile_contents = File.open(ssh_pub_key_file_path).gets.chomp.split(' ')
|
107
|
+
ssh_key = ssh_keyfile_contents[1]
|
108
|
+
ssh_key_type = ssh_keyfile_contents[0]
|
109
|
+
|
110
|
+
data = {'namespace' => $opt['namespace'],
|
111
|
+
'rhlogin' => $opt['rhlogin']}
|
112
|
+
|
113
|
+
# send the ssh key and key type only in case of domain creation
|
114
|
+
# key updates will be handled by the 'rhc sshkey update' command
|
115
|
+
if !alter
|
116
|
+
data[:ssh] = ssh_key
|
117
|
+
data[:key_type] = ssh_key_type
|
118
|
+
end
|
119
|
+
|
120
|
+
if alter
|
121
|
+
data[:alter] = true
|
122
|
+
not_found_message = "A user with rhlogin '#{$opt['rhlogin']}' does not have a registered domain. Be sure to run 'rhc domain create' first."
|
123
|
+
user_info = RHC::get_user_info($libra_server, $opt['rhlogin'], $password, @http, true, not_found_message)
|
124
|
+
end
|
125
|
+
if @mydebug
|
126
|
+
data[:debug] = true
|
127
|
+
end
|
128
|
+
RHC::print_post_data(data)
|
129
|
+
json_data = RHC::generate_json(data)
|
130
|
+
|
131
|
+
url = URI.parse("https://#{$libra_server}/broker/domain")
|
132
|
+
response = RHC::http_post(@http, url, json_data, $password)
|
133
|
+
|
134
|
+
if response.code == '200'
|
135
|
+
begin
|
136
|
+
json_resp = JSON.parse(response.body)
|
137
|
+
RHC::print_response_success(json_resp)
|
138
|
+
json_rhlogininfo = JSON.parse(json_resp['data'])
|
139
|
+
add_rhlogin_config(json_rhlogininfo['rhlogin'], json_rhlogininfo['uuid'])
|
140
|
+
add_ssh_config_host(json_rhlogininfo['rhc_domain'], ssh_key_file_path, ssh_config, ssh_config_d)
|
141
|
+
|
142
|
+
if !alter
|
143
|
+
puts <<EOF
|
144
|
+
Creation successful
|
145
|
+
|
146
|
+
You may now create an application.
|
147
|
+
|
148
|
+
EOF
|
149
|
+
else
|
150
|
+
app_info = user_info['app_info']
|
151
|
+
dns_success = true
|
152
|
+
if !app_info.empty? && $opt['namespace'] != user_info['user_info']['namespace']
|
153
|
+
#
|
154
|
+
# Confirm that the host(s) exist in DNS
|
155
|
+
#
|
156
|
+
puts "Now your new domain name(s) are being propagated worldwide (this might take a minute)..."
|
157
|
+
# Allow DNS to propogate
|
158
|
+
sleep 15
|
159
|
+
app_info.each_key do |appname|
|
160
|
+
fqdn = "#{appname}-#{$opt['namespace']}.#{user_info['user_info']['rhc_domain']}"
|
161
|
+
|
162
|
+
# Now start checking for DNS
|
163
|
+
loop = 0
|
164
|
+
sleep_time = 2
|
165
|
+
while loop < RHC::MAX_RETRIES && !RHC::hostexist?(fqdn)
|
166
|
+
sleep sleep_time
|
167
|
+
loop+=1
|
168
|
+
puts " retry # #{loop} - Waiting for DNS: #{fqdn}"
|
169
|
+
sleep_time = RHC::delay(sleep_time)
|
170
|
+
end
|
171
|
+
|
172
|
+
if loop >= RHC::MAX_RETRIES
|
173
|
+
puts "Host could not be found: #{fqdn}"
|
174
|
+
dns_success = false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
puts "You can use 'rhc domain show' to view any url changes. Be sure to update any links"
|
178
|
+
puts "including the url in your local git config: <local_git_repo>/.git/config"
|
179
|
+
end
|
180
|
+
if dns_success
|
181
|
+
puts "Alteration successful."
|
182
|
+
else
|
183
|
+
puts "Alteration successful but at least one of the urls is still updating in DNS."
|
184
|
+
end
|
185
|
+
puts ""
|
186
|
+
end
|
187
|
+
exit 0
|
188
|
+
rescue JSON::ParserError
|
189
|
+
RHC::print_response_err(response)
|
190
|
+
end
|
191
|
+
else
|
192
|
+
RHC::print_response_err(response)
|
193
|
+
end
|
194
|
+
exit 1
|
195
|
+
end
|
196
|
+
|
197
|
+
def destroy_domain()
|
198
|
+
validate_args(true, false)
|
199
|
+
|
200
|
+
url = URI.parse("https://#{$libra_server}/broker/domain")
|
201
|
+
data = {}
|
202
|
+
data[:rhlogin] = $opt['rhlogin']
|
203
|
+
data[:delete] = true
|
204
|
+
data[:namespace] = $opt['namespace']
|
205
|
+
|
206
|
+
RHC::print_post_data(data)
|
207
|
+
json_data = RHC::generate_json(data)
|
208
|
+
|
209
|
+
response = RHC::http_post(@http, url, json_data, $password)
|
210
|
+
|
211
|
+
if response.code == '200'
|
212
|
+
begin
|
213
|
+
json_resp = JSON.parse(response.body)
|
214
|
+
RHC::update_server_api_v(json_resp)
|
215
|
+
RHC::print_response_success(json_resp)
|
216
|
+
puts "Success"
|
217
|
+
exit 0
|
218
|
+
rescue JSON::ParserError
|
219
|
+
RHC::print_response_err(response)
|
220
|
+
end
|
221
|
+
else
|
222
|
+
RHC::print_response_err(response)
|
223
|
+
end
|
224
|
+
puts "Failure"
|
225
|
+
exit 1
|
226
|
+
end
|
227
|
+
|
228
|
+
def show_domain_info()
|
229
|
+
validate_args(false, true)
|
230
|
+
|
231
|
+
user_info = RHC::get_user_info($libra_server, $opt['rhlogin'], $password, @http, true)
|
232
|
+
|
233
|
+
puts ""
|
234
|
+
puts "User Info"
|
235
|
+
puts "========="
|
236
|
+
puts "Namespace: #{user_info['user_info']['namespace']}"
|
237
|
+
#puts " UUID: #{user_info['user_info']['uuid']}"
|
238
|
+
puts " RHLogin: #{user_info['user_info']['rhlogin']}"
|
239
|
+
|
240
|
+
puts "\n\n"
|
241
|
+
|
242
|
+
puts "Application Info"
|
243
|
+
puts "================"
|
244
|
+
unless user_info['app_info'].empty?
|
245
|
+
user_info['app_info'].each do |key, val|
|
246
|
+
puts key
|
247
|
+
puts " Framework: #{val['framework']}"
|
248
|
+
puts " Creation: #{val['creation_time']}"
|
249
|
+
puts " UUID: #{val['uuid']}"
|
250
|
+
puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
|
251
|
+
puts " Public URL: http://#{key}-#{user_info['user_info']['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
252
|
+
if val['aliases'] && !val['aliases'].empty?
|
253
|
+
puts " Aliases: #{val['aliases'].join(', ')}"
|
254
|
+
end
|
255
|
+
puts ""
|
256
|
+
puts " Embedded: "
|
257
|
+
if val['embedded'] && !val['embedded'].empty?
|
258
|
+
val['embedded'].each do |embed_key, embed_val|
|
259
|
+
if embed_val.has_key?('info') && !embed_val['info'].empty?
|
260
|
+
puts " #{embed_key} - #{embed_val['info']}"
|
261
|
+
else
|
262
|
+
puts " #{embed_key}"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
else
|
266
|
+
puts " None"
|
267
|
+
end
|
268
|
+
puts ""
|
269
|
+
end
|
270
|
+
else
|
271
|
+
puts "No applications found. You can use 'rhc app create' to create new applications."
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def check_domain_status
|
276
|
+
$opt['rhlogin'] = get_var('default_rhlogin') unless $opt['rhlogin']
|
277
|
+
p_usage if !RHC::check_rhlogin($opt['rhlogin'])
|
278
|
+
|
279
|
+
system("rhc-chk #{get_args} 2>&1")
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
begin
|
284
|
+
argv_c = ARGV.clone
|
285
|
+
|
286
|
+
if ARGV[0] =~ /^(create|alter|destroy)$/
|
287
|
+
ARGV.shift
|
288
|
+
opts = GetoptLong.new(
|
289
|
+
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
290
|
+
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
291
|
+
["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
|
292
|
+
["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
|
293
|
+
["--namespace", "-n", GetoptLong::REQUIRED_ARGUMENT],
|
294
|
+
["--config", GetoptLong::REQUIRED_ARGUMENT],
|
295
|
+
["--timeout", GetoptLong::REQUIRED_ARGUMENT]
|
296
|
+
)
|
297
|
+
elsif ARGV[0] =~ /^(status|show)$/
|
298
|
+
ARGV.shift
|
299
|
+
opts = GetoptLong.new(
|
300
|
+
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
301
|
+
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
302
|
+
["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
|
303
|
+
["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
|
304
|
+
["--config", GetoptLong::REQUIRED_ARGUMENT],
|
305
|
+
["--timeout", GetoptLong::REQUIRED_ARGUMENT]
|
306
|
+
)
|
307
|
+
else
|
308
|
+
# if the user just enters "rhc domain", don't throw an error
|
309
|
+
# let it be handled by the "rhc domain show" command
|
310
|
+
if ARGV[0].to_s.strip.length == 0
|
311
|
+
opts = []
|
312
|
+
else
|
313
|
+
puts "Missing or invalid command!" unless ARGV[0] =~ /^(help|-h|--help)$/
|
314
|
+
# just exit at this point
|
315
|
+
# printing the usage description will be handled in the rescue
|
316
|
+
exit 255
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
$opt = {}
|
321
|
+
opts.each do |o, a|
|
322
|
+
$opt[o[2..-1]] = a.to_s
|
323
|
+
end
|
324
|
+
rescue Exception => e
|
325
|
+
p_usage
|
326
|
+
end
|
327
|
+
|
328
|
+
p_usage if $opt["help"]
|
329
|
+
|
330
|
+
case argv_c[0]
|
331
|
+
when "create"
|
332
|
+
create_or_alter_domain(false)
|
333
|
+
when "alter"
|
334
|
+
create_or_alter_domain(true)
|
335
|
+
when "status"
|
336
|
+
check_domain_status
|
337
|
+
when "show", nil
|
338
|
+
show_domain_info
|
339
|
+
when "destroy"
|
340
|
+
destroy_domain
|
341
|
+
when "-h", "--help", "help", nil
|
342
|
+
p_usage
|
343
|
+
else
|
344
|
+
puts "Invalid command!"
|
345
|
+
p_usage
|
346
|
+
end
|
347
|
+
|
348
|
+
exit 0
|