rhc 0.97.17 → 0.98.16
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rhc +9 -9
- data/bin/rhc-port-forward +3 -0
- data/bin/rhc-sshkey +3 -0
- data/features/README.md +163 -35
- data/features/application.feature +24 -0
- data/features/cartridge.feature +24 -0
- data/features/client.feature +11 -0
- data/features/domain.feature +29 -0
- data/features/lib/rhc_helper.rb +14 -0
- data/features/lib/rhc_helper/app.rb +2 -8
- data/features/lib/rhc_helper/cartridge.rb +1 -7
- data/features/lib/rhc_helper/commandify.rb +37 -6
- data/features/lib/rhc_helper/domain.rb +5 -1
- data/features/lib/rhc_helper/httpify.rb +124 -60
- data/features/lib/rhc_helper/loggable.rb +0 -2
- data/features/lib/rhc_helper/persistable.rb +12 -2
- data/features/lib/rhc_helper/sshkey.rb +29 -0
- data/features/multiple_cartridge.feature +17 -0
- data/features/sshkey.feature +58 -0
- data/features/step_definitions/application_steps.rb +60 -52
- data/features/step_definitions/cartridge_steps.rb +22 -24
- data/features/step_definitions/client_steps.rb +9 -2
- data/features/step_definitions/domain_steps.rb +4 -0
- data/features/step_definitions/sshkey_steps.rb +56 -0
- data/features/support/assumptions.rb +37 -0
- data/features/support/before_hooks.rb +25 -0
- data/features/support/env.rb +84 -39
- data/features/support/key1 +27 -0
- data/features/support/key1.pub +1 -0
- data/features/support/key2 +27 -0
- data/features/support/key2.pub +1 -0
- data/features/support/key3.pub +1 -0
- data/features/support/ssh.sh +2 -0
- data/features/verify.feature +18 -159
- data/lib/rhc-common.rb +8 -21
- data/lib/rhc.rb +9 -5
- data/lib/rhc/autocomplete.rb +68 -0
- data/lib/rhc/autocomplete_templates/rhc.erb +33 -0
- data/lib/rhc/cli.rb +9 -6
- data/lib/rhc/command_runner.rb +108 -0
- data/lib/rhc/commands.rb +66 -132
- data/lib/rhc/commands/base.rb +95 -24
- data/lib/rhc/commands/domain.rb +33 -50
- data/lib/rhc/commands/port-forward.rb +81 -0
- data/lib/rhc/commands/setup.rb +1 -1
- data/lib/rhc/commands/sshkey.rb +95 -0
- data/lib/rhc/config.rb +108 -103
- data/lib/rhc/context_helper.rb +19 -0
- data/lib/rhc/coverage_helper.rb +1 -1
- data/lib/rhc/exceptions.rb +55 -4
- data/lib/rhc/help_formatter.rb +2 -3
- data/lib/rhc/helpers.rb +31 -23
- data/lib/{rhc-rest.rb → rhc/rest.rb} +95 -23
- data/lib/{rhc-rest → rhc/rest}/application.rb +1 -1
- data/lib/{rhc-rest → rhc/rest}/cartridge.rb +1 -1
- data/lib/{rhc-rest → rhc/rest}/client.rb +40 -9
- data/lib/{rhc-rest → rhc/rest}/domain.rb +1 -1
- data/lib/{rhc-rest → rhc/rest}/key.rb +11 -1
- data/lib/{rhc-rest → rhc/rest}/user.rb +1 -1
- data/lib/rhc/ssh_key_helpers.rb +10 -1
- data/lib/rhc/targz.rb +7 -8
- data/lib/rhc/usage_templates/command_help.erb +7 -6
- data/lib/rhc/usage_templates/help.erb +6 -9
- data/lib/rhc/usage_templates/missing_help.erb +1 -0
- data/lib/rhc/version.rb +2 -2
- data/lib/rhc/wizard.rb +4 -9
- data/spec/coverage_helper.rb +2 -2
- data/spec/rest_spec_helper.rb +66 -16
- data/spec/rhc/cli_spec.rb +16 -5
- data/spec/rhc/command_spec.rb +61 -6
- data/spec/rhc/commands/domain_spec.rb +50 -27
- data/spec/rhc/commands/port-forward_spec.rb +133 -0
- data/spec/rhc/commands/setup_spec.rb +2 -2
- data/spec/rhc/commands/sshkey_spec.rb +141 -0
- data/spec/rhc/common_spec.rb +1 -1
- data/spec/rhc/config_spec.rb +6 -4
- data/spec/rhc/helpers_spec.rb +0 -21
- data/spec/rhc/rest_application_spec.rb +7 -7
- data/spec/rhc/rest_client_spec.rb +87 -24
- data/spec/rhc/rest_spec.rb +36 -36
- data/spec/rhc/wizard_spec.rb +3 -3
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +3 -3
- metadata +61 -31
- data/lib/rhc-rest/exceptions/exceptions.rb +0 -75
- data/test/functional/application_test.rb +0 -71
- data/test/functional/domain_test.rb +0 -123
- data/test/functional/test_credentials.rb +0 -5
- data/test/sample-usage.rb +0 -122
- data/test/support/server.rb +0 -14
- data/test/support/testcase.rb +0 -3
- data/test/test_helper.rb +0 -4
- data/test/unit/command_test.rb +0 -19
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rhc/commands/base'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module RHC::Commands
|
5
|
+
class PortForward < Base
|
6
|
+
|
7
|
+
IP_AND_PORT = /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}/
|
8
|
+
|
9
|
+
summary "Forward remote ports to the workstation"
|
10
|
+
option ["-n", "--namespace namespace"], "Namespace of the application you are port forwarding to", :context => :namespace_context, :required => true
|
11
|
+
argument :app, "Application you are port forwarding to (required)", ["-a", "--app app"]
|
12
|
+
option ["--timeout timeout"], "Timeout, in seconds, for the session"
|
13
|
+
def run(app)
|
14
|
+
|
15
|
+
rest_domain = rest_client.find_domain options.namespace
|
16
|
+
rest_app = rest_domain.find_application app
|
17
|
+
|
18
|
+
raise RHC::ScaledApplicationsNotSupportedException.new "This utility does not currently support scaled applications. You will need to set up port forwarding manually." if (rest_app.embedded.keys.any?{ |k| k =~ /\Ahaproxy/ })
|
19
|
+
|
20
|
+
ssh_uri = URI.parse(rest_app.ssh_url)
|
21
|
+
say "Using #{rest_app.ssh_url}..." if options.debug
|
22
|
+
|
23
|
+
hosts_and_ports = []
|
24
|
+
hosts_and_ports_descriptions = []
|
25
|
+
|
26
|
+
begin
|
27
|
+
|
28
|
+
say "Checking available ports..."
|
29
|
+
|
30
|
+
Net::SSH.start(ssh_uri.host, ssh_uri.user) do |ssh|
|
31
|
+
|
32
|
+
ssh.exec! "rhc-list-ports" do |channel, stream, data|
|
33
|
+
if stream == :stderr
|
34
|
+
data.each_line do |line|
|
35
|
+
line.chomp!
|
36
|
+
raise RHC::PermissionDeniedException.new "Permission denied." if line =~ /permission denied/i
|
37
|
+
hosts_and_ports_descriptions << line if line.index(IP_AND_PORT)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
data.each_line do |line|
|
41
|
+
line.chomp!
|
42
|
+
hosts_and_ports << line if ((not line =~ /scale/i) and IP_AND_PORT.match(line))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
raise RHC::NoPortsToForwardException.new "There are no available ports to forward for this application. Your application may be stopped." if hosts_and_ports.length == 0
|
48
|
+
|
49
|
+
hosts_and_ports_descriptions.each { |description| say "Binding #{description}..." }
|
50
|
+
|
51
|
+
begin
|
52
|
+
Net::SSH.start(ssh_uri.host, ssh_uri.user) do |ssh|
|
53
|
+
say "Forwarding ports, use ctl + c to stop"
|
54
|
+
hosts_and_ports.each do |host_and_port|
|
55
|
+
host, port = host_and_port.split(/:/)
|
56
|
+
ssh.forward.local(host, port.to_i, host, port.to_i)
|
57
|
+
end
|
58
|
+
ssh.loop { true }
|
59
|
+
end
|
60
|
+
rescue Interrupt
|
61
|
+
results { say "Ending port forward" }
|
62
|
+
return 0
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
rescue Timeout::Error, Errno::EADDRNOTAVAIL, Errno::EADDRINUSE, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Net::SSH::AuthenticationFailed => e
|
68
|
+
ssh_cmd = "ssh -N "
|
69
|
+
hosts_and_ports.each { |port| ssh_cmd << "-L #{port}:#{port} " }
|
70
|
+
ssh_cmd << "#{ssh_uri.user}@#{ssh_uri.host}"
|
71
|
+
raise RHC::PortForwardFailedException.new("#{e.message if options.debug}\nError trying to forward ports. You can try to forward manually by running:\n" + ssh_cmd)
|
72
|
+
end
|
73
|
+
|
74
|
+
return 0
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# mock for windows
|
80
|
+
if defined?(UNIXServer) != 'constant' or UNIXServer.class != Class then class UNIXServer; end; end
|
81
|
+
|
data/lib/rhc/commands/setup.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rhc/commands/base'
|
4
|
+
|
5
|
+
module RHC::Commands
|
6
|
+
class Sshkey < Base
|
7
|
+
include RHC::SSHKeyHelpers
|
8
|
+
|
9
|
+
summary 'Manage multiple keys for the registered rhcloud user.'
|
10
|
+
syntax '<action>'
|
11
|
+
default_action :list
|
12
|
+
|
13
|
+
summary 'Display all the SSH keys for the user account'
|
14
|
+
syntax ''
|
15
|
+
option ["--timeout timeout"], "Timeout, in seconds, for the session"
|
16
|
+
def list
|
17
|
+
ssh_keys = rest_client.sshkeys
|
18
|
+
results do
|
19
|
+
result = ''
|
20
|
+
|
21
|
+
ssh_keys.each do |key|
|
22
|
+
result += format(key, erb)
|
23
|
+
end
|
24
|
+
|
25
|
+
say result
|
26
|
+
end
|
27
|
+
|
28
|
+
0
|
29
|
+
end
|
30
|
+
|
31
|
+
summary 'List the SSH key with the given name'
|
32
|
+
syntax '<name>'
|
33
|
+
argument :name, 'SSH key to display', []
|
34
|
+
option ["--timeout timeout"], "Timeout, in seconds, for the session"
|
35
|
+
def show(name)
|
36
|
+
key = rest_client.find_key(name)
|
37
|
+
say format(key, erb)
|
38
|
+
|
39
|
+
0
|
40
|
+
end
|
41
|
+
|
42
|
+
summary 'Add SSH key to the user account'
|
43
|
+
syntax '<name> <SSH Key file>'
|
44
|
+
argument :name, 'Name for this key', []
|
45
|
+
argument :key, 'SSH public key filepath', []
|
46
|
+
option ["--timeout timeout"], "Timeout, in seconds, for the session"
|
47
|
+
def add(name, key)
|
48
|
+
begin
|
49
|
+
file = File.open(key)
|
50
|
+
rescue Errno::ENOENT => e
|
51
|
+
raise ::RHC::KeyFileNotExistentException.new("File '#{key}' does not exist.")
|
52
|
+
rescue Errno::EACCES => e
|
53
|
+
raise ::RHC::KeyFileAccessDeniedException.new("Access denied to '#{key}'.")
|
54
|
+
end
|
55
|
+
type, content, comment = file.gets.chomp.split
|
56
|
+
|
57
|
+
# validate the user input before sending it to the server
|
58
|
+
begin
|
59
|
+
Net::SSH::KeyFactory.load_data_public_key "#{type} #{content}"
|
60
|
+
rescue NotImplementedError, Net::SSH::Exception => e
|
61
|
+
raise ::RHC::KeyDataInvalidException.new("File '#{key}' contains invalid data")
|
62
|
+
end
|
63
|
+
|
64
|
+
rest_client.add_key(name, content, type)
|
65
|
+
results { say "SSH key #{key} has been added as '#{name}'" }
|
66
|
+
|
67
|
+
0
|
68
|
+
end
|
69
|
+
|
70
|
+
summary 'Remove SSH key from the user account'
|
71
|
+
syntax '<name>'
|
72
|
+
alias_action :delete
|
73
|
+
argument :name, 'SSH key to remove', []
|
74
|
+
option ["--timeout timeout"], "Timeout, in seconds, for the session"
|
75
|
+
def remove(name)
|
76
|
+
rest_client.delete_key(name)
|
77
|
+
results { say "SSH key '#{name}' has been removed" }
|
78
|
+
|
79
|
+
0
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
# shared ERB template for formatting SSH Key
|
84
|
+
def erb
|
85
|
+
return @erb if @erb # cache
|
86
|
+
@erb = ERB.new <<-FORMAT
|
87
|
+
Name: <%= key.name %>
|
88
|
+
Type: <%= key.type %>
|
89
|
+
Fingerprint: <%= key.fingerprint %>
|
90
|
+
|
91
|
+
FORMAT
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
data/lib/rhc/config.rb
CHANGED
@@ -2,77 +2,95 @@ require 'rhc/vendor/parseconfig'
|
|
2
2
|
require 'rhc/core_ext'
|
3
3
|
|
4
4
|
module RHC
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class Config
|
6
|
+
|
7
|
+
def self.default
|
8
|
+
@default ||= begin
|
9
|
+
RHC::Config.new
|
10
|
+
end.tap do |c|
|
11
|
+
c.read_config_files
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.method_missing(method, *args, &block)
|
16
|
+
if default.respond_to?(method)
|
17
|
+
default.send(method, *args, &block)
|
18
|
+
else
|
19
|
+
raise NoMethodError, method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.initialize
|
24
|
+
@default = nil
|
25
|
+
default
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
set_defaults
|
30
|
+
|
31
|
+
_gem_cfg = File.join(File.expand_path(File.dirname(__FILE__) + "/../../conf"), @conf_name)
|
32
|
+
@global_config_path = File.exists?(@_linux_cfg) ? @_linux_cfg : _gem_cfg
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_config_files
|
36
|
+
@global_config = RHC::Vendor::ParseConfig.new(@global_config_path) if File.exists?(@global_config_path)
|
37
|
+
@local_config = RHC::Vendor::ParseConfig.new(File.expand_path(@local_config_path)) if File.exists?(@local_config_path)
|
9
38
|
rescue Errno::EACCES => e
|
10
39
|
raise Errno::EACCES.new("Could not open config file: #{e.message}")
|
11
40
|
end
|
12
41
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
42
|
+
def set_defaults
|
43
|
+
@defaults = RHC::Vendor::ParseConfig.new()
|
44
|
+
@global_config = nil
|
45
|
+
@local_config = nil
|
46
|
+
@opts_config = nil # config file passed in the options
|
47
|
+
@opts = RHC::Vendor::ParseConfig.new() # option switches that override config file
|
48
|
+
@default_proxy = nil
|
49
|
+
@env_config = RHC::Vendor::ParseConfig.new()
|
21
50
|
|
22
|
-
|
23
|
-
|
51
|
+
@defaults.add('libra_server', 'openshift.redhat.com')
|
52
|
+
@env_config.add('libra_server', ENV['LIBRA_SERVER']) if ENV['LIBRA_SERVER']
|
24
53
|
#
|
25
54
|
# Config paths... /etc/openshift/express.conf or $GEM/conf/express.conf -> ~/.openshift/express.conf
|
26
55
|
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
56
|
+
@conf_name = 'express.conf'
|
57
|
+
@home_dir = File.expand_path("~")
|
58
|
+
@home_conf_path = File.join(@home_dir, '.openshift')
|
59
|
+
@local_config_path = File.join(@home_conf_path, @conf_name)
|
31
60
|
|
32
61
|
# config path passed in on the command line
|
33
|
-
|
62
|
+
@opts_config_path = nil
|
34
63
|
|
35
64
|
# authoritive config path
|
36
|
-
# this can be
|
37
|
-
#
|
65
|
+
# this can be @local_config_path or @opts_config_path
|
66
|
+
# @opts_config_path trumps
|
38
67
|
# this is used to determine where config options should be written to
|
39
68
|
# when a script modifies the config such as in rhc setup
|
40
|
-
|
69
|
+
@config_path = @local_config_path
|
41
70
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@@_linux_cfg = '/etc/openshift/' + @@conf_name
|
46
|
-
@@global_config_path = @@_linux_cfg
|
47
|
-
end
|
71
|
+
@ssh_priv_key_file_path = "#{@home_dir}/.ssh/id_rsa"
|
72
|
+
@ssh_pub_key_file_path = "#{@home_dir}/.ssh/id_rsa.pub"
|
48
73
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
_gem_cfg = File.join(File.expand_path(File.dirname(__FILE__) + "/../../conf"), @@conf_name)
|
53
|
-
@@global_config_path = File.exists?(@@_linux_cfg) ? @@_linux_cfg : _gem_cfg
|
54
|
-
|
55
|
-
read_config_files
|
74
|
+
@_linux_cfg = '/etc/openshift/' + @conf_name
|
75
|
+
@global_config_path = @_linux_cfg
|
56
76
|
end
|
57
77
|
|
58
|
-
self.initialize
|
59
|
-
|
60
78
|
# used for tests
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
79
|
+
def home_dir=(home_dir)
|
80
|
+
@home_dir=home_dir
|
81
|
+
@home_conf_path = File.join(@home_dir, '.openshift')
|
82
|
+
@local_config_path = File.join(@home_conf_path, @conf_name)
|
83
|
+
@local_config = nil
|
84
|
+
@local_config = RHC::Vendor::ParseConfig.new(File.expand_path(@local_config_path)) if File.exists?(@local_config_path)
|
85
|
+
@ssh_priv_key_file_path = "#{@home_dir}/.ssh/id_rsa"
|
86
|
+
@ssh_pub_key_file_path = "#{@home_dir}/.ssh/id_rsa.pub"
|
69
87
|
end
|
70
88
|
|
71
|
-
def
|
89
|
+
def [](key)
|
72
90
|
raise KeyError("Please use RHC::Config.password to access the password config") if key == "password"
|
73
91
|
|
74
92
|
# evaluate in cascading order
|
75
|
-
configs = [
|
93
|
+
configs = [@opts, @opts_config, @env_config, @local_config, @global_config, @defaults]
|
76
94
|
result = nil
|
77
95
|
configs.each do |conf|
|
78
96
|
result = conf[key] if !conf.nil?
|
@@ -82,45 +100,37 @@ module RHC
|
|
82
100
|
result
|
83
101
|
end
|
84
102
|
|
85
|
-
def
|
103
|
+
def get_value(key)
|
86
104
|
self[key]
|
87
105
|
end
|
88
106
|
|
89
|
-
def
|
107
|
+
def username
|
90
108
|
self['default_rhlogin']
|
91
109
|
end
|
92
110
|
|
93
111
|
# Public: configures the default user for this session
|
94
|
-
def
|
95
|
-
|
112
|
+
def config_user(username)
|
113
|
+
@defaults.add('default_rhlogin', username)
|
96
114
|
end
|
97
115
|
|
98
|
-
def
|
99
|
-
|
116
|
+
def opts_login=(username)
|
117
|
+
@opts.add('default_rhlogin', username)
|
100
118
|
end
|
101
119
|
|
102
120
|
# password is not allowed in config files and can only be passed on comman line
|
103
|
-
def
|
104
|
-
|
121
|
+
def password=(password)
|
122
|
+
@opts.add('password', password)
|
105
123
|
end
|
106
124
|
|
107
|
-
def
|
108
|
-
|
125
|
+
def password
|
126
|
+
@opts['password']
|
109
127
|
end
|
110
128
|
|
111
|
-
def
|
112
|
-
@@opts.add('noprompt', bool)
|
113
|
-
end
|
114
|
-
|
115
|
-
def self.noprompt?
|
116
|
-
@@opts['noprompt']
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.set_local_config(confpath, must_exist=true)
|
129
|
+
def set_local_config(confpath, must_exist=true)
|
120
130
|
begin
|
121
|
-
|
122
|
-
|
123
|
-
|
131
|
+
@local_config_path = File.expand_path(confpath)
|
132
|
+
@config_path = @local_config_path if @opts_config_path.nil?
|
133
|
+
@local_config = RHC::Vendor::ParseConfig.new(@local_config_path)
|
124
134
|
rescue Errno::EACCES => e
|
125
135
|
if must_exist
|
126
136
|
raise Errno::EACCES.new "Could not open config file: #{e.message}"
|
@@ -128,17 +138,17 @@ module RHC
|
|
128
138
|
end
|
129
139
|
end
|
130
140
|
|
131
|
-
def
|
141
|
+
def set_opts_config(confpath)
|
132
142
|
begin
|
133
|
-
|
134
|
-
|
135
|
-
|
143
|
+
@opts_config_path = File.expand_path(confpath)
|
144
|
+
@config_path = @opts_config_path
|
145
|
+
@opts_config = RHC::Vendor::ParseConfig.new(@opts_config_path) if File.exists?(@opts_config_path)
|
136
146
|
rescue Errno::EACCES => e
|
137
147
|
raise Errno::EACCES.new "Could not open config file: #{e.message}"
|
138
148
|
end
|
139
149
|
end
|
140
150
|
|
141
|
-
def
|
151
|
+
def check_cpath(opts)
|
142
152
|
unless opts["config"].nil?
|
143
153
|
opts_config_path = File.expand_path(opts["config"])
|
144
154
|
if !File.readable?(opts_config_path)
|
@@ -149,25 +159,20 @@ module RHC
|
|
149
159
|
end
|
150
160
|
end
|
151
161
|
|
152
|
-
def
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
def self.has_local_config?
|
157
|
-
!@@local_config.nil?
|
162
|
+
def has_global_config?
|
163
|
+
!@global_config.nil?
|
158
164
|
end
|
159
165
|
|
160
|
-
def
|
161
|
-
|
166
|
+
def has_local_config?
|
167
|
+
!@local_config.nil?
|
162
168
|
end
|
163
169
|
|
164
|
-
|
165
|
-
|
166
|
-
not (has_local_config? or has_opts_config? or noprompt?)
|
170
|
+
def has_opts_config?
|
171
|
+
!@opts_config.nil?
|
167
172
|
end
|
168
173
|
|
169
|
-
def
|
170
|
-
not File.exists?
|
174
|
+
def should_run_ssh_wizard?
|
175
|
+
not File.exists? @ssh_priv_key_file_path
|
171
176
|
end
|
172
177
|
|
173
178
|
##
|
@@ -176,46 +181,46 @@ module RHC
|
|
176
181
|
# authoritive configuration path
|
177
182
|
# this is used to determine where config options should be written to
|
178
183
|
# when a script modifies the config such as in rhc setup
|
179
|
-
def
|
180
|
-
|
184
|
+
def config_path
|
185
|
+
@config_path
|
181
186
|
end
|
182
187
|
|
183
|
-
def
|
184
|
-
|
188
|
+
def local_config_path
|
189
|
+
@local_config_path
|
185
190
|
end
|
186
191
|
|
187
|
-
def
|
188
|
-
|
192
|
+
def home_conf_path
|
193
|
+
@home_conf_path
|
189
194
|
end
|
190
195
|
|
191
|
-
def
|
192
|
-
|
196
|
+
def home_dir
|
197
|
+
@home_dir
|
193
198
|
end
|
194
199
|
|
195
|
-
def
|
196
|
-
|
200
|
+
def ssh_pub_key_file_path
|
201
|
+
@ssh_pub_key_file_path
|
197
202
|
end
|
198
203
|
|
199
|
-
def
|
204
|
+
def default_rhlogin
|
200
205
|
get_value('default_rhlogin')
|
201
206
|
end
|
202
207
|
|
203
|
-
def
|
208
|
+
def default_proxy
|
204
209
|
#
|
205
210
|
# Check for proxy environment
|
206
211
|
#
|
207
|
-
if
|
212
|
+
if @default_proxy.nil?
|
208
213
|
if ENV['http_proxy']
|
209
214
|
if ENV['http_proxy']!~/^(\w+):\/\// then
|
210
215
|
ENV['http_proxy']="http://" + ENV['http_proxy']
|
211
216
|
end
|
212
217
|
proxy_uri=URI.parse(ENV['http_proxy'])
|
213
|
-
|
218
|
+
@default_proxy = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
214
219
|
else
|
215
|
-
|
220
|
+
@default_proxy = Net::HTTP
|
216
221
|
end
|
217
222
|
end
|
218
|
-
|
223
|
+
@default_proxy
|
219
224
|
end
|
220
225
|
end
|
221
226
|
end
|