rhc 1.3.8 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,156 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rhc/coverage_helper'
4
-
5
- require 'rhc-common'
6
-
7
- RHC::Helpers.deprecated_command('rhc domain show',true)
8
-
9
- #
10
- # print help
11
- #
12
- def p_usage(error_code = 255)
13
- rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
14
- puts <<USAGE
15
-
16
- Usage: #{$0}
17
- Display information about a user
18
-
19
- -l|--rhlogin rhlogin OpenShift login (#{rhlogin})
20
- -p|--password password Password (optional, will prompt)
21
- -a|--apps List applications for rhlogin
22
- -i|--info Show user info
23
- -d|--debug Print Debug info
24
- -h|--help Show Usage info
25
- --config path Path of alternate config file
26
- --timeout # Timeout, in seconds, for the session
27
-
28
- USAGE
29
- exit error_code
30
- end
31
-
32
- begin
33
- opts = GetoptLong.new(
34
- ["--debug", "-d", GetoptLong::NO_ARGUMENT],
35
- ["--help", "-h", GetoptLong::NO_ARGUMENT],
36
- ["--apps", "-a", GetoptLong::NO_ARGUMENT],
37
- ["--info", "-i", GetoptLong::NO_ARGUMENT],
38
- ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
39
- ["--config", GetoptLong::REQUIRED_ARGUMENT],
40
- ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
41
- ["--timeout", GetoptLong::REQUIRED_ARGUMENT]
42
- )
43
- opt = {}
44
- opts.each do |o, a|
45
- opt[o[2..-1]] = a.to_s
46
- end
47
- rescue Exception => e
48
- #puts e.message
49
- p_usage
50
- end
51
-
52
- # If provided a config path, check it
53
- RHC::Config.check_cpath(opt)
54
-
55
- # Pull in configs from files
56
- libra_server = get_var('libra_server')
57
- debug = get_var('debug') == 'false' ? nil : get_var('debug')
58
-
59
- p_usage 0 if opt["help"]
60
-
61
- p_usage if 0 != ARGV.length
62
-
63
- debug = true if opt["debug"]
64
-
65
- RHC::debug(debug)
66
-
67
- RHC::timeout(opt["timeout"], get_var('timeout'))
68
- RHC::connect_timeout(opt["timeout"], get_var('timeout'))
69
-
70
- opt["rhlogin"] = get_var('default_rhlogin') unless opt["rhlogin"]
71
-
72
- if !RHC::check_rhlogin(opt['rhlogin'])
73
- p_usage
74
- end
75
-
76
- password = opt['password']
77
- if !password
78
- password = RHC::get_password
79
- end
80
-
81
- opt['apps'] = true if not opt['info'] and not opt['apps']
82
- user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, RHC::Config.default_proxy, true)
83
-
84
- if opt['info']
85
- ssh_keys = RHC::get_ssh_keys(libra_server, opt['rhlogin'], password, RHC::Config.default_proxy)
86
-
87
- domains = user_info['user_info']['domains']
88
- num_domains = domains.length
89
-
90
- puts "User Info"
91
- puts "========="
92
- if num_domains == 0
93
- puts "Namespace: No namespaces found. You can use 'rhc domain create -n <namespace>' to create a namespace for your applications."
94
- elsif num_domains == 1
95
- puts "Namespace: #{domains[0]['namespace']}"
96
- else
97
- domains.each_index { |i| puts "Namespace(#{i}): #{domains[i]['namespace']}" }
98
- end
99
- #puts " UUID: #{user_info['user_info']['uuid']}"
100
- puts " OpenShift login: #{user_info['user_info']['rhlogin']}"
101
- puts "Primary SSH key: #{user_info['user_info']['ssh_key']}"
102
- puts "Primary SSH key type: #{user_info['user_info']['ssh_type']}" unless user_info['user_info']['ssh_type'].to_s.strip.length == 0
103
-
104
- if ssh_keys['keys'] && ssh_keys['keys'].kind_of?(Hash)
105
- puts ""
106
- puts "Additional SSH keys"
107
- puts "==================="
108
- ssh_keys['keys'].each do |name, keyval|
109
- puts "Name: #{name}"
110
- puts " Key: #{keyval['key']}"
111
- puts "Type: #{keyval['type']}"
112
- puts ""
113
- end
114
- puts "Use rhc-ctl-domain for managing additional ssh keys"
115
- end
116
-
117
- end
118
-
119
- if opt['apps']
120
- puts "\n\n" if opt['info']
121
-
122
- puts "Application Info"
123
- puts "================"
124
- unless user_info['app_info'].empty?
125
- user_info['app_info'].each do |key, val|
126
- puts key
127
- puts " Framework: #{val['framework']}"
128
- puts " Creation: #{val['creation_time']}"
129
- puts " UUID: #{val['uuid']}"
130
- puts " Git URL: ssh://#{val['uuid']}@#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/~/git/#{key}.git/"
131
- puts " Public URL: http://#{key}-#{user_info['user_info']['domains'][0]['namespace']}.#{user_info['user_info']['rhc_domain']}/"
132
- if val['aliases'] && !val['aliases'].empty?
133
- puts " Aliases: #{val['aliases'].join(', ')}"
134
- end
135
- puts ""
136
- puts " Embedded: "
137
- if val['embedded'] && !val['embedded'].empty?
138
- val['embedded'].each do |embed_key, embed_val|
139
- if embed_val.has_key?('info') && !embed_val['info'].empty?
140
- puts " #{embed_key} - #{embed_val['info']}"
141
- else
142
- puts " #{embed_key}"
143
- end
144
- end
145
- else
146
- puts " None"
147
- end
148
- puts ""
149
- end
150
- else
151
- puts "No applications found. You can use rhc-create-app to create new applications."
152
- end
153
-
154
- end
155
-
156
- exit 0
@@ -1,234 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rhc/coverage_helper'
4
-
5
- require 'rhc-common'
6
-
7
- RHC::Helpers.deprecated_command('rhc port-forward',true)
8
-
9
- #
10
- # print help
11
- #
12
- def p_usage(exit_code = 255)
13
- rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
14
- puts <<USAGE
15
-
16
- Usage: rhc port-forward
17
- Forward remote ports to the workstation
18
-
19
- -l|--rhlogin rhlogin OpenShift login (#{rhlogin})
20
- -a|--app Target application (required)
21
- -p|--password password Password (optional, will prompt)
22
- -d|--debug Print Debug info
23
- -h|--help Show Usage info
24
- --config path Path of alternate config file
25
- --timeout # Timeout, in seconds, for the session
26
-
27
- USAGE
28
- exit exit_code
29
- end
30
-
31
- begin
32
- opts = GetoptLong.new(
33
- ["--debug", "-d", GetoptLong::NO_ARGUMENT],
34
- ["--help", "-h", GetoptLong::NO_ARGUMENT],
35
- ["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
36
- ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
37
- ["--config", GetoptLong::REQUIRED_ARGUMENT],
38
- ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
39
- ["--timeout", GetoptLong::REQUIRED_ARGUMENT]
40
- )
41
- opt = {}
42
- opts.each do |o, a|
43
- opt[o[2..-1]] = a.to_s
44
- end
45
- rescue Exception => e
46
- #puts e.message
47
- p_usage
48
- end
49
-
50
- # If provided a config path, check it
51
- RHC::Config.check_cpath(opt)
52
-
53
- # Pull in configs from files
54
- libra_server = get_var('libra_server')
55
- debug = get_var('debug') == 'false' ? nil : get_var('debug')
56
-
57
- p_usage 0 if opt['help']
58
-
59
- p_usage if !opt['app'] || 0 != ARGV.length
60
-
61
- debug = true if opt['debug']
62
-
63
- RHC::debug(debug)
64
-
65
- RHC::timeout(opt["timeout"], get_var('timeout'))
66
- RHC::connect_timeout(opt["timeout"], get_var('timeout'))
67
-
68
- opt['rhlogin'] = get_var('default_rhlogin') unless opt['rhlogin']
69
-
70
- if !RHC::check_rhlogin(opt['rhlogin'])
71
- p_usage
72
- end
73
-
74
- password = opt['password']
75
- if !password
76
- password = RHC::get_password
77
- end
78
-
79
- user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, RHC::Config.default_proxy, false)
80
-
81
- app_name = opt['app']
82
-
83
- unless user_info['app_info'][app_name]
84
- puts
85
- puts "Could not find app '#{app_name}'. Please run rhc-domain-info to get a list"
86
- puts "of your current running applications"
87
- puts
88
- exit 101
89
- end
90
-
91
- if (user_info['app_info'][app_name].has_key?('embedded') && user_info['app_info'][app_name]['embedded'].keys.any?{ |k| k =~ /\Ahaproxy/ })
92
- puts
93
- puts "This utility does not currently support scaled applications.\n"
94
- puts "You will need to set up port forwarding manually.\n"
95
- puts
96
- exit 101
97
- end
98
-
99
- # mock for windows
100
- if defined?(UNIXServer) != 'constant' or UNIXServer.class != Class
101
- class UNIXServer; end
102
- end
103
-
104
- app_uuid = user_info['app_info'][app_name]['uuid']
105
- namespace = user_info['user_info']['domains'][0]['namespace']
106
- rhc_domain = user_info['user_info']['rhc_domain']
107
- ssh_host = "#{app_name}-#{namespace}.#{rhc_domain}"
108
-
109
- puts "Checking available ports..."
110
-
111
- ip_and_port_simple_regex = /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}/
112
-
113
- hosts_and_ports = []
114
- hosts_and_ports_descriptions = []
115
- scaled_uuids = []
116
-
117
- puts "Using #{app_uuid}@#{ssh_host}..." if debug
118
-
119
- Net::SSH.start(ssh_host, app_uuid) do |ssh|
120
-
121
- ssh.exec! "rhc-list-ports" do |channel, stream, data|
122
-
123
- if stream == :stderr
124
-
125
- data.lines { |line|
126
-
127
- line = line.chomp
128
-
129
- if line.downcase =~ /permission denied/
130
- puts line
131
- exit 1
132
- end
133
-
134
- if line.index(ip_and_port_simple_regex)
135
- hosts_and_ports_descriptions << line
136
- end
137
- }
138
-
139
- else
140
-
141
- data.lines { |line|
142
-
143
- line = line.chomp
144
-
145
- if line.downcase =~ /scale/
146
- scaled_uuid = line[5..-1]
147
- scaled_uuids << scaled_uuid
148
-
149
- else
150
- if ip_and_port_simple_regex.match(line)
151
- hosts_and_ports << line
152
- end
153
- end
154
- }
155
-
156
- end
157
-
158
- end
159
-
160
- scaled_uuids.each { |scaled_uuid|
161
-
162
- puts "Using #{scaled_uuid}@#{ssh_host} (scaled instance)..." if debug
163
-
164
- Net::SSH.start(ssh_host, scaled_uuid) do |ssh|
165
-
166
- ssh.exec! "rhc-list-ports" do |channel, stream, data|
167
- if stream == :stderr
168
- data.lines { |line|
169
-
170
- line = line.chomp
171
- if line.downcase =~ /permission denied/
172
- puts line
173
- exit 1
174
- end
175
- if line.index(ip_and_port_simple_regex)
176
- hosts_and_ports_descriptions << line
177
- end
178
- }
179
- else
180
- data.lines { |line|
181
-
182
- line = line.chomp
183
- if ip_and_port_simple_regex.match(line)
184
- hosts_and_ports << line
185
- end
186
- }
187
- end
188
- end
189
- end
190
- }
191
-
192
- if hosts_and_ports.length == 0
193
- puts
194
- puts "No available ports to forward"
195
- exit 102
196
- end
197
-
198
- puts
199
-
200
- hosts_and_ports_descriptions.each { |description| puts "Binding #{description}..." }
201
-
202
- begin
203
-
204
- Net::SSH.start(ssh_host, app_uuid) do |ssh|
205
- puts "Use ctl + c to stop"
206
- hosts_and_ports.each do |host_and_port|
207
- host, port = host_and_port.split(/:/)
208
- ssh.forward.local(host, port.to_i, host, port.to_i)
209
- end
210
- ssh.loop { true }
211
- end
212
-
213
- rescue Interrupt
214
- puts
215
- puts "Terminating..."
216
- exit 0
217
-
218
- rescue Exception => e
219
- puts
220
- puts e.message if debug
221
- puts "Error trying to forward ports. You can try to forward manually by running:"
222
- ssh_cmd = "ssh -N "
223
- hosts_and_ports.each { |port| ssh_cmd << "-L #{port}:#{port} " }
224
- ssh_cmd << "#{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain}"
225
- puts
226
- puts ssh_cmd
227
- puts
228
- exit 1
229
- end
230
-
231
- end
232
-
233
- # never
234
- exit 1
@@ -1,109 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rhc/coverage_helper'
4
-
5
- require 'rhc-common'
6
-
7
- puts "Warning: This command is deprecated and will be removed in the future. Please use 'rhc snapshot' instead."
8
- puts""
9
-
10
- #
11
- # print help
12
- #
13
- def p_usage(exit_code = 255)
14
- rhlogin = get_var('default_rhlogin') ? "Default: #{get_var('default_rhlogin')}" : "required"
15
- puts <<USAGE
16
-
17
- Usage: #{$0}
18
- Pull down application snapshot for a user
19
-
20
- -l|--rhlogin rhlogin OpenShift login (#{rhlogin})
21
- -a|--app Target application to snapshot (required)
22
- -r|--restore Local path of the tarball to restore (restores git and application data folders found in archive)
23
- -s|--save Local path to save tarball (default: ./$APPNAME.tar.gz)
24
- -p|--password password Password (optional, will prompt)
25
- -d|--debug Print Debug info
26
- -h|--help Show Usage info
27
- --config path Path of alternate config file
28
- --timeout # Timeout, in seconds, for the session
29
-
30
- USAGE
31
- exit exit_code
32
- end
33
-
34
- begin
35
- opts = GetoptLong.new(
36
- ["--debug", "-d", GetoptLong::NO_ARGUMENT],
37
- ["--help", "-h", GetoptLong::NO_ARGUMENT],
38
- ["--app", "-a", GetoptLong::REQUIRED_ARGUMENT],
39
- ["--save", "-s", GetoptLong::REQUIRED_ARGUMENT],
40
- ["--restore", "-r", GetoptLong::REQUIRED_ARGUMENT],
41
- ["--rhlogin", "-l", GetoptLong::REQUIRED_ARGUMENT],
42
- ["--config", GetoptLong::REQUIRED_ARGUMENT],
43
- ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT],
44
- ["--timeout", GetoptLong::REQUIRED_ARGUMENT]
45
- )
46
- opt = {}
47
- opts.each do |o, a|
48
- opt[o[2..-1]] = a.to_s
49
- end
50
- rescue Exception => e
51
- #puts e.message
52
- p_usage
53
- end
54
-
55
- # If provided a config path, check it
56
- RHC::Config.check_cpath(opt)
57
-
58
- # Pull in configs from files
59
- libra_server = get_var('libra_server')
60
- debug = get_var('debug') == 'false' ? nil : get_var('debug')
61
-
62
- p_usage 0 if opt["help"]
63
-
64
- p_usage if !opt['app'] || 0 != ARGV.length
65
-
66
- debug = true if opt["debug"]
67
-
68
- RHC::debug(debug)
69
-
70
- RHC::timeout(opt["timeout"], get_var('timeout'))
71
- RHC::connect_timeout(opt["timeout"], get_var('timeout'))
72
-
73
- opt["rhlogin"] = get_var('default_rhlogin') unless opt["rhlogin"]
74
-
75
- if !RHC::check_rhlogin(opt['rhlogin'])
76
- p_usage
77
- end
78
-
79
- password = opt['password']
80
- if !password
81
- password = RHC::get_password
82
- end
83
-
84
- user_info = RHC::get_user_info(libra_server, opt['rhlogin'], password, RHC::Config.default_proxy, debug, false)
85
-
86
- app = opt['app']
87
- opt['save'] = "#{opt['app']}.tar.gz" unless opt['save'] || opt['restore']
88
-
89
- unless user_info['app_info'][app]
90
- puts
91
- puts "Could not find app '#{app}'. Please run rhc-domain-info to get a list"
92
- puts "of your current running applications"
93
- puts
94
- exit 101
95
- end
96
-
97
- app_uuid = user_info['app_info'][app]['uuid']
98
- namespace = user_info['user_info']['domains'][0]['namespace']
99
- rhc_domain = user_info['user_info']['rhc_domain']
100
-
101
- if opt['save']
102
- status = RHC.snapshot_create rhc_domain, namespace, app, app_uuid, opt['save'], debug
103
- exit status if ! status
104
- else
105
- status = RHC.snapshot_restore rhc_domain, namespace, app, app_uuid, opt['restore'], debug
106
- exit status if ! status
107
- end
108
-
109
- exit 0