rhc 0.96.9 → 0.97.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/bin/rhc +6 -18
- data/bin/rhc-app +3 -3
- data/bin/rhc-chk +2 -2
- data/bin/rhc-create-app +2 -2
- data/bin/rhc-create-domain +5 -2
- data/bin/rhc-ctl-app +2 -2
- data/bin/rhc-ctl-domain +5 -2
- data/bin/rhc-domain +6 -3
- data/bin/rhc-domain-info +6 -3
- data/bin/rhc-port-forward +9 -2
- data/bin/rhc-snapshot +2 -2
- data/bin/rhc-sshkey +2 -2
- data/bin/rhc-tail-files +2 -2
- data/features/lib/rhc_helper/app.rb +1 -1
- data/features/lib/rhc_helper/commandify.rb +32 -3
- data/features/lib/rhc_helper/domain.rb +46 -20
- data/features/step_definitions/cartridge_steps.rb +3 -3
- data/features/step_definitions/client_steps.rb +3 -1
- data/features/step_definitions/domain_steps.rb +45 -0
- data/features/verify.feature +36 -0
- data/lib/rhc-common.rb +6 -8
- data/lib/rhc-rest.rb +11 -2
- data/lib/rhc-rest/application.rb +20 -8
- data/lib/rhc-rest/cartridge.rb +18 -6
- data/lib/rhc-rest/client.rb +13 -37
- data/lib/rhc-rest/domain.rb +12 -4
- data/lib/rhc-rest/exceptions/exceptions.rb +1 -1
- data/lib/rhc-rest/key.rb +2 -2
- data/lib/rhc-rest/user.rb +2 -2
- data/lib/rhc/cli.rb +2 -3
- data/lib/rhc/commands.rb +154 -4
- data/lib/rhc/commands/base.rb +49 -12
- data/lib/rhc/commands/domain.rb +142 -0
- data/lib/rhc/commands/server.rb +1 -0
- data/lib/rhc/commands/setup.rb +3 -10
- data/lib/rhc/config.rb +20 -18
- data/lib/rhc/exceptions.rb +20 -0
- data/lib/rhc/help_formatter.rb +3 -22
- data/lib/rhc/helpers.rb +36 -5
- data/lib/rhc/json.rb +44 -44
- data/lib/rhc/targz.rb +3 -3
- data/lib/rhc/usage_templates/command_help.erb +26 -0
- data/lib/rhc/usage_templates/help.erb +27 -0
- data/lib/rhc/vendor/zliby.rb +563 -563
- data/lib/rhc/version.rb +2 -2
- data/lib/rhc/wizard.rb +10 -5
- data/spec/coverage_helper.rb +0 -1
- data/spec/rest_spec_helper.rb +95 -0
- data/spec/rhc/cli_spec.rb +7 -2
- data/spec/rhc/command_spec.rb +59 -13
- data/spec/rhc/commands/domain_spec.rb +225 -0
- data/spec/rhc/config_spec.rb +4 -4
- data/spec/rhc/helpers_spec.rb +27 -1
- data/spec/rhc/rest_application_spec.rb +6 -0
- data/spec/rhc/rest_client_spec.rb +32 -32
- data/spec/rhc/rest_spec.rb +2 -2
- data/spec/rhc/wizard_spec.rb +11 -4
- data/spec/spec_helper.rb +9 -9
- metadata +314 -312
@@ -1,8 +1,44 @@
|
|
1
1
|
include RHCHelper
|
2
|
+
|
3
|
+
And /^an existing domain$/ do
|
4
|
+
$namespace.nil?.should be_false, 'No existing namespace to alter'
|
5
|
+
end
|
6
|
+
|
7
|
+
And /^given domains is empty$/ do
|
8
|
+
$namespace.nil?.should be_true
|
9
|
+
end
|
10
|
+
|
2
11
|
When /^a new domain is needed and created$/ do
|
3
12
|
Domain.create_if_needed
|
4
13
|
end
|
5
14
|
|
15
|
+
When /^domain is updated$/ do
|
16
|
+
Domain.update
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^domain is deleted$/ do
|
20
|
+
Domain.delete
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^rhc domain (.*)is run$/ do |action|
|
24
|
+
action.rstrip!
|
25
|
+
cmd = "rhc_domain"
|
26
|
+
cmd += "_#{action}" if action.length > 0
|
27
|
+
Domain.send(:"#{cmd}")
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^the default domain action output should equal the show action output$/ do
|
31
|
+
Domain.domain_output.should match($namespace)
|
32
|
+
|
33
|
+
domain_output = Domain.domain_output.lines
|
34
|
+
domain_show_output = Domain.domain_show_output.lines
|
35
|
+
|
36
|
+
# check line by line while ignoring debug output which is timestamped
|
37
|
+
domain_output.zip(domain_show_output) do |a, b|
|
38
|
+
a.should == b unless a.match("DEBUG")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
6
42
|
Then /^the domain should be reserved?$/ do
|
7
43
|
# Sleep to allow DNS to propogate
|
8
44
|
sleep 5
|
@@ -17,3 +53,12 @@ Then /^the domain should be reserved?$/ do
|
|
17
53
|
|
18
54
|
resolved.should be_true, 'Not able to lookup DNS TXT record in time.'
|
19
55
|
end
|
56
|
+
|
57
|
+
Then /^the domain command should fail with an exitcode of (\d*)$/ do |exitcode|
|
58
|
+
exitcode = exitcode.to_i
|
59
|
+
Domain.exitcode.should == exitcode
|
60
|
+
end
|
61
|
+
|
62
|
+
Then /^domains should be empty$/ do
|
63
|
+
$namespace.should be_nil
|
64
|
+
end
|
data/features/verify.feature
CHANGED
@@ -11,7 +11,43 @@ Feature: Client Integration Tests
|
|
11
11
|
When a new domain is needed and created
|
12
12
|
Then the domain should be reserved
|
13
13
|
|
14
|
+
Scenario: Domain Update
|
15
|
+
Given the libra client tools
|
16
|
+
And an existing domain
|
17
|
+
When domain is updated
|
18
|
+
Then the domain should be reserved
|
19
|
+
|
20
|
+
Scenario: Domain Show
|
21
|
+
Given the libra client tools
|
22
|
+
And an existing domain
|
23
|
+
When rhc domain is run
|
24
|
+
When rhc domain show is run
|
25
|
+
Then the default domain action output should equal the show action output
|
26
|
+
|
27
|
+
Scenario: Domain Create Fails
|
28
|
+
Given the libra client tools
|
29
|
+
And an existing domain
|
30
|
+
When rhc domain create is called
|
31
|
+
Then the domain command should fail with an exitcode of 128
|
32
|
+
|
33
|
+
Scenario: Domain Delete
|
34
|
+
Given the libra client tools
|
35
|
+
And an existing domain
|
36
|
+
When domain is deleted
|
37
|
+
Then domains should be empty
|
38
|
+
|
39
|
+
Scenario: Domain Update Fails
|
40
|
+
Given the libra client tools
|
41
|
+
And given domains is empty
|
42
|
+
When domain is updated
|
43
|
+
Then the domain command should fail with an exitcode of 127
|
44
|
+
|
14
45
|
@init
|
46
|
+
Scenario: Domain Creation for Apps
|
47
|
+
Given the libra client tools
|
48
|
+
When a new domain is needed and created
|
49
|
+
Then the domain should be reserved
|
50
|
+
|
15
51
|
Scenario: Application Creation
|
16
52
|
Given the libra client tools
|
17
53
|
When 1 php-5.3 applications are created
|
data/lib/rhc-common.rb
CHANGED
@@ -150,11 +150,11 @@ end
|
|
150
150
|
def self.check_rhlogin(rhlogin)
|
151
151
|
if rhlogin
|
152
152
|
if rhlogin =~ /["\$\^<>\|%\/;:,\\\*=~]/
|
153
|
-
puts '
|
153
|
+
puts 'OpenShift login may not contain any of these characters: (\") ($) (^) (<) (>) (|) (%) (/) (;) (:) (,) (\) (*) (=) (~)'
|
154
154
|
return false
|
155
155
|
end
|
156
156
|
else
|
157
|
-
puts "
|
157
|
+
puts "OpenShift login is required"
|
158
158
|
return false
|
159
159
|
end
|
160
160
|
true
|
@@ -319,7 +319,7 @@ end
|
|
319
319
|
tempfile = `mktemp /tmp/openshift.XXXXXXXX`
|
320
320
|
`echo "#{ssh_keys['ssh_type']} #{ssh_keys['ssh_key']}" > #{tempfile}`
|
321
321
|
ssh_keys['fingerprint'] = `ssh-keygen -lf #{tempfile}`.split(' ')[1]
|
322
|
-
rescue Net::SSH::Exception, NotImplementedError
|
322
|
+
rescue Net::SSH::Exception, NotImplementedError, OpenSSL::PKey::PKeyError
|
323
323
|
# Could be a new unsupported key type or invalid data on the server
|
324
324
|
ssh_keys['fingerprint'] = 'Key type is not recognized. Please check this key is valid.'
|
325
325
|
end
|
@@ -511,7 +511,7 @@ end
|
|
511
511
|
end_point = "https://#{libra_server}/broker/rest/api"
|
512
512
|
client = Rhc::Rest::Client.new(end_point, rhlogin, password)
|
513
513
|
|
514
|
-
domain = client.find_domain(user_info['user_info']['domains'][0]['namespace'])
|
514
|
+
domain = client.find_domain(user_info['user_info']['domains'][0]['namespace'])
|
515
515
|
|
516
516
|
namespace = domain.id
|
517
517
|
# Catch errors
|
@@ -1229,10 +1229,8 @@ end
|
|
1229
1229
|
# nil of there was an error
|
1230
1230
|
#
|
1231
1231
|
def default_setup_wizard
|
1232
|
-
|
1233
|
-
|
1234
|
-
return w.run
|
1235
|
-
end
|
1232
|
+
w = RHC::Wizard.new(RHC::Config)
|
1233
|
+
return w.run if w.needs_configuration?
|
1236
1234
|
|
1237
1235
|
false
|
1238
1236
|
end
|
data/lib/rhc-rest.rb
CHANGED
@@ -62,6 +62,13 @@ module Rhc
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def new_request(options)
|
66
|
+
# user specified timeout takes presidence
|
67
|
+
options[:timeout] = $rest_timeout || options[:timeout]
|
68
|
+
|
69
|
+
RestClient::Request.new options
|
70
|
+
end
|
71
|
+
|
65
72
|
def request(request)
|
66
73
|
begin
|
67
74
|
response = request.execute
|
@@ -71,8 +78,10 @@ module Rhc
|
|
71
78
|
@@headers["cookie"] = "rh_sso=#{rh_sso}"
|
72
79
|
end
|
73
80
|
return parse_response(response) unless response.nil? or response.code == 204
|
74
|
-
rescue RestClient::RequestTimeout
|
75
|
-
raise
|
81
|
+
rescue RestClient::RequestTimeout => e
|
82
|
+
raise TimeoutException.new("Connection to server timed out. It is possible the operation finished without being able to report success. Use 'rhc domain show' or 'rhc app status' to check the status of your applications.")
|
83
|
+
rescue RestClient::ServerBrokeConnection => e
|
84
|
+
raise ConnectionException.new("Connection to server got interrupted: #{e.message}")
|
76
85
|
rescue RestClient::ExceptionWithResponse => e
|
77
86
|
process_error_response(e.response)
|
78
87
|
rescue Exception => e
|
data/lib/rhc-rest/application.rb
CHANGED
@@ -3,7 +3,8 @@ module Rhc
|
|
3
3
|
module Rest
|
4
4
|
class Application
|
5
5
|
include Rest
|
6
|
-
attr_reader :domain_id, :name, :creation_time, :uuid, :aliases, :git_url, :app_url, :
|
6
|
+
attr_reader :domain_id, :name, :creation_time, :uuid, :aliases, :git_url, :app_url, :gear_profile, :framework,
|
7
|
+
:scalable, :health_check_path, :embedded, :gear_count, :ssh_url, :scale_min, :scale_max
|
7
8
|
def initialize(args)
|
8
9
|
#logger.debug args
|
9
10
|
@domain_id = args[:domain_id] || args["domain_id"]
|
@@ -11,8 +12,19 @@ module Rhc
|
|
11
12
|
@creation_time = args[:creation_time] || args["creation_time"]
|
12
13
|
@uuid = args[:uuid] || args["uuid"]
|
13
14
|
@aliases = args[:aliases] || args["aliases"]
|
14
|
-
@
|
15
|
+
@git_url = args[:git_url] || args["git_url"]
|
16
|
+
@app_url = args[:app_url] || args["app_url"]
|
17
|
+
@gear_profile = args[:gear_profile] || args["gear_profile"]
|
18
|
+
@framework = args[:framework] || args["framework"]
|
19
|
+
@scalable = args[:scalable] || args["scalable"]
|
20
|
+
@health_check_path = args[:health_check_path] || args["health_check_path"]
|
21
|
+
@embedded = args[:embedded] || args["embedded"]
|
22
|
+
@gear_count = args[:gear_count] || args["gear_count"]
|
23
|
+
@ssh_url = args[:ssh_url] || args["ssh_url"]
|
24
|
+
@scale_min = args[:scale_min] || args["scale_min"]
|
25
|
+
@scale_max = args[:scale_max] || args["scale_max"]
|
15
26
|
@links = args[:links] || args["links"]
|
27
|
+
|
16
28
|
end
|
17
29
|
|
18
30
|
#Add Cartridge
|
@@ -21,7 +33,7 @@ module Rhc
|
|
21
33
|
url = @links['ADD_CARTRIDGE']['href']
|
22
34
|
method = @links['ADD_CARTRIDGE']['method']
|
23
35
|
payload = {:name => name}
|
24
|
-
request =
|
36
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
25
37
|
return request(request)
|
26
38
|
end
|
27
39
|
|
@@ -30,7 +42,7 @@ module Rhc
|
|
30
42
|
logger.debug "Getting all cartridges for application #{self.name}" if @mydebug
|
31
43
|
url = @links['LIST_CARTRIDGES']['href']
|
32
44
|
method = @links['LIST_CARTRIDGES']['method']
|
33
|
-
request =
|
45
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
34
46
|
return request(request)
|
35
47
|
end
|
36
48
|
|
@@ -40,7 +52,7 @@ module Rhc
|
|
40
52
|
url = @links['START']['href']
|
41
53
|
method = @links['START']['method']
|
42
54
|
payload = {:event=> "start"}
|
43
|
-
request =
|
55
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
44
56
|
return request(request)
|
45
57
|
end
|
46
58
|
|
@@ -54,7 +66,7 @@ module Rhc
|
|
54
66
|
else
|
55
67
|
payload = {:event=> "stop"}
|
56
68
|
end
|
57
|
-
request =
|
69
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
58
70
|
return request(request)
|
59
71
|
end
|
60
72
|
|
@@ -64,7 +76,7 @@ module Rhc
|
|
64
76
|
url = @links['RESTART']['href']
|
65
77
|
method = @links['RESTART']['method']
|
66
78
|
payload = {:event=> "restart"}
|
67
|
-
request =
|
79
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
68
80
|
return request(request)
|
69
81
|
end
|
70
82
|
|
@@ -73,7 +85,7 @@ module Rhc
|
|
73
85
|
logger.debug "Deleting application #{self.name}" if @mydebug
|
74
86
|
url = @links['DELETE']['href']
|
75
87
|
method = @links['DELETE']['method']
|
76
|
-
request =
|
88
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
77
89
|
return request(request)
|
78
90
|
end
|
79
91
|
alias :delete :destroy
|
data/lib/rhc-rest/cartridge.rb
CHANGED
@@ -2,11 +2,23 @@ module Rhc
|
|
2
2
|
module Rest
|
3
3
|
class Cartridge
|
4
4
|
include Rest
|
5
|
-
attr_reader :type, :name
|
5
|
+
attr_reader :type, :name, :properties
|
6
6
|
def initialize(args)
|
7
7
|
@name = args[:name] || args["name"]
|
8
8
|
@type = args[:type] || args["type"]
|
9
9
|
@links = args[:links] || args["links"]
|
10
|
+
@properties = {}
|
11
|
+
props = args[:properties] || args["properties"] || []
|
12
|
+
props.each do |p|
|
13
|
+
category = @properties[:"#{p['type']}"] || {}
|
14
|
+
category[:"#{p['name']}"] = p
|
15
|
+
@properties[:"#{p['type']}"] = category
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def property(category, key)
|
20
|
+
category = properties[category]
|
21
|
+
category ? category[key] : nil
|
10
22
|
end
|
11
23
|
|
12
24
|
#Start Cartridge
|
@@ -15,7 +27,7 @@ module Rhc
|
|
15
27
|
url = @links['START']['href']
|
16
28
|
method = @links['START']['method']
|
17
29
|
payload = {:event=> "start"}
|
18
|
-
request =
|
30
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
19
31
|
return request(request)
|
20
32
|
end
|
21
33
|
|
@@ -25,7 +37,7 @@ module Rhc
|
|
25
37
|
url = @links['STOP']['href']
|
26
38
|
method = @links['STOP']['method']
|
27
39
|
payload = {:event=> "stop"}
|
28
|
-
request =
|
40
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
29
41
|
return request(request)
|
30
42
|
end
|
31
43
|
|
@@ -35,7 +47,7 @@ module Rhc
|
|
35
47
|
url = @links['RESTART']['href']
|
36
48
|
method = @links['RESTART']['method']
|
37
49
|
payload = {:event=> "restart"}
|
38
|
-
request =
|
50
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
39
51
|
return request(request)
|
40
52
|
end
|
41
53
|
|
@@ -45,7 +57,7 @@ module Rhc
|
|
45
57
|
url = @links['RESTART']['href']
|
46
58
|
method = @links['RESTART']['method']
|
47
59
|
payload = {:event=> "reload"}
|
48
|
-
request =
|
60
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
49
61
|
return request(request)
|
50
62
|
end
|
51
63
|
|
@@ -54,7 +66,7 @@ module Rhc
|
|
54
66
|
logger.debug "Deleting cartridge #{self.name}" if @mydebug
|
55
67
|
url = @links['DELETE']['href']
|
56
68
|
method = @links['DELETE']['method']
|
57
|
-
request =
|
69
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
58
70
|
return request(request)
|
59
71
|
end
|
60
72
|
alias :delete :destroy
|
data/lib/rhc-rest/client.rb
CHANGED
@@ -5,14 +5,16 @@ module Rhc
|
|
5
5
|
module Rest
|
6
6
|
class Client
|
7
7
|
include Rest
|
8
|
-
def initialize(end_point, username, password)
|
8
|
+
def initialize(end_point, username, password, debug=false)
|
9
|
+
# use mydebug for legacy reasons
|
10
|
+
@mydebug = @mydebug || debug
|
9
11
|
logger.debug "Connecting to #{end_point}" if @mydebug
|
10
12
|
credentials = Base64.encode64("#{username}:#{password}")
|
11
13
|
@@headers["Authorization"] = "Basic #{credentials}"
|
12
14
|
@@headers["User-Agent"] = RHC::Helpers.user_agent rescue nil
|
13
15
|
#first get the API
|
14
16
|
RestClient.proxy = ENV['http_proxy']
|
15
|
-
request =
|
17
|
+
request = new_request(:url => end_point, :method => :get, :headers => @@headers)
|
16
18
|
begin
|
17
19
|
response = request.execute
|
18
20
|
result = RHC::Json.decode(response)
|
@@ -30,7 +32,7 @@ module Rhc
|
|
30
32
|
url = @links['ADD_DOMAIN']['href']
|
31
33
|
method = @links['ADD_DOMAIN']['method']
|
32
34
|
payload = {:id => id}
|
33
|
-
request =
|
35
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
34
36
|
return request(request)
|
35
37
|
end
|
36
38
|
|
@@ -39,36 +41,16 @@ module Rhc
|
|
39
41
|
logger.debug "Getting all domains" if @mydebug
|
40
42
|
url = @links['LIST_DOMAINS']['href']
|
41
43
|
method = @links['LIST_DOMAINS']['method']
|
42
|
-
request =
|
44
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
43
45
|
return request(request)
|
44
46
|
end
|
45
47
|
|
46
48
|
#Find Domain by namesapce
|
47
49
|
def find_domain(id)
|
48
50
|
logger.debug "Finding domain #{id}" if @mydebug
|
49
|
-
|
50
|
-
domains.each do |domain|
|
51
|
-
#TODO do a regex caomparison
|
52
|
-
if domain.id == id
|
53
|
-
filtered.push(domain)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
return filtered
|
57
|
-
end
|
51
|
+
domains.each { |domain| return domain if domain.id == id }
|
58
52
|
|
59
|
-
|
60
|
-
def find_application(name)
|
61
|
-
logger.debug "Finding application #{name}" if @mydebug
|
62
|
-
filtered = Array.new
|
63
|
-
domains.each do |domain|
|
64
|
-
#TODO do a regex caomparison
|
65
|
-
domain.applications.each do |app|
|
66
|
-
if app.name == name
|
67
|
-
filtered.push(app)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
return filtered
|
53
|
+
raise RHC::DomainNotFoundException.new("Domain #{id} does not exist")
|
72
54
|
end
|
73
55
|
|
74
56
|
#Get all Cartridge
|
@@ -76,7 +58,7 @@ module Rhc
|
|
76
58
|
logger.debug "Getting all cartridges" if @mydebug
|
77
59
|
url = @links['LIST_CARTRIDGES']['href']
|
78
60
|
method = @links['LIST_CARTRIDGES']['method']
|
79
|
-
request =
|
61
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
80
62
|
return request(request)
|
81
63
|
end
|
82
64
|
|
@@ -85,7 +67,6 @@ module Rhc
|
|
85
67
|
logger.debug "Finding cartridge #{name}" if @mydebug
|
86
68
|
filtered = Array.new
|
87
69
|
cartridges.each do |cart|
|
88
|
-
#TODO do a regex caomparison
|
89
70
|
if cart.name == name
|
90
71
|
filtered.push(cart)
|
91
72
|
end
|
@@ -97,21 +78,16 @@ module Rhc
|
|
97
78
|
def user
|
98
79
|
url = @links['GET_USER']['href']
|
99
80
|
method = @links['GET_USER']['method']
|
100
|
-
request =
|
81
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
101
82
|
return request(request)
|
102
83
|
end
|
103
84
|
|
104
85
|
#find Key by name
|
105
86
|
def find_key(name)
|
106
87
|
logger.debug "Finding key #{name}" if @mydebug
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
if key.name == name
|
111
|
-
filtered.push(key)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
return filtered
|
88
|
+
user.keys.each { |key| return key if key.name == name }
|
89
|
+
|
90
|
+
raise RHC::KeyNotFoundException.new("Key #{name} does not exist")
|
115
91
|
end
|
116
92
|
|
117
93
|
def logout
|
data/lib/rhc-rest/domain.rb
CHANGED
@@ -26,7 +26,7 @@ module Rhc
|
|
26
26
|
if options[:scale]
|
27
27
|
timeout = 300 # 5 minute timeout for scalable app
|
28
28
|
end
|
29
|
-
request =
|
29
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout => timeout)
|
30
30
|
return request(request)
|
31
31
|
end
|
32
32
|
|
@@ -35,17 +35,25 @@ module Rhc
|
|
35
35
|
logger.debug "Getting all applications for domain #{self.id}" if @mydebug
|
36
36
|
url = @links['LIST_APPLICATIONS']['href']
|
37
37
|
method = @links['LIST_APPLICATIONS']['method']
|
38
|
-
request =
|
38
|
+
request = new_request(:url => url, :method => method, :headers => @@headers)
|
39
39
|
return request(request)
|
40
40
|
end
|
41
41
|
|
42
|
+
def find_application(name)
|
43
|
+
logger.debug "Finding application #{name}" if @mydebug
|
44
|
+
applications.each { |app| return app if app.name == name }
|
45
|
+
|
46
|
+
raise RHC::ApplicationNotFoundException.new("Application #{name} does not exist")
|
47
|
+
end
|
48
|
+
|
42
49
|
#Update Domain
|
43
50
|
def update(new_id)
|
44
51
|
logger.debug "Updating domain #{self.id} to #{new_id}" if @mydebug
|
45
52
|
url = @links['UPDATE']['href']
|
46
53
|
method = @links['UPDATE']['method']
|
47
54
|
payload = {:id => new_id}
|
48
|
-
|
55
|
+
# 5 minute timeout as this may take time if there are a lot of apps
|
56
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout=> 300)
|
49
57
|
return request(request)
|
50
58
|
end
|
51
59
|
alias :save :update
|
@@ -56,7 +64,7 @@ module Rhc
|
|
56
64
|
url = @links['DELETE']['href']
|
57
65
|
method = @links['DELETE']['method']
|
58
66
|
payload = {:force => force}
|
59
|
-
request =
|
67
|
+
request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
60
68
|
return request(request)
|
61
69
|
end
|
62
70
|
alias :delete :destroy
|