rhc 0.98.16 → 1.0.4
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 +7 -49
- data/bin/rhc-app +14 -3
- data/bin/rhc-chk +16 -16
- data/bin/rhc-create-app +2 -0
- data/bin/rhc-create-domain +1 -2
- data/bin/rhc-ctl-app +12 -3
- data/bin/rhc-ctl-domain +1 -2
- data/bin/rhc-domain +1 -2
- data/bin/rhc-domain-info +1 -2
- data/bin/rhc-port-forward +1 -2
- data/bin/rhc-snapshot +3 -0
- data/bin/rhc-sshkey +1 -2
- data/bin/rhc-tail-files +1 -1
- data/bin/rhc-user-info +1 -3
- data/features/application.feature +4 -1
- data/features/domain.feature +0 -4
- data/features/geared_application.feature +11 -0
- data/features/lib/rhc_helper/app.rb +16 -5
- data/features/lib/rhc_helper/cartridge.rb +25 -9
- data/features/lib/rhc_helper/commandify.rb +34 -7
- data/features/lib/rhc_helper/domain.rb +2 -2
- data/features/lib/rhc_helper/httpify.rb +24 -14
- data/features/lib/rhc_helper/persistable.rb +1 -1
- data/features/lib/rhc_helper/sshkey.rb +11 -7
- data/features/lib/rhc_helper.rb +5 -3
- data/features/multiple_cartridge.feature +1 -1
- data/features/scaled_application.feature +48 -0
- data/features/sshkey.feature +37 -31
- data/features/step_definitions/application_steps.rb +18 -7
- data/features/step_definitions/cartridge_steps.rb +29 -3
- data/features/step_definitions/domain_steps.rb +2 -2
- data/features/step_definitions/sshkey_steps.rb +34 -34
- data/features/support/assumptions.rb +21 -9
- data/features/support/before_hooks.rb +24 -6
- data/features/support/env.rb +45 -19
- data/lib/rhc/cartridge_helper.rb +27 -0
- data/lib/rhc/cli.rb +1 -1
- data/lib/rhc/command_runner.rb +31 -3
- data/lib/rhc/commands/alias.rb +38 -0
- data/lib/rhc/commands/app.rb +478 -0
- data/lib/rhc/commands/base.rb +42 -12
- data/lib/rhc/commands/cartridge.rb +189 -0
- data/lib/rhc/commands/domain.rb +11 -49
- data/lib/rhc/commands/port-forward.rb +0 -1
- data/lib/rhc/commands/setup.rb +2 -1
- data/lib/rhc/commands/snapshot.rb +118 -0
- data/lib/rhc/commands/sshkey.rb +24 -38
- data/lib/rhc/commands/tail.rb +24 -0
- data/lib/rhc/commands/threaddump.rb +16 -0
- data/lib/rhc/commands.rb +33 -7
- data/lib/rhc/config.rb +28 -12
- data/lib/rhc/context_helper.rb +19 -5
- data/lib/rhc/core_ext.rb +86 -0
- data/lib/rhc/exceptions.rb +44 -0
- data/lib/rhc/git_helper.rb +59 -0
- data/lib/rhc/helpers.rb +86 -5
- data/lib/rhc/output_helpers.rb +213 -0
- data/lib/rhc/rest/application.rb +134 -67
- data/lib/rhc/rest/base.rb +48 -0
- data/lib/rhc/rest/cartridge.rb +40 -44
- data/lib/rhc/rest/client.rb +127 -59
- data/lib/rhc/rest/domain.rb +29 -39
- data/lib/rhc/rest/gear_group.rb +10 -0
- data/lib/rhc/rest/key.rb +8 -23
- data/lib/rhc/rest/user.rb +8 -24
- data/lib/rhc/rest.rb +22 -11
- data/lib/rhc/ssh_key_helpers.rb +47 -0
- data/lib/rhc/usage_templates/help.erb +0 -1
- data/lib/rhc/version.rb +3 -3
- data/lib/rhc/wizard.rb +123 -225
- data/lib/rhc-common.rb +43 -62
- data/spec/rest_spec_helper.rb +159 -36
- data/spec/rhc/cli_spec.rb +29 -1
- data/spec/rhc/command_spec.rb +32 -35
- data/spec/rhc/commands/alias_spec.rb +123 -0
- data/spec/rhc/commands/app_spec.rb +414 -0
- data/spec/rhc/commands/cartridge_spec.rb +342 -0
- data/spec/rhc/commands/domain_spec.rb +8 -8
- data/spec/rhc/commands/setup_spec.rb +17 -6
- data/spec/rhc/commands/snapshot_spec.rb +140 -0
- data/spec/rhc/commands/sshkey_spec.rb +26 -4
- data/spec/rhc/commands/tail_spec.rb +34 -0
- data/spec/rhc/commands/threaddump_spec.rb +83 -0
- data/spec/rhc/config_spec.rb +39 -13
- data/spec/rhc/context_spec.rb +51 -0
- data/spec/rhc/helpers_spec.rb +52 -12
- data/spec/rhc/rest_application_spec.rb +16 -3
- data/spec/rhc/rest_client_spec.rb +144 -36
- data/spec/rhc/rest_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +133 -232
- data/spec/spec_helper.rb +4 -3
- metadata +56 -31
- data/features/support/ssh.sh +0 -2
- data/spec/rhc/common_spec.rb +0 -49
data/lib/rhc/wizard.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rhc/ssh_key_helpers'
|
|
4
4
|
require 'highline/system_extensions'
|
5
5
|
require 'net/ssh'
|
6
6
|
require 'fileutils'
|
7
|
+
require 'socket'
|
7
8
|
|
8
9
|
module RHC
|
9
10
|
class Wizard
|
@@ -24,7 +25,7 @@ module RHC
|
|
24
25
|
STAGES
|
25
26
|
end
|
26
27
|
|
27
|
-
def initialize(config)
|
28
|
+
def initialize(config, opts=nil)
|
28
29
|
@config = config
|
29
30
|
@config_path = config.config_path
|
30
31
|
if @libra_server.nil?
|
@@ -32,6 +33,8 @@ module RHC
|
|
32
33
|
# if not set, set to default
|
33
34
|
@libra_server = @libra_server ? @libra_server : "openshift.redhat.com"
|
34
35
|
end
|
36
|
+
@config.config_user opts.rhlogin if opts && opts.rhlogin
|
37
|
+
@debug = opts.debug if opts.respond_to? :debug
|
35
38
|
end
|
36
39
|
|
37
40
|
# Public: Runs the setup wizard to make sure ~/.openshift and ~/.ssh are correct
|
@@ -45,6 +48,7 @@ module RHC
|
|
45
48
|
def run
|
46
49
|
stages.each do |stage|
|
47
50
|
# FIXME: cleanup if we fail
|
51
|
+
debug "Running #{stage}"
|
48
52
|
if (self.send stage).nil?
|
49
53
|
return nil
|
50
54
|
end
|
@@ -77,21 +81,25 @@ module RHC
|
|
77
81
|
def login_stage
|
78
82
|
# get_password adds an extra untracked newline so set :bottom to -1
|
79
83
|
section(:top => 1, :bottom => -1) do
|
80
|
-
@
|
81
|
-
|
84
|
+
if @config.has_opts? && @config.opts_login
|
85
|
+
@username = @config.opts_login
|
86
|
+
say "Using #{@username}, which was given on the command line"
|
87
|
+
else
|
88
|
+
@username = ask("To connect to #{@libra_server} enter your OpenShift login (email or Red Hat login id): ") do |q|
|
89
|
+
q.default = RHC::Config.default_rhlogin
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
@password = RHC::Config.password
|
85
94
|
@password = RHC::get_password if @password.nil?
|
86
95
|
end
|
87
96
|
|
88
|
-
# Confirm username / password works:
|
89
|
-
user_info = RHC::get_user_info(@libra_server, @username, @password, RHC::Config.default_proxy, true)
|
90
|
-
|
91
97
|
# instantiate a REST client that stages can use
|
92
|
-
# TODO: use only REST calls in the wizard
|
93
98
|
end_point = "https://#{@libra_server}/broker/rest/api"
|
94
|
-
@rest_client = RHC::Rest::Client.new(end_point, @username, @password)
|
99
|
+
@rest_client = RHC::Rest::Client.new(end_point, @username, @password, @debug)
|
100
|
+
|
101
|
+
# confirm that the REST client can connect
|
102
|
+
return false unless @rest_client.user
|
95
103
|
|
96
104
|
true
|
97
105
|
end
|
@@ -136,87 +144,59 @@ EOF
|
|
136
144
|
true
|
137
145
|
end
|
138
146
|
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
|
147
|
+
# return true if the account has the public key defined by
|
148
|
+
# RHC::Config::ssh_pub_key_file_path
|
143
149
|
def ssh_key_uploaded?
|
144
|
-
@ssh_keys
|
145
|
-
|
146
|
-
|
147
|
-
local_fingerprint = nil
|
148
|
-
begin
|
149
|
-
local_fingerprint = Net::SSH::KeyFactory.load_public_key(RHC::Config.ssh_pub_key_file_path).fingerprint
|
150
|
-
rescue NoMethodError #older net/ssh (mac for example)
|
151
|
-
local_fingerprint = ssh_keygen_fallback RHC::Config.ssh_pub_key_file_path
|
152
|
-
end
|
150
|
+
@ssh_keys ||= @rest_client.sshkeys
|
151
|
+
@ssh_keys.any? { |k| k.fingerprint == fingerprint_for_default_key }
|
152
|
+
end
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
154
|
+
def existing_keys_info
|
155
|
+
return unless @ssh_keys
|
156
|
+
# TODO: This ERB format is shared with RHC::Commands::Sshkey; should be refactored
|
157
|
+
@ssh_keys.inject("Current Keys: \n") do |result, key|
|
158
|
+
erb = ::RHC::Helpers.ssh_key_display_format
|
159
|
+
result += format(key, erb)
|
157
160
|
end
|
158
|
-
|
159
|
-
false
|
160
161
|
end
|
161
162
|
|
162
|
-
def
|
163
|
-
additional_ssh_keys = @ssh_keys['keys']
|
164
|
-
known_keys = []
|
165
|
-
|
163
|
+
def get_preferred_key_name
|
166
164
|
paragraph do
|
167
165
|
say "You can enter a name for your key, or leave it blank to use the default name. " \
|
168
166
|
"Using the same name as an existing key will overwrite the old key."
|
169
167
|
end
|
168
|
+
key_name = 'default'
|
170
169
|
|
171
|
-
|
172
|
-
if @ssh_keys['fingerprint'].nil?
|
173
|
-
section(:bottom => 1) { say " None" }
|
174
|
-
else
|
175
|
-
known_keys << 'default'
|
176
|
-
section do
|
177
|
-
say " default - #{@ssh_keys['fingerprint']}"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
if additional_ssh_keys && additional_ssh_keys.kind_of?(Hash)
|
182
|
-
section(:bottom => 1) do
|
183
|
-
additional_ssh_keys.each do |name, keyval|
|
184
|
-
say " #{name} - #{keyval['fingerprint']}"
|
185
|
-
known_keys.push(name)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
if @ssh_keys['fingerprint'].nil?
|
191
|
-
key_name = "default"
|
170
|
+
if @ssh_keys.empty?
|
192
171
|
paragraph do
|
193
|
-
say
|
194
|
-
|
172
|
+
say <<-DEFAULT_KEY_UPLOAD_MSG
|
173
|
+
Since you do not have any keys associated with your OpenShift account,
|
174
|
+
your new key will be uploaded as the 'default' key
|
175
|
+
DEFAULT_KEY_UPLOAD_MSG
|
195
176
|
end
|
196
177
|
else
|
197
|
-
|
198
|
-
key_valid = true
|
199
|
-
begin
|
200
|
-
key_fingerprint = Net::SSH::KeyFactory.load_public_key(RHC::Config.ssh_pub_key_file_path).fingerprint
|
201
|
-
rescue NoMethodError #older net/ssh (mac for example)
|
202
|
-
key_fingerprint = ssh_keygen_fallback RHC::Config.ssh_pub_key_file_path
|
203
|
-
if $?.exitstatus != 0
|
204
|
-
key_valid = false
|
205
|
-
end
|
206
|
-
rescue Net::SSH::Exception, NotImplementedError
|
207
|
-
key_valid = false
|
208
|
-
end
|
178
|
+
section(:top => 1) { say existing_keys_info }
|
209
179
|
|
210
|
-
|
180
|
+
key_fingerprint = fingerprint_for_default_key
|
181
|
+
unless key_fingerprint
|
211
182
|
paragraph do
|
212
|
-
say
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
183
|
+
say <<-CONFIG_KEY_INVALID
|
184
|
+
Your ssh public key at #{RHC::Config.ssh_pub_key_file_path} is invalid or unreadable.
|
185
|
+
The setup can not continue until you manually remove or fix both of your
|
186
|
+
public and private keys id_rsa keys.
|
187
|
+
CONFIG_KEY_INVALID
|
188
|
+
end
|
189
|
+
return nil
|
217
190
|
end
|
218
|
-
|
219
|
-
|
191
|
+
hostname = Socket.gethostname.gsub(/\..*\z/,'')
|
192
|
+
username = @username ? @username.gsub(/@.*/, '') : ''
|
193
|
+
pubkey_base_name = "#{username}#{hostname}".gsub(/[^A-Za-z0-9]/,'').slice(0,16)
|
194
|
+
pubkey_default_name = find_unique_key_name(
|
195
|
+
:keys => @ssh_keys,
|
196
|
+
:base => pubkey_base_name,
|
197
|
+
:max_length => RHC::DEFAULT_MAX_LENGTH
|
198
|
+
)
|
199
|
+
|
220
200
|
paragraph do
|
221
201
|
key_name = ask("Provide a name for this key: ") do |q|
|
222
202
|
q.default = pubkey_default_name
|
@@ -225,46 +205,65 @@ EOF
|
|
225
205
|
end
|
226
206
|
end
|
227
207
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
208
|
+
key_name
|
209
|
+
end
|
210
|
+
|
211
|
+
# given the base name and the maximum length,
|
212
|
+
# find a name that does not clash with what is in opts[:keys]
|
213
|
+
def find_unique_key_name(opts)
|
214
|
+
keys = opts[:keys] || @ssh_keys
|
215
|
+
base = opts[:base] || 'default'
|
216
|
+
max = opts[:max_length] || RHC::DEFAULT_MAX_LENGTH # in rhc-common.rb
|
217
|
+
key_name_suffix = 1
|
218
|
+
candidate = base
|
219
|
+
while @ssh_keys.detect { |k| k.name == candidate }
|
220
|
+
candidate = base.slice(0, max - key_name_suffix.to_s.length) +
|
221
|
+
key_name_suffix.to_s
|
222
|
+
key_name_suffix += 1
|
223
|
+
end
|
224
|
+
candidate
|
225
|
+
end
|
226
|
+
|
227
|
+
def upload_ssh_key
|
228
|
+
key_name = get_preferred_key_name
|
229
|
+
return false unless key_name
|
230
|
+
|
231
|
+
type, content, comment = ssh_key_triple_for_default_key
|
232
|
+
say "type: %s\ncontent: %s\nfingerprint: %s" % [type, content, fingerprint_for_default_key]
|
233
|
+
|
234
|
+
if !@ssh_keys.empty? && @ssh_keys.any? { |k| k.name == key_name }
|
235
|
+
say "Key with the name #{key_name} already exists. Updating... "
|
236
|
+
key = @rest_client.find_key(key_name)
|
237
|
+
key.update(type, content)
|
233
238
|
else
|
234
|
-
|
235
|
-
|
236
|
-
add_or_update_key('add', key_name, RHC::Config.ssh_pub_key_file_path, @username, @password)
|
237
|
-
end
|
239
|
+
say "Uploading key '#{key_name}' from #{RHC::Config::ssh_pub_key_file_path}"
|
240
|
+
@rest_client.add_key key_name, content, type
|
238
241
|
end
|
242
|
+
|
239
243
|
true
|
240
244
|
end
|
241
245
|
|
242
246
|
def upload_ssh_key_stage
|
243
|
-
|
244
|
-
upload = false
|
245
|
-
section do
|
246
|
-
upload = agree "Your public ssh key must be uploaded to the OpenShift server. Would you like us to upload it for you? (yes/no) "
|
247
|
-
end
|
247
|
+
return true if ssh_key_uploaded?
|
248
248
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
249
|
+
upload = false
|
250
|
+
section do
|
251
|
+
upload = agree "Your public ssh key must be uploaded to the OpenShift server. Would you like us to upload it for you? (yes/no) "
|
252
|
+
end
|
253
|
+
|
254
|
+
if upload
|
255
|
+
upload_ssh_key
|
256
|
+
else
|
257
|
+
paragraph do
|
258
|
+
say "You can upload your ssh key at a later time using the 'rhc sshkey' command"
|
255
259
|
end
|
256
260
|
end
|
257
261
|
true
|
258
262
|
end
|
259
263
|
|
260
264
|
##
|
261
|
-
#
|
262
|
-
#
|
263
|
-
# should manually install them
|
264
|
-
#
|
265
|
-
# On Unix we rely on PackageKit (which mostly just covers modern Linux flavors
|
266
|
-
# such as Fedora, Suse, Debian and Ubuntu). On Windows we will give instructions
|
267
|
-
# and links for the tools they should install
|
265
|
+
# Alert the user that they should manually install tools if they are not
|
266
|
+
# currently available
|
268
267
|
#
|
269
268
|
# Unix Tools:
|
270
269
|
# git
|
@@ -277,16 +276,10 @@ EOF
|
|
277
276
|
if windows?
|
278
277
|
windows_install
|
279
278
|
else
|
280
|
-
# we use command line tools for dbus since the dbus gem is not cross
|
281
|
-
# platform and compiles itself on the host system when installed
|
282
279
|
paragraph do
|
283
280
|
say "We will now check to see if you have the necessary client tools installed."
|
284
281
|
end
|
285
|
-
|
286
|
-
package_kit_install
|
287
|
-
else
|
288
|
-
generic_unix_install_check
|
289
|
-
end
|
282
|
+
generic_unix_install_check
|
290
283
|
end
|
291
284
|
true
|
292
285
|
end
|
@@ -294,14 +287,13 @@ EOF
|
|
294
287
|
def config_namespace_stage
|
295
288
|
paragraph do
|
296
289
|
say "Checking for your namespace ... "
|
297
|
-
|
298
|
-
domains = user_info['user_info']['domains']
|
290
|
+
domains = @rest_client.domains
|
299
291
|
if domains.length == 0
|
300
292
|
say "not found"
|
301
293
|
ask_for_namespace
|
302
294
|
else
|
303
295
|
say "found namespace:"
|
304
|
-
domains.each { |d| say " #{d
|
296
|
+
domains.each { |d| say " #{d.id}" }
|
305
297
|
end
|
306
298
|
end
|
307
299
|
|
@@ -312,33 +304,31 @@ EOF
|
|
312
304
|
section do
|
313
305
|
say "Checking for applications ... "
|
314
306
|
end
|
315
|
-
|
316
|
-
apps =
|
307
|
+
|
308
|
+
apps = @rest_client.domains.inject([]) do |list, domain|
|
309
|
+
list += domain.applications
|
310
|
+
end
|
311
|
+
|
317
312
|
if !apps.nil? and !apps.empty?
|
318
313
|
section(:bottom => 1) do
|
319
314
|
say "found"
|
320
|
-
apps.each do |
|
321
|
-
app_url
|
322
|
-
|
323
|
-
app_url = "http://#{app_name}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/"
|
324
|
-
end
|
325
|
-
|
326
|
-
if app_url.nil?
|
327
|
-
say " * #{app_name} - no public url (you need to add a namespace)"
|
315
|
+
apps.each do |app|
|
316
|
+
if app.app_url.nil? && app.u
|
317
|
+
say " * #{app.name} - no public url (you need to add a namespace)"
|
328
318
|
else
|
329
|
-
say " * #{
|
319
|
+
say " * #{app.name} - #{app.app_url}"
|
330
320
|
end
|
331
321
|
end
|
332
322
|
end
|
333
323
|
else
|
334
324
|
section(:bottom => 1) { say "none found" }
|
335
325
|
paragraph do
|
336
|
-
say "
|
337
|
-
|
326
|
+
say "Run 'rhc app create' to create your first application.\n\n"
|
327
|
+
say "Below is a list of the types of application you can create: \n"
|
338
328
|
|
339
|
-
application_types =
|
340
|
-
application_types.each do |cart|
|
341
|
-
say " * #{cart} - rhc app create
|
329
|
+
application_types = @rest_client.find_cartridges :type => "standalone"
|
330
|
+
application_types.sort {|a,b| a.name <=> b.name }.each do |cart|
|
331
|
+
say " * #{cart.name} - rhc app create <app name> #{cart.name}"
|
342
332
|
end
|
343
333
|
end
|
344
334
|
end
|
@@ -401,96 +391,6 @@ EOF
|
|
401
391
|
end
|
402
392
|
end
|
403
393
|
|
404
|
-
def dbus_send_exec(name, service, obj_path, iface, stringafied_params, wait_for_reply)
|
405
|
-
# :nocov: dbus_send_exec is not safe to run on a test system
|
406
|
-
method = "#{iface}.#{name}"
|
407
|
-
print_reply = ""
|
408
|
-
print_reply = "--print-reply" if wait_for_reply
|
409
|
-
|
410
|
-
cmd = "dbus-send --session #{print_reply} --type=method_call \
|
411
|
-
--dest=#{service} #{obj_path} #{method} #{stringafied_params}"
|
412
|
-
`cmd 2>&1`
|
413
|
-
# :nocov:
|
414
|
-
end
|
415
|
-
|
416
|
-
def dbus_send_session_method(name, service, obj_path, iface, stringafied_params, wait_for_reply=true)
|
417
|
-
output = dbus_send_exec(name, service, obj_path, iface, stringafied_params, wait_for_reply)
|
418
|
-
raise output if output.start_with?('Error') and !$?.success?
|
419
|
-
|
420
|
-
# parse the output
|
421
|
-
results = []
|
422
|
-
output.split('\n').each_with_index do |line, i|
|
423
|
-
if i != 0 # discard first line
|
424
|
-
param_type, value = line.chomp.split(" ", 2)
|
425
|
-
|
426
|
-
case param_type
|
427
|
-
when "boolean"
|
428
|
-
results << (value == 'true')
|
429
|
-
when "string"
|
430
|
-
results << value
|
431
|
-
else
|
432
|
-
say "unknown type #{param_type} - treating as string"
|
433
|
-
results << value
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
if results.length == 0
|
439
|
-
return nil
|
440
|
-
elsif results.length == 1
|
441
|
-
return results[0]
|
442
|
-
else
|
443
|
-
return results
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
##
|
448
|
-
# calls package kit methods using dbus_send
|
449
|
-
#
|
450
|
-
# name - method name
|
451
|
-
# iface - either 'Query' or 'Modify'
|
452
|
-
# stringafied_params - string of params in the format of dbus-send
|
453
|
-
# e.g. "int32:10 string:'hello world'"
|
454
|
-
#
|
455
|
-
def package_kit_method(name, iface, stringafied_params, wait_for_reply=true)
|
456
|
-
service = "org.freedesktop.PackageKit"
|
457
|
-
obj_path = "/org/freedesktop/PackageKit"
|
458
|
-
full_iface = "org.freedesktop.PackageKit.#{iface}"
|
459
|
-
dbus_send_session_method name, service, obj_path, full_iface, stringafied_params, wait_for_reply
|
460
|
-
end
|
461
|
-
def package_kit_git_installed?
|
462
|
-
package_kit_method('IsInstalled', 'Query', 'string:git string:')
|
463
|
-
end
|
464
|
-
|
465
|
-
def package_kit_install
|
466
|
-
section(:top => 1) do
|
467
|
-
say "Checking for git ... "
|
468
|
-
end
|
469
|
-
|
470
|
-
begin
|
471
|
-
# double check due to slight differences in older platforms
|
472
|
-
if has_git? or package_kit_git_installed?
|
473
|
-
section(:bottom => 1) { say "found" }
|
474
|
-
else
|
475
|
-
section(:bottom => 1) { say "needs to be installed" }
|
476
|
-
install = false
|
477
|
-
section do
|
478
|
-
install = agree "Would you like to install git with the system installer? (yes/no) "
|
479
|
-
end
|
480
|
-
if install
|
481
|
-
package_kit_method('InstallPackageNames', 'Modify', 'uint32:0 array:string:"git" string:', false)
|
482
|
-
paragraph do
|
483
|
-
say "You may safely continue while the installer is running or " \
|
484
|
-
"you can wait until it has finished. Press any key to continue:"
|
485
|
-
get_character
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
rescue
|
490
|
-
generic_unix_install_check false
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
394
|
def generic_unix_install_check(show_action=true)
|
495
395
|
section(:top => 1) { say "Checking for git ... " } if show_action
|
496
396
|
if has_git?
|
@@ -532,16 +432,15 @@ EOF
|
|
532
432
|
rescue
|
533
433
|
false
|
534
434
|
end
|
535
|
-
|
536
|
-
def
|
537
|
-
|
538
|
-
exe? 'dbus-send' and !bus.nil? and bus.length > 0
|
435
|
+
|
436
|
+
def debug?
|
437
|
+
@debug
|
539
438
|
end
|
540
439
|
end
|
541
440
|
|
542
441
|
class RerunWizard < Wizard
|
543
|
-
def initialize(config)
|
544
|
-
super
|
442
|
+
def initialize(config, login=nil)
|
443
|
+
super(config, login)
|
545
444
|
end
|
546
445
|
|
547
446
|
def greeting_stage
|
@@ -592,9 +491,8 @@ EOF
|
|
592
491
|
STAGES
|
593
492
|
end
|
594
493
|
|
595
|
-
def initialize(
|
596
|
-
@
|
597
|
-
@password = password
|
494
|
+
def initialize(rest_client)
|
495
|
+
@rest_client = rest_client
|
598
496
|
super RHC::Config
|
599
497
|
end
|
600
498
|
end
|
data/lib/rhc-common.rb
CHANGED
@@ -872,67 +872,56 @@ LOOKSGOOD
|
|
872
872
|
def self.snapshot_restore(rhc_domain, namespace, app_name, app_uuid, filename, debug=false)
|
873
873
|
if File.exists? filename
|
874
874
|
|
875
|
-
|
875
|
+
include_git = RHC::Helpers.windows? ? false : RHC::TarGz.contains(filename, './*/git')
|
876
876
|
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
return 255
|
877
|
+
ssh_cmd = "cat #{filename} | ssh #{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
|
878
|
+
puts "Restoring from snapshot #{filename}..."
|
879
|
+
puts ssh_cmd if debug
|
880
|
+
puts
|
882
881
|
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
channel.on_extended_data do |ch, type, data|
|
911
|
-
puts data
|
912
|
-
end
|
913
|
-
channel.on_close do |ch|
|
914
|
-
puts "Terminating..."
|
915
|
-
end
|
916
|
-
File.open(filename, 'rb') do |file|
|
917
|
-
file.chunk(1024) do |chunk|
|
918
|
-
channel.send_data chunk
|
919
|
-
end
|
882
|
+
begin
|
883
|
+
if ! RHC::Helpers.windows?
|
884
|
+
output = `#{ssh_cmd}`
|
885
|
+
if $?.exitstatus != 0
|
886
|
+
puts output
|
887
|
+
puts "Error in trying to restore snapshot. You can try to restore manually by running:"
|
888
|
+
puts
|
889
|
+
puts ssh_cmd
|
890
|
+
puts
|
891
|
+
return 1
|
892
|
+
end
|
893
|
+
else
|
894
|
+
ssh = Net::SSH.start("#{app_name}-#{namespace}.#{rhc_domain}", app_uuid)
|
895
|
+
ssh.open_channel do |channel|
|
896
|
+
channel.exec("restore#{include_git ? ' INCLUDE_GIT' : ''}") do |ch, success|
|
897
|
+
channel.on_data do |ch, data|
|
898
|
+
puts data
|
899
|
+
end
|
900
|
+
channel.on_extended_data do |ch, type, data|
|
901
|
+
puts data
|
902
|
+
end
|
903
|
+
channel.on_close do |ch|
|
904
|
+
puts "Terminating..."
|
905
|
+
end
|
906
|
+
File.open(filename, 'rb') do |file|
|
907
|
+
file.chunk(1024) do |chunk|
|
908
|
+
channel.send_data chunk
|
920
909
|
end
|
921
|
-
channel.eof!
|
922
910
|
end
|
911
|
+
channel.eof!
|
923
912
|
end
|
924
|
-
ssh.loop
|
925
913
|
end
|
926
|
-
|
927
|
-
puts e.backtrace
|
928
|
-
puts "Error in trying to restore snapshot. You can try to restore manually by running:"
|
929
|
-
puts
|
930
|
-
puts ssh_cmd
|
931
|
-
puts
|
932
|
-
return 1
|
914
|
+
ssh.loop
|
933
915
|
end
|
934
|
-
|
916
|
+
rescue Exception => e
|
917
|
+
puts e.backtrace
|
918
|
+
puts "Error in trying to restore snapshot. You can try to restore manually by running:"
|
919
|
+
puts
|
920
|
+
puts ssh_cmd
|
921
|
+
puts
|
922
|
+
return 1
|
935
923
|
end
|
924
|
+
|
936
925
|
else
|
937
926
|
puts "Archive not found: #{filename}"
|
938
927
|
return 255
|
@@ -966,16 +955,8 @@ local_config_path = File.expand_path(@local_config_path)
|
|
966
955
|
#
|
967
956
|
# Check for proxy environment
|
968
957
|
#
|
969
|
-
if ENV['http_proxy']
|
970
|
-
if ENV['http_proxy']!~/^(\w+):\/\// then
|
971
|
-
ENV['http_proxy']="http://" + ENV['http_proxy']
|
972
|
-
end
|
973
|
-
proxy_uri=URI.parse(ENV['http_proxy'])
|
974
|
-
@http = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
975
|
-
else
|
976
|
-
@http = Net::HTTP
|
977
|
-
end
|
978
958
|
|
959
|
+
@http = RHC::Config.default_proxy
|
979
960
|
|
980
961
|
def config_path
|
981
962
|
return @opts_config_path ? @opts_config_path : @local_config_path
|