rhc 0.82.18 → 0.83.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rhc-ctl-app +6 -3
- data/lib/rhc-common.rb +82 -10
- metadata +10 -10
data/bin/rhc-ctl-app
CHANGED
@@ -35,7 +35,7 @@ Control an OpenShift express app
|
|
35
35
|
-a|--app application Application name (alphanumeric) (required)
|
36
36
|
-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (#{rhlogin})
|
37
37
|
-p|--password password RHLogin password (optional, will prompt)
|
38
|
-
-c|--command command (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias)
|
38
|
+
-c|--command command (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)
|
39
39
|
-L|--embedded-list List supported embedded cartridges
|
40
40
|
-e|--embed (add|remove|stop|start|restart|status|reload)-$cartridge eg: add-mysql-5.1
|
41
41
|
-b|--bypass Bypass warnings
|
@@ -123,8 +123,8 @@ unless opt["embed"] or opt["command"]
|
|
123
123
|
end
|
124
124
|
|
125
125
|
if opt["command"]
|
126
|
-
unless opt["command"] =~ /^(start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias)$/
|
127
|
-
puts "Invalid command '#{opt["command"]}' specified. Valid commands are (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias)"
|
126
|
+
unless opt["command"] =~ /^(start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)$/
|
127
|
+
puts "Invalid command '#{opt["command"]}' specified. Valid commands are (start|stop|force-stop|restart|reload|status|destroy|tidy|add-alias|remove-alias|threaddump)"
|
128
128
|
p_usage
|
129
129
|
end
|
130
130
|
elsif opt["embed"]
|
@@ -144,6 +144,9 @@ if opt['command'] and (opt['alias'] and !(opt['command'] =~ /-alias$/)) || ((opt
|
|
144
144
|
p_usage
|
145
145
|
end
|
146
146
|
|
147
|
+
if opt["command"] == "threaddump"
|
148
|
+
print "NOTE: The threaddump command is only applicable to applications of type jbossas-7.0. The thread dump file will be available via 'rhc-tail-files -f app-name/jbossas-7.0/stdout.log'"
|
149
|
+
end
|
147
150
|
|
148
151
|
password = opt['password']
|
149
152
|
if !password
|
data/lib/rhc-common.rb
CHANGED
@@ -26,6 +26,8 @@ require 'getoptlong'
|
|
26
26
|
require 'json'
|
27
27
|
require 'net/http'
|
28
28
|
require 'net/https'
|
29
|
+
#require 'net/ssh'
|
30
|
+
require 'open3'
|
29
31
|
require 'parseconfig'
|
30
32
|
require 'resolv'
|
31
33
|
require 'uri'
|
@@ -38,10 +40,11 @@ module RHC
|
|
38
40
|
MAX_RETRIES = 7
|
39
41
|
DEFAULT_DELAY = 2
|
40
42
|
API = "1.1.1"
|
43
|
+
PATTERN_VERSION=/\A\d+\.\d+\.\d+\z/
|
41
44
|
@mytimeout = 10
|
42
45
|
@mydebug = false
|
43
|
-
broker_version = "?.?.?"
|
44
|
-
api_version = "?.?.?"
|
46
|
+
@@broker_version = "?.?.?"
|
47
|
+
@@api_version = "?.?.?"
|
45
48
|
|
46
49
|
# reset lines
|
47
50
|
# \r moves the cursor to the beginning of line
|
@@ -75,11 +78,19 @@ module RHC
|
|
75
78
|
end
|
76
79
|
|
77
80
|
def self.update_server_api_v(dict)
|
78
|
-
if !dict['broker'].nil? && (dict['broker'] =~
|
79
|
-
broker_version = dict['broker']
|
81
|
+
if !dict['broker'].nil? && (dict['broker'] =~ PATTERN_VERSION)
|
82
|
+
@@broker_version = dict['broker']
|
80
83
|
end
|
81
|
-
if !dict['api'].nil? && (dict['api'] =~
|
82
|
-
api_version = dict['api']
|
84
|
+
if !dict['api'].nil? && (dict['api'] =~ PATTERN_VERSION)
|
85
|
+
@@api_version = dict['api']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.check_version
|
90
|
+
if @@api_version =~ PATTERN_VERSION
|
91
|
+
if API != @@api_version
|
92
|
+
puts "\nNOTICE: Client API version (#{API}) does not match the server (#{@@api_version}).\nThough requests may succeed, you should consider updating your client tools.\n\n"
|
93
|
+
end
|
83
94
|
end
|
84
95
|
end
|
85
96
|
|
@@ -283,8 +294,6 @@ module RHC
|
|
283
294
|
end
|
284
295
|
exit_code = 1
|
285
296
|
if response.content_type == 'application/json'
|
286
|
-
print "JSON response:"
|
287
|
-
$stdout.flush
|
288
297
|
begin
|
289
298
|
json_resp = JSON.parse(response.body)
|
290
299
|
exit_code = print_json_body(json_resp)
|
@@ -432,6 +441,9 @@ module RHC
|
|
432
441
|
puts
|
433
442
|
end
|
434
443
|
|
444
|
+
# construct the Git URL
|
445
|
+
git_url = "ssh://#{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain}/~/git/#{app_name}.git/"
|
446
|
+
|
435
447
|
# If the hostname couldn't be resolved, print out the git URL
|
436
448
|
# and exit cleanly. This will help solve issues where DNS times
|
437
449
|
# out in APAC, etc on resolution.
|
@@ -473,8 +485,6 @@ WARNING
|
|
473
485
|
# Pull new repo locally
|
474
486
|
#
|
475
487
|
|
476
|
-
git_url = "ssh://#{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain}/~/git/#{app_name}.git/"
|
477
|
-
|
478
488
|
unless no_git
|
479
489
|
puts "Pulling new repo down" if @mydebug
|
480
490
|
|
@@ -599,6 +609,62 @@ LOOKSGOOD
|
|
599
609
|
http_post(net_http, url, json_data, password)
|
600
610
|
end
|
601
611
|
|
612
|
+
# Runs rhc-list-ports on server to check available ports
|
613
|
+
# :stderr return user-friendly port name, :stdout returns 127.0.0.1:8080 format
|
614
|
+
def self.list_ports(rhc_domain, namespace, app_name, app_uuid, debug=true)
|
615
|
+
|
616
|
+
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}/
|
617
|
+
|
618
|
+
ssh_host = "#{app_name}-#{namespace}.#{rhc_domain}"
|
619
|
+
|
620
|
+
ssh_cmd = "ssh -t #{app_uuid}@#{ssh_host} 'rhc-list-ports'"
|
621
|
+
|
622
|
+
hosts_and_ports = []
|
623
|
+
hosts_and_ports_descriptions = []
|
624
|
+
|
625
|
+
puts ssh_cmd if debug
|
626
|
+
|
627
|
+
Open3.popen3(ssh_cmd) { |stdin, stdout, stderr|
|
628
|
+
|
629
|
+
stdout.each { |line|
|
630
|
+
line = line.chomp
|
631
|
+
if ip_and_port_simple_regex.match(line)
|
632
|
+
hosts_and_ports << line
|
633
|
+
end
|
634
|
+
}
|
635
|
+
|
636
|
+
stderr.each { |line|
|
637
|
+
line = line.chomp
|
638
|
+
if line.index(ip_and_port_simple_regex)
|
639
|
+
hosts_and_ports_descriptions << line
|
640
|
+
end
|
641
|
+
}
|
642
|
+
|
643
|
+
}
|
644
|
+
|
645
|
+
#hosts_and_ports_descriptions = stderr.gets.chomp.split(/\n/)
|
646
|
+
#hosts_and_ports = stdout.gets.chomp.split(/\n/)
|
647
|
+
|
648
|
+
# Net::SSH.start(ssh_host, app_uuid) do |ssh|
|
649
|
+
|
650
|
+
# ssh.exec!("rhc-list-ports") do |channel, stream, data|
|
651
|
+
|
652
|
+
# array = data.split(/\n/)
|
653
|
+
|
654
|
+
# if stream == :stderr
|
655
|
+
# hosts_and_ports_descriptions = array
|
656
|
+
# elsif stream == :stdout
|
657
|
+
# hosts_and_ports = array
|
658
|
+
# end
|
659
|
+
|
660
|
+
# end
|
661
|
+
|
662
|
+
# end
|
663
|
+
|
664
|
+
return hosts_and_ports, hosts_and_ports_descriptions
|
665
|
+
|
666
|
+
end
|
667
|
+
|
602
668
|
def self.ctl_app(libra_server, net_http, app_name, rhlogin, password, action, embedded=false, framework=nil, server_alias=nil, print_result=true)
|
603
669
|
data = {:action => action,
|
604
670
|
:app_name => app_name,
|
@@ -634,6 +700,12 @@ LOOKSGOOD
|
|
634
700
|
|
635
701
|
end
|
636
702
|
|
703
|
+
# provide a hook for performing actions before rhc-* commands exit
|
704
|
+
at_exit {
|
705
|
+
# ensure client tools are up to date
|
706
|
+
RHC::check_version
|
707
|
+
}
|
708
|
+
|
637
709
|
#
|
638
710
|
# Config paths... /etc/openshift/express.conf or $GEM/conf/express.conf -> ~/.openshift/express.conf
|
639
711
|
#
|
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: 321
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 83
|
9
|
+
- 9
|
10
|
+
version: 0.83.9
|
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-12-
|
18
|
+
date: 2011-12-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json_pure
|
@@ -61,13 +61,13 @@ extra_rdoc_files: []
|
|
61
61
|
|
62
62
|
files:
|
63
63
|
- lib/rhc-common.rb
|
64
|
-
- bin/rhc-create-app
|
65
|
-
- bin/rhc-chk
|
66
|
-
- bin/rhc-user-info
|
67
|
-
- bin/rhc-create-domain
|
68
|
-
- bin/rhc-snapshot
|
69
64
|
- bin/rhc-ctl-app
|
70
65
|
- bin/rhc-tail-files
|
66
|
+
- bin/rhc-user-info
|
67
|
+
- bin/rhc-snapshot
|
68
|
+
- bin/rhc-chk
|
69
|
+
- bin/rhc-create-app
|
70
|
+
- bin/rhc-create-domain
|
71
71
|
- conf/express.conf
|
72
72
|
- LICENSE
|
73
73
|
- README
|