rhc-rest 0.0.7 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -0
- data/bin/sample-usage.rb +26 -28
- data/doc/Rhc/Rest/Client.html +8 -8
- data/doc/images/add.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/ext/mkrf_conf.rb +21 -0
- data/lib/rhc-rest.rb +5 -1
- data/lib/rhc-rest/application.rb +14 -13
- data/lib/rhc-rest/cartridge.rb +10 -10
- data/lib/rhc-rest/client.rb +19 -18
- data/lib/rhc-rest/domain.rb +26 -17
- data/lib/rhc-rest/key.rb +4 -4
- data/lib/rhc-rest/user.rb +2 -2
- data/rhc-rest.gemspec +1 -1
- data/rhc-rest.spec +44 -1
- metadata +8 -22
- data/doc/doc/created.rid +0 -0
data/Rakefile
CHANGED
data/bin/sample-usage.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Copyright 2011 Red Hat, Inc.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
19
|
-
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
20
|
-
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
# SOFTWARE.
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
23
15
|
|
24
16
|
require '../lib/rhc-rest'
|
25
17
|
|
@@ -29,18 +21,24 @@ if __FILE__ == $0
|
|
29
21
|
end_point = ARGV[0]
|
30
22
|
username = ARGV[1]
|
31
23
|
password = ARGV[2]
|
32
|
-
|
24
|
+
domain_id = ARGV[3]
|
33
25
|
|
34
|
-
if end_point.nil? or username.nil? or password.nil? or
|
35
|
-
puts "Usage: https://<hostname>/broker/rest <username> <password> <
|
26
|
+
if end_point.nil? or username.nil? or password.nil? or domain_id.nil?
|
27
|
+
puts "Usage: https://<hostname>/broker/rest <username> <password> <domain_id>"
|
36
28
|
exit 1
|
37
29
|
end
|
38
|
-
|
30
|
+
@mydebug =true
|
39
31
|
client = Rhc::Rest::Client.new(end_point, username, password)
|
40
32
|
|
33
|
+
client.domains.each do |domain|
|
34
|
+
domain.applications.each do |app|
|
35
|
+
app.delete
|
36
|
+
end
|
37
|
+
domain.delete
|
38
|
+
end
|
41
39
|
puts "Creating a domain"
|
42
|
-
domain = client.add_domain(
|
43
|
-
puts "Domain created: #{domain.
|
40
|
+
domain = client.add_domain(domain_id)
|
41
|
+
puts "Domain created: #{domain.id}"
|
44
42
|
|
45
43
|
puts "Getting all cartridges..."
|
46
44
|
client.cartridges.each do |cart|
|
@@ -49,7 +47,7 @@ end
|
|
49
47
|
|
50
48
|
puts "Creating application appone"
|
51
49
|
carts = client.find_cartridge("php-5.3")
|
52
|
-
domain.add_application("appone", carts.first.name)
|
50
|
+
domain.add_application("appone", {:cartridge => carts.first.name})
|
53
51
|
|
54
52
|
puts "Try deleting domain with an application"
|
55
53
|
begin
|
@@ -60,7 +58,7 @@ end
|
|
60
58
|
|
61
59
|
puts "Getting all domains and applications..."
|
62
60
|
client.domains.each do |domain|
|
63
|
-
puts " Domain: #{domain.
|
61
|
+
puts " Domain: #{domain.id}"
|
64
62
|
domain.applications.each do |app|
|
65
63
|
puts " Application: #{app.name}"
|
66
64
|
app.cartridges.each do |cart|
|
@@ -79,7 +77,7 @@ if not apps.nil? and not apps.first.nil?
|
|
79
77
|
end
|
80
78
|
|
81
79
|
puts "Create new application named appthree..."
|
82
|
-
app = client.domains.first.add_application("appthree", "php-5.3")
|
80
|
+
app = client.domains.first.add_application("appthree", {:cartridge =>"php-5.3"})
|
83
81
|
puts "Adding MySQL cartridge to appthree"
|
84
82
|
cartridge = app.add_cartridge("mysql-5.1")
|
85
83
|
puts "Check to see if it was added"
|
data/doc/Rhc/Rest/Client.html
CHANGED
@@ -246,7 +246,7 @@
|
|
246
246
|
|
247
247
|
<div class="method-heading">
|
248
248
|
<span class="method-name">add_domain</span><span
|
249
|
-
class="method-args">(
|
249
|
+
class="method-args">(id)</span>
|
250
250
|
<span class="method-click-advice">click to toggle source</span>
|
251
251
|
</div>
|
252
252
|
|
@@ -259,11 +259,11 @@
|
|
259
259
|
|
260
260
|
<div class="method-source-code" id="add_domain-source">
|
261
261
|
<pre><span class="ruby-comment"># File lib/rhc-rest/client.rb, line 45</span>
|
262
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_domain</span>(<span class="ruby-identifier">
|
263
|
-
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Adding domain #{
|
262
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_domain</span>(<span class="ruby-identifier">id</span>)
|
263
|
+
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Adding domain #{id}"</span>
|
264
264
|
<span class="ruby-identifier">url</span> = <span class="ruby-identifier">@@end_point</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@links</span>[<span class="ruby-string">'ADD_DOMAIN'</span>][<span class="ruby-string">'href'</span>]
|
265
265
|
<span class="ruby-identifier">method</span> = <span class="ruby-ivar">@links</span>[<span class="ruby-string">'ADD_DOMAIN'</span>][<span class="ruby-string">'method'</span>]
|
266
|
-
<span class="ruby-identifier">payload</span> = {<span class="ruby-value">:
|
266
|
+
<span class="ruby-identifier">payload</span> = {<span class="ruby-value">:id</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">id</span>}
|
267
267
|
<span class="ruby-identifier">request</span> = <span class="ruby-constant">RestClient</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:url</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">url</span>, <span class="ruby-value">:method</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">method</span>, <span class="ruby-value">:headers</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">@@headers</span>, <span class="ruby-value">:payload</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">payload</span>)
|
268
268
|
<span class="ruby-keyword">return</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">request</span>)
|
269
269
|
<span class="ruby-keyword">end</span></pre>
|
@@ -454,7 +454,7 @@
|
|
454
454
|
|
455
455
|
<div class="method-heading">
|
456
456
|
<span class="method-name">find_domain</span><span
|
457
|
-
class="method-args">(
|
457
|
+
class="method-args">(id)</span>
|
458
458
|
<span class="method-click-advice">click to toggle source</span>
|
459
459
|
</div>
|
460
460
|
|
@@ -467,12 +467,12 @@
|
|
467
467
|
|
468
468
|
<div class="method-source-code" id="find_domain-source">
|
469
469
|
<pre><span class="ruby-comment"># File lib/rhc-rest/client.rb, line 64</span>
|
470
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">find_domain</span>(<span class="ruby-identifier">
|
471
|
-
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Finding domain #{
|
470
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">find_domain</span>(<span class="ruby-identifier">id</span>)
|
471
|
+
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"Finding domain #{id}"</span>
|
472
472
|
<span class="ruby-identifier">filtered</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
473
473
|
<span class="ruby-identifier">domains</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">domain</span><span class="ruby-operator">|</span>
|
474
474
|
<span class="ruby-comment">#TODO do a regex caomparison</span>
|
475
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">
|
475
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span>
|
476
476
|
<span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">domain</span>)
|
477
477
|
<span class="ruby-keyword">end</span>
|
478
478
|
<span class="ruby-keyword">end</span>
|
data/doc/images/add.png
CHANGED
File without changes
|
data/doc/images/delete.png
CHANGED
File without changes
|
data/doc/images/tag_blue.png
CHANGED
File without changes
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/command.rb'
|
3
|
+
require 'rubygems/dependency_installer.rb'
|
4
|
+
begin
|
5
|
+
Gem::Command.build_args = ARGV
|
6
|
+
rescue NoMethodError
|
7
|
+
end
|
8
|
+
inst = Gem::DependencyInstaller.new
|
9
|
+
begin
|
10
|
+
if ENV['JSON_PURE'] or (RUBY_VERSION == "1.8.6" or RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /darwin/)
|
11
|
+
inst.install('json_pure')
|
12
|
+
else
|
13
|
+
inst.install('json')
|
14
|
+
end
|
15
|
+
rescue
|
16
|
+
exit(1)
|
17
|
+
end
|
18
|
+
|
19
|
+
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
20
|
+
f.write("task :default\n")
|
21
|
+
f.close
|
data/lib/rhc-rest.rb
CHANGED
@@ -79,6 +79,8 @@ module Rhc
|
|
79
79
|
end
|
80
80
|
#puts "#{response}"
|
81
81
|
return parse_response(response) unless response.nil? or response.code == 204
|
82
|
+
rescue RestClient::RequestTimeout, RestClient::ServerBrokeConnection, RestClient::SSLCertificateNotVerified => e
|
83
|
+
raise ResourceAccessException.new("Failed to access resource: #{e.message}")
|
82
84
|
rescue RestClient::ExceptionWithResponse => e
|
83
85
|
#puts "#{e.response}"
|
84
86
|
process_error_response(e.response)
|
@@ -93,7 +95,7 @@ module Rhc
|
|
93
95
|
result = JSON.parse(response)
|
94
96
|
messages = result['messages']
|
95
97
|
rescue Exception => e
|
96
|
-
logger.debug "Response did not include a message from server"
|
98
|
+
logger.debug "Response did not include a message from server" if @mydebug
|
97
99
|
#puts response
|
98
100
|
end
|
99
101
|
case response.code
|
@@ -148,6 +150,8 @@ module Rhc
|
|
148
150
|
raise ServiceUnavailableException.new(message['text'])
|
149
151
|
end
|
150
152
|
end
|
153
|
+
else
|
154
|
+
raise ResourceAccessException.new("Server returned error code with no output: #{response.code}")
|
151
155
|
end
|
152
156
|
|
153
157
|
end
|
data/lib/rhc-rest/application.rb
CHANGED
@@ -3,8 +3,9 @@ module Rhc
|
|
3
3
|
module Rest
|
4
4
|
class Application
|
5
5
|
include Rest
|
6
|
-
attr_reader :domain_id, :name, :creation_time, :uuid, :aliases, :
|
6
|
+
attr_reader :domain_id, :name, :creation_time, :uuid, :aliases, :git_url, :app_url, :node_profile, :framework, :scalable, :health_check_path, :embedded
|
7
7
|
def initialize(args)
|
8
|
+
#logger.debug args
|
8
9
|
@domain_id = args[:domain_id] || args["domain_id"]
|
9
10
|
@name = args[:name] || args["name"]
|
10
11
|
@creation_time = args[:creation_time] || args["creation_time"]
|
@@ -16,8 +17,8 @@ module Rhc
|
|
16
17
|
|
17
18
|
#Add Cartridge
|
18
19
|
def add_cartridge(name)
|
19
|
-
logger.debug "Adding cartridge #{name}"
|
20
|
-
url =
|
20
|
+
logger.debug "Adding cartridge #{name}" if @mydebug
|
21
|
+
url = @links['ADD_CARTRIDGE']['href']
|
21
22
|
method = @links['ADD_CARTRIDGE']['method']
|
22
23
|
payload = {:name => name}
|
23
24
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -26,8 +27,8 @@ module Rhc
|
|
26
27
|
|
27
28
|
#Get all Cartridge for this applications
|
28
29
|
def cartridges
|
29
|
-
logger.debug "Getting all cartridges for application #{self.name}"
|
30
|
-
url =
|
30
|
+
logger.debug "Getting all cartridges for application #{self.name}" if @mydebug
|
31
|
+
url = @links['LIST_CARTRIDGES']['href']
|
31
32
|
method = @links['LIST_CARTRIDGES']['method']
|
32
33
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
33
34
|
return send(request)
|
@@ -35,8 +36,8 @@ module Rhc
|
|
35
36
|
|
36
37
|
#Start Application
|
37
38
|
def start
|
38
|
-
logger.debug "Starting application #{self.name}"
|
39
|
-
url =
|
39
|
+
logger.debug "Starting application #{self.name}" if @mydebug
|
40
|
+
url = @links['START']['href']
|
40
41
|
method = @links['START']['method']
|
41
42
|
payload = {:event=> "start"}
|
42
43
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -45,8 +46,8 @@ module Rhc
|
|
45
46
|
|
46
47
|
#Stop Application
|
47
48
|
def stop(force=false)
|
48
|
-
logger.debug "Stopping application #{self.name} force-#{force}"
|
49
|
-
url =
|
49
|
+
logger.debug "Stopping application #{self.name} force-#{force}" if @mydebug
|
50
|
+
url = @links['STOP']['href']
|
50
51
|
method = @links['STOP']['method']
|
51
52
|
if force
|
52
53
|
payload = {:event=> "force-stop"}
|
@@ -59,8 +60,8 @@ module Rhc
|
|
59
60
|
|
60
61
|
#Restart Application
|
61
62
|
def restart
|
62
|
-
logger.debug "Restarting application #{self.name}"
|
63
|
-
url =
|
63
|
+
logger.debug "Restarting application #{self.name}" if @mydebug
|
64
|
+
url = @links['RESTART']['href']
|
64
65
|
method = @links['RESTART']['method']
|
65
66
|
payload = {:event=> "restart"}
|
66
67
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -69,8 +70,8 @@ module Rhc
|
|
69
70
|
|
70
71
|
#Delete Application
|
71
72
|
def destroy
|
72
|
-
logger.debug "Deleting application #{self.name}"
|
73
|
-
url =
|
73
|
+
logger.debug "Deleting application #{self.name}" if @mydebug
|
74
|
+
url = @links['DELETE']['href']
|
74
75
|
method = @links['DELETE']['method']
|
75
76
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
76
77
|
return send(request)
|
data/lib/rhc-rest/cartridge.rb
CHANGED
@@ -11,8 +11,8 @@ module Rhc
|
|
11
11
|
|
12
12
|
#Start Cartridge
|
13
13
|
def start
|
14
|
-
logger.debug "Starting cartridge #{self.name}"
|
15
|
-
url =
|
14
|
+
logger.debug "Starting cartridge #{self.name}" if @mydebug
|
15
|
+
url = @links['START']['href']
|
16
16
|
method = @links['START']['method']
|
17
17
|
payload = {:event=> "start"}
|
18
18
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -21,8 +21,8 @@ module Rhc
|
|
21
21
|
|
22
22
|
#Stop Cartridge
|
23
23
|
def stop()
|
24
|
-
logger.debug "Stopping cartridge #{self.name}"
|
25
|
-
url =
|
24
|
+
logger.debug "Stopping cartridge #{self.name}" if @mydebug
|
25
|
+
url = @links['STOP']['href']
|
26
26
|
method = @links['STOP']['method']
|
27
27
|
payload = {:event=> "stop"}
|
28
28
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -31,8 +31,8 @@ module Rhc
|
|
31
31
|
|
32
32
|
#Restart Cartridge
|
33
33
|
def restart
|
34
|
-
logger.debug "Restarting cartridge #{self.name}"
|
35
|
-
url =
|
34
|
+
logger.debug "Restarting cartridge #{self.name}" if @mydebug
|
35
|
+
url = @links['RESTART']['href']
|
36
36
|
method = @links['RESTART']['method']
|
37
37
|
payload = {:event=> "restart"}
|
38
38
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -41,8 +41,8 @@ module Rhc
|
|
41
41
|
|
42
42
|
#Reload Cartridge
|
43
43
|
def reload
|
44
|
-
logger.debug "Reloading cartridge #{self.name}"
|
45
|
-
url =
|
44
|
+
logger.debug "Reloading cartridge #{self.name}" if @mydebug
|
45
|
+
url = @links['RESTART']['href']
|
46
46
|
method = @links['RESTART']['method']
|
47
47
|
payload = {:event=> "reload"}
|
48
48
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -51,8 +51,8 @@ module Rhc
|
|
51
51
|
|
52
52
|
#Delete Cartridge
|
53
53
|
def destroy
|
54
|
-
logger.debug "Deleting cartridge #{self.name}"
|
55
|
-
url =
|
54
|
+
logger.debug "Deleting cartridge #{self.name}" if @mydebug
|
55
|
+
url = @links['DELETE']['href']
|
56
56
|
method = @links['DELETE']['method']
|
57
57
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
58
58
|
return send(request)
|
data/lib/rhc-rest/client.rb
CHANGED
@@ -5,11 +5,12 @@ module Rhc
|
|
5
5
|
class Client
|
6
6
|
include Rest
|
7
7
|
def initialize(end_point, username, password)
|
8
|
-
|
8
|
+
logger.debug "Connecting to #{end_point}" if @mydebug
|
9
9
|
credentials = Base64.encode64("#{username}:#{password}")
|
10
10
|
@@headers["Authorization"] = "Basic #{credentials}"
|
11
11
|
#first get the API
|
12
|
-
|
12
|
+
RestClient.proxy = ENV['http_proxy']
|
13
|
+
request = RestClient::Request.new(:url => end_point, :method => :get, :headers => @@headers)
|
13
14
|
begin
|
14
15
|
response = request.execute
|
15
16
|
result = JSON.parse(response)
|
@@ -22,31 +23,31 @@ module Rhc
|
|
22
23
|
end
|
23
24
|
|
24
25
|
#Add Domain
|
25
|
-
def add_domain(
|
26
|
-
logger.debug "Adding domain #{
|
27
|
-
url =
|
26
|
+
def add_domain(id)
|
27
|
+
logger.debug "Adding domain #{id}" if @mydebug
|
28
|
+
url = @links['ADD_DOMAIN']['href']
|
28
29
|
method = @links['ADD_DOMAIN']['method']
|
29
|
-
payload = {:
|
30
|
+
payload = {:id => id}
|
30
31
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
31
32
|
return send(request)
|
32
33
|
end
|
33
34
|
|
34
35
|
#Get all Domain
|
35
36
|
def domains
|
36
|
-
logger.debug "Getting all domains"
|
37
|
-
url =
|
37
|
+
logger.debug "Getting all domains" if @mydebug
|
38
|
+
url = @links['LIST_DOMAINS']['href']
|
38
39
|
method = @links['LIST_DOMAINS']['method']
|
39
40
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
40
41
|
return send(request)
|
41
42
|
end
|
42
43
|
|
43
44
|
#Find Domain by namesapce
|
44
|
-
def find_domain(
|
45
|
-
logger.debug "Finding domain #{
|
45
|
+
def find_domain(id)
|
46
|
+
logger.debug "Finding domain #{id}" if @mydebug
|
46
47
|
filtered = Array.new
|
47
48
|
domains.each do |domain|
|
48
49
|
#TODO do a regex caomparison
|
49
|
-
if domain.
|
50
|
+
if domain.id == id
|
50
51
|
filtered.push(domain)
|
51
52
|
end
|
52
53
|
end
|
@@ -55,7 +56,7 @@ module Rhc
|
|
55
56
|
|
56
57
|
#Find Application by name
|
57
58
|
def find_application(name)
|
58
|
-
logger.debug "Finding application #{name}"
|
59
|
+
logger.debug "Finding application #{name}" if @mydebug
|
59
60
|
filtered = Array.new
|
60
61
|
domains.each do |domain|
|
61
62
|
#TODO do a regex caomparison
|
@@ -70,8 +71,8 @@ module Rhc
|
|
70
71
|
|
71
72
|
#Get all Cartridge
|
72
73
|
def cartridges
|
73
|
-
logger.debug "Getting all cartridges"
|
74
|
-
url =
|
74
|
+
logger.debug "Getting all cartridges" if @mydebug
|
75
|
+
url = @links['LIST_CARTRIDGES']['href']
|
75
76
|
method = @links['LIST_CARTRIDGES']['method']
|
76
77
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
77
78
|
return send(request)
|
@@ -79,7 +80,7 @@ module Rhc
|
|
79
80
|
|
80
81
|
#Find Cartridge by name
|
81
82
|
def find_cartridge(name)
|
82
|
-
logger.debug "Finding cartridge #{name}"
|
83
|
+
logger.debug "Finding cartridge #{name}" if @mydebug
|
83
84
|
filtered = Array.new
|
84
85
|
cartridges.each do |cart|
|
85
86
|
#TODO do a regex caomparison
|
@@ -92,7 +93,7 @@ module Rhc
|
|
92
93
|
|
93
94
|
#Get User info
|
94
95
|
def user
|
95
|
-
url =
|
96
|
+
url = @links['GET_USER']['href']
|
96
97
|
method = @links['GET_USER']['method']
|
97
98
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
98
99
|
return send(request)
|
@@ -100,7 +101,7 @@ module Rhc
|
|
100
101
|
|
101
102
|
#find Key by name
|
102
103
|
def find_key(name)
|
103
|
-
logger.debug "Finding key #{name}"
|
104
|
+
logger.debug "Finding key #{name}" if @mydebug
|
104
105
|
filtered = Array.new
|
105
106
|
user.keys.each do |key|
|
106
107
|
#TODO do a regex caomparison
|
@@ -113,7 +114,7 @@ module Rhc
|
|
113
114
|
|
114
115
|
def logout
|
115
116
|
#TODO logout
|
116
|
-
logger.debug "Logout/Close client"
|
117
|
+
logger.debug "Logout/Close client" if @mydebug
|
117
118
|
end
|
118
119
|
alias :close :logout
|
119
120
|
end
|
data/lib/rhc-rest/domain.rb
CHANGED
@@ -2,40 +2,49 @@ module Rhc
|
|
2
2
|
module Rest
|
3
3
|
class Domain
|
4
4
|
include Rest
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :id
|
6
6
|
def initialize(args)
|
7
|
-
@
|
7
|
+
@id = args[:id] || args["id"]
|
8
8
|
@links = args[:links] || args["links"]
|
9
9
|
end
|
10
10
|
|
11
11
|
#Add Application to this domain
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# options
|
13
|
+
# cartrdige
|
14
|
+
# template
|
15
|
+
# scale
|
16
|
+
# node_profile
|
17
|
+
def add_application(name, options)
|
18
|
+
logger.debug "Adding application #{name} to domain #{self.id}" if @mydebug
|
19
|
+
url = @links['ADD_APPLICATION']['href']
|
15
20
|
method = @links['ADD_APPLICATION']['method']
|
16
|
-
payload = {:name => name
|
17
|
-
|
18
|
-
payload[
|
21
|
+
payload = {:name => name}
|
22
|
+
options.each do |key, value|
|
23
|
+
payload[key] = value
|
19
24
|
end
|
20
|
-
|
25
|
+
timeout = nil
|
26
|
+
if options[:scale]
|
27
|
+
timeout = 180 # 3 minute timeout for scalable app
|
28
|
+
end
|
29
|
+
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload, :timeout => timeout)
|
21
30
|
return send(request)
|
22
31
|
end
|
23
32
|
|
24
33
|
#Get all Application for this domain
|
25
34
|
def applications
|
26
|
-
logger.debug "Getting all applications for domain #{self.
|
27
|
-
url =
|
35
|
+
logger.debug "Getting all applications for domain #{self.id}" if @mydebug
|
36
|
+
url = @links['LIST_APPLICATIONS']['href']
|
28
37
|
method = @links['LIST_APPLICATIONS']['method']
|
29
38
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
30
39
|
return send(request)
|
31
40
|
end
|
32
41
|
|
33
42
|
#Update Domain
|
34
|
-
def update(
|
35
|
-
logger.debug "Updating domain #{self.
|
36
|
-
url =
|
43
|
+
def update(new_id)
|
44
|
+
logger.debug "Updating domain #{self.id} to #{new_id}" if @mydebug
|
45
|
+
url = @links['UPDATE']['href']
|
37
46
|
method = @links['UPDATE']['method']
|
38
|
-
payload = {:
|
47
|
+
payload = {:domain_id => new_id}
|
39
48
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
40
49
|
return send(request)
|
41
50
|
end
|
@@ -43,8 +52,8 @@ module Rhc
|
|
43
52
|
|
44
53
|
#Delete Domain
|
45
54
|
def destroy(force=false)
|
46
|
-
logger.debug "Deleting domain #{self.
|
47
|
-
url =
|
55
|
+
logger.debug "Deleting domain #{self.id}" if @mydebug
|
56
|
+
url = @links['DELETE']['href']
|
48
57
|
method = @links['DELETE']['method']
|
49
58
|
payload = {:force => force}
|
50
59
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
data/lib/rhc-rest/key.rb
CHANGED
@@ -12,8 +12,8 @@ module Rhc
|
|
12
12
|
|
13
13
|
# Update Key
|
14
14
|
def update(type, content)
|
15
|
-
logger.debug "Updating key #{self.name}"
|
16
|
-
url =
|
15
|
+
logger.debug "Updating key #{self.name}" if @mydebug
|
16
|
+
url = @links['UPDATE']['href']
|
17
17
|
method = @links['UPDATE']['method']
|
18
18
|
payload = {:type => type, :content => content}
|
19
19
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -22,8 +22,8 @@ module Rhc
|
|
22
22
|
|
23
23
|
#Delete Key
|
24
24
|
def destroy
|
25
|
-
logger.debug "Deleting key #{self.name}"
|
26
|
-
url =
|
25
|
+
logger.debug "Deleting key #{self.name}" if @mydebug
|
26
|
+
url = @links['DELETE']['href']
|
27
27
|
method = @links['DELETE']['method']
|
28
28
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
29
29
|
return send(request)
|
data/lib/rhc-rest/user.rb
CHANGED
@@ -10,7 +10,7 @@ module Rhc
|
|
10
10
|
|
11
11
|
#Add Key for this user
|
12
12
|
def add_key(name, content, type)
|
13
|
-
url =
|
13
|
+
url = @links['ADD_KEY']['href']
|
14
14
|
method = @links['ADD_KEY']['method']
|
15
15
|
payload = {:name => name, :type => type, :content => content}
|
16
16
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
@@ -19,7 +19,7 @@ module Rhc
|
|
19
19
|
|
20
20
|
#Get all Key for this user
|
21
21
|
def keys
|
22
|
-
url =
|
22
|
+
url = @links['LIST_KEYS']['href']
|
23
23
|
method = @links['LIST_KEYS']['method']
|
24
24
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
25
25
|
return send(request)
|
data/rhc-rest.gemspec
CHANGED
data/rhc-rest.spec
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
|
7
7
|
Summary: Ruby bindings/client for OpenShift REST API
|
8
8
|
Name: rhc-rest
|
9
|
-
|
9
|
+
# Make sure to update express/client.spec and express/Rakefile when increasing version number
|
10
|
+
Version: 0.0.14
|
10
11
|
Release: 1%{?dist}
|
11
12
|
Group: Network/Daemons
|
12
13
|
License: ASL 2.0
|
@@ -56,6 +57,48 @@ rm -rf %{buildroot}
|
|
56
57
|
%doc COPYRIGHT
|
57
58
|
|
58
59
|
%changelog
|
60
|
+
* Thu Apr 12 2012 Mike McGrath <mmcgrath@redhat.com> 0.0.14-1
|
61
|
+
- Merge branch 'master' of github.com:openshift/os-client-tools
|
62
|
+
(mmcgrath@redhat.com)
|
63
|
+
- BZ810790: Fixed app scaling payload creation (fotios@redhat.com)
|
64
|
+
|
65
|
+
* Thu Apr 12 2012 Mike McGrath <mmcgrath@redhat.com> 0.0.13-1
|
66
|
+
-
|
67
|
+
|
68
|
+
* Thu Apr 12 2012 Mike McGrath <mmcgrath@redhat.com> 0.0.12-1
|
69
|
+
- Update to ASL 2.0 License (jhonce@redhat.com)
|
70
|
+
- Bug 810714 - Command Line Tools: Unable to create scalable application via
|
71
|
+
proxy (lnader@redhat.com)
|
72
|
+
- Also noted to change Rakefile when bumping version (fotios@redhat.com)
|
73
|
+
- BZ810439: Fixed dependency for client tools to require latest version of rhc-
|
74
|
+
rest (fotios@redhat.com)
|
75
|
+
- changed permissions to 755 (lnader@redhat.com)
|
76
|
+
- removed doc/created.rid (lnader@redhat.com)
|
77
|
+
- remove +x (lnader@redhat.com)
|
78
|
+
|
79
|
+
* Mon Apr 09 2012 Lili Nader <lnader@redhat.com> 0.0.11-1
|
80
|
+
- bug fixes (lnader@redhat.com)
|
81
|
+
|
82
|
+
* Mon Apr 09 2012 Lili Nader <lnader@redhat.com> 0.0.10-1
|
83
|
+
-
|
84
|
+
|
85
|
+
* Mon Apr 09 2012 Lili Nader <lnader@redhat.com> 0.0.9-1
|
86
|
+
- absolute URLs (lnader@redhat.com)
|
87
|
+
- Made sure debugging output was only printed when @mydebug was specified
|
88
|
+
(fotios@redhat.com)
|
89
|
+
- Ruby REST api changes: - Make 'domain namespace' consistent across
|
90
|
+
domain/app objects. It will be referred as 'id' in domain objects and
|
91
|
+
'domain_id' in app objects. (rpenta@redhat.com)
|
92
|
+
- update sample script for ruby REST api (rpenta@redhat.com)
|
93
|
+
|
94
|
+
* Fri Mar 30 2012 Lili Nader <lnader@redhat.com> 0.0.8-1
|
95
|
+
- Catch all to prevent trying to parse a null response on an http code we did
|
96
|
+
not expect. (rmillner@redhat.com)
|
97
|
+
- Increase the timeout to 3 minutes on creating a scalable application.
|
98
|
+
(rmillner@redhat.com)
|
99
|
+
- Creating scalable apps was causing a timeout. Needed to setup an exception
|
100
|
+
to propagate that back to the end-user. (rmillner@redhat.com)
|
101
|
+
|
59
102
|
* Wed Mar 21 2012 Lili Nader <lnader@redhat.com> 0.0.7-1
|
60
103
|
- Get rhc-rest a building ... (ramr@redhat.com)
|
61
104
|
- Fix to get rhc-rest building. (ramr@redhat.com)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhc-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 14
|
10
|
+
version: 0.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: rest-client
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -31,27 +31,13 @@ dependencies:
|
|
31
31
|
version: "0"
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: rest-client
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
34
|
description: Ruby bindings for OpenShift REST API
|
49
35
|
email:
|
50
36
|
- openshift@redhat.com
|
51
37
|
executables: []
|
52
38
|
|
53
|
-
extensions:
|
54
|
-
|
39
|
+
extensions:
|
40
|
+
- ext/mkrf_conf.rb
|
55
41
|
extra_rdoc_files: []
|
56
42
|
|
57
43
|
files:
|
@@ -117,7 +103,6 @@ files:
|
|
117
103
|
- doc/js/search_index.js
|
118
104
|
- doc/js/search.js
|
119
105
|
- doc/js/jquery.js
|
120
|
-
- doc/doc/created.rid
|
121
106
|
- doc/Gemfile.html
|
122
107
|
- Rakefile
|
123
108
|
- rhc-rest.gemspec
|
@@ -125,6 +110,7 @@ files:
|
|
125
110
|
- rhc-rest.spec
|
126
111
|
- COPYRIGHT
|
127
112
|
- LICENSE
|
113
|
+
- ext/mkrf_conf.rb
|
128
114
|
homepage: http://www.openshift.com
|
129
115
|
licenses: []
|
130
116
|
|
data/doc/doc/created.rid
DELETED
File without changes
|