rest_connection 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rest_connection.rb +0 -1
- data/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +10 -0
- data/lib/rest_connection/rightscale/right_script_internal.rb +51 -0
- data/lib/rest_connection/rightscale/rightscale_api_resources.rb +1 -0
- data/lib/rest_connection/rightscale/server.rb +21 -2
- data/lib/rest_connection/rightscale/server_template.rb +27 -1
- data/lib/rest_connection/rightscale/server_template_internal.rb +34 -0
- data/lib/rest_connection/ssh_hax.rb +1 -0
- data/rest_connection.gemspec +9 -2
- data/spec/image_jockey.rb +11 -2
- data/spec/right_script_internal.rb +28 -0
- data/spec/server_template_internal.rb +35 -0
- data/spec/spec_helper.rb +7 -0
- metadata +11 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/lib/rest_connection.rb
CHANGED
@@ -35,4 +35,14 @@ class MultiCloudImageInternal
|
|
35
35
|
"multi_cloud_image"
|
36
36
|
end
|
37
37
|
|
38
|
+
def commit(message)
|
39
|
+
t = URI.parse(self.href)
|
40
|
+
MultiCloudImage.new(:href => connection.post(t.path + "/commit"))
|
41
|
+
end
|
42
|
+
|
43
|
+
def clone
|
44
|
+
t = URI.parse(self.href)
|
45
|
+
MultiCloudImage.new(:href => connection.post(t.path + "/clone"))
|
46
|
+
end
|
47
|
+
|
38
48
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# This file is part of RestConnection
|
2
|
+
#
|
3
|
+
# RestConnection is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# RestConnection is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with RestConnection. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
|
17
|
+
class RightScriptInternal
|
18
|
+
include RightScale::Api::Base
|
19
|
+
extend RightScale::Api::BaseExtend
|
20
|
+
include RightScale::Api::Internal
|
21
|
+
extend RightScale::Api::InternalExtend
|
22
|
+
|
23
|
+
def resource_plural_name
|
24
|
+
"right_scripts"
|
25
|
+
end
|
26
|
+
|
27
|
+
def resource_singular_name
|
28
|
+
"right_script"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.resource_plural_name
|
32
|
+
"right_scripts"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.resource_singular_name
|
36
|
+
"right_script"
|
37
|
+
end
|
38
|
+
|
39
|
+
# commits a rightscript
|
40
|
+
def commit(message)
|
41
|
+
t = URI.parse(self.href)
|
42
|
+
RightScript.new(:href => connection.post(t.path + "/commit", :commit_message => message))
|
43
|
+
end
|
44
|
+
|
45
|
+
# clones a RightScript and returns the new RightScript resource that's been created.
|
46
|
+
def clone
|
47
|
+
t = URI.parse(self.href)
|
48
|
+
RightScript.new(:href => connection.post(t.path + "/clone"))
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -35,6 +35,7 @@ require 'rest_connection/rightscale/ec2_ebs_snapshot'
|
|
35
35
|
require 'rest_connection/rightscale/server_internal'
|
36
36
|
require 'rest_connection/rightscale/ec2_ssh_key_internal'
|
37
37
|
require 'rest_connection/rightscale/server_template_internal'
|
38
|
+
require 'rest_connection/rightscale/right_script_internal'
|
38
39
|
require 'rest_connection/rightscale/multi_cloud_image_internal'
|
39
40
|
require 'rest_connection/rightscale/multi_cloud_image_cloud_setting_internal'
|
40
41
|
require 'rest_connection/rightscale/ec2_server_array'
|
@@ -105,11 +105,12 @@ class Server
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def stop
|
108
|
-
|
108
|
+
# All instances will have a valid href including EBS instances that are "stopped"
|
109
|
+
if self.current_instance_href
|
109
110
|
t = URI.parse(self.href)
|
110
111
|
connection.post(t.path + '/stop')
|
111
112
|
else
|
112
|
-
connection.logger("WARNING: was in #{self.state} so skiping stop call")
|
113
|
+
connection.logger("WARNING: was in #{self.state} and had a current_instance_href so skiping stop call")
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
@@ -225,5 +226,23 @@ class Server
|
|
225
226
|
raise("FATAL: timeout after #{timeout}s waiting for state change")
|
226
227
|
end
|
227
228
|
|
229
|
+
# Save the servers parameters to the current server (instead of the next server)
|
230
|
+
def save_current
|
231
|
+
uri = URI.parse(self.href)
|
232
|
+
connection.put(uri.path + "/current", resource_singular_name.to_sym => @params)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Load server's settings from the current server (instead of the next server)
|
236
|
+
def settings_current
|
237
|
+
serv_href = URI.parse(self.href)
|
238
|
+
@params.merge! connection.get(serv_href.path + "/current" + "/settings")
|
239
|
+
end
|
240
|
+
|
241
|
+
# Reload the server's basic information from the current server.
|
242
|
+
def reload_current
|
243
|
+
uri = URI.parse(self.href)
|
244
|
+
@params ? @params.merge!(connection.get(uri.path + "/current")) : @params = connection.get(uri.path)
|
245
|
+
end
|
246
|
+
|
228
247
|
end
|
229
248
|
|
@@ -27,6 +27,22 @@ class ServerTemplate
|
|
27
27
|
@params["executables"]
|
28
28
|
end
|
29
29
|
|
30
|
+
def alert_specs
|
31
|
+
unless @params["alert_specs"]
|
32
|
+
fetch_alert_specs
|
33
|
+
end
|
34
|
+
@params["alert_specs"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def fetch_alert_specs
|
38
|
+
my_href = URI.parse(self.href)
|
39
|
+
as = []
|
40
|
+
connection.get(my_href.path + "/alert_specs").each do |e|
|
41
|
+
as << AlertSpec.new(e)
|
42
|
+
end
|
43
|
+
@params["alert_specs"] = as
|
44
|
+
end
|
45
|
+
|
30
46
|
def multi_cloud_images
|
31
47
|
unless @params["multi_cloud_images"]
|
32
48
|
fetch_multi_cloud_images
|
@@ -46,5 +62,15 @@ class ServerTemplate
|
|
46
62
|
def fetch_multi_cloud_images
|
47
63
|
@params["multi_cloud_images"] = RsInternal.get_server_template_multi_cloud_images(self.href)
|
48
64
|
end
|
49
|
-
|
65
|
+
|
66
|
+
# The RightScale api calls this 'duplicate' but is more popularly known as 'clone' from a users perspective
|
67
|
+
def duplicate
|
68
|
+
my_href = URI.parse(self.href)
|
69
|
+
ServerTemplate.new(:href => connection.post(my_href.path + "/duplicate"))
|
70
|
+
end
|
71
|
+
|
72
|
+
def clone
|
73
|
+
duplicate
|
74
|
+
end
|
75
|
+
|
50
76
|
end
|
@@ -55,4 +55,38 @@ class ServerTemplateInternal
|
|
55
55
|
connection.get(t.path + "/multi_cloud_images")
|
56
56
|
end
|
57
57
|
|
58
|
+
# message <~String>: commit message string (required)
|
59
|
+
def commit(message)
|
60
|
+
t = URI.parse(self.href)
|
61
|
+
ServerTemplate.new(:href => connection.post(t.path + "/commit", :commit_message => message))
|
62
|
+
end
|
63
|
+
|
64
|
+
# <~Executable> executable, an Executable object to add
|
65
|
+
# <~String> Apply, a string designating the type of executable: "boot", "operational", "decommission". Default is operational
|
66
|
+
def add_executable(executable, apply="operational")
|
67
|
+
t = URI.parse(self.href)
|
68
|
+
params = {}
|
69
|
+
if executable.recipe?
|
70
|
+
params[:recipe] = executable.href
|
71
|
+
else
|
72
|
+
params[:right_script_href] = executable.href
|
73
|
+
end
|
74
|
+
params[:apply] = apply
|
75
|
+
connection.post(t.path + "/add_executable", params)
|
76
|
+
end
|
77
|
+
|
78
|
+
# <~Executable> executable, an Executable object to delete
|
79
|
+
# <~String> Apply, a string designating the type of executable: "boot", "operational", "decommission". Default is operational
|
80
|
+
def delete_executable(executable, apply="operational")
|
81
|
+
t = URI.parse(self.href)
|
82
|
+
params = {}
|
83
|
+
if executable.recipe?
|
84
|
+
params[:recipe] = executable.href
|
85
|
+
else
|
86
|
+
params[:right_script_href] = executable.href
|
87
|
+
end
|
88
|
+
params[:apply] = apply
|
89
|
+
connection.delete(t.path + "/delete_executable", params)
|
90
|
+
end
|
91
|
+
|
58
92
|
end
|
@@ -145,6 +145,7 @@ module SshHax
|
|
145
145
|
|
146
146
|
# returns hash of exit_status and output from command
|
147
147
|
def spot_check_command(command, ssh_key=nil, host_dns=self.dns_name)
|
148
|
+
raise "FATAL: spot_check_command called on a server with no dns_name. You need to run .settings on the server to populate this attribute." unless host_dns
|
148
149
|
connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key)}"
|
149
150
|
status = nil
|
150
151
|
output = ""
|
data/rest_connection.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rest_connection}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremy Deininger"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-01}
|
13
13
|
s.description = %q{provides rest_connection}
|
14
14
|
s.email = %q{jeremy@rubyonlinux.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
"lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb",
|
47
47
|
"lib/rest_connection/rightscale/multi_cloud_image_internal.rb",
|
48
48
|
"lib/rest_connection/rightscale/right_script.rb",
|
49
|
+
"lib/rest_connection/rightscale/right_script_internal.rb",
|
49
50
|
"lib/rest_connection/rightscale/rightscale_api_base.rb",
|
50
51
|
"lib/rest_connection/rightscale/rightscale_api_internal.rb",
|
51
52
|
"lib/rest_connection/rightscale/rightscale_api_resources.rb",
|
@@ -62,9 +63,12 @@ Gem::Specification.new do |s|
|
|
62
63
|
"spec/ec2_ssh_key_internal_spec.rb",
|
63
64
|
"spec/image_jockey.rb",
|
64
65
|
"spec/method_missing_spec.rb",
|
66
|
+
"spec/right_script_internal.rb",
|
65
67
|
"spec/rs_internal_spec.rb",
|
66
68
|
"spec/server_internal_spec.rb",
|
67
69
|
"spec/server_spec.rb",
|
70
|
+
"spec/server_template_internal.rb",
|
71
|
+
"spec/spec_helper.rb",
|
68
72
|
"spec/tag_spec.rb"
|
69
73
|
]
|
70
74
|
s.homepage = %q{http://github.com/jeremyd/rest_connection}
|
@@ -74,8 +78,11 @@ Gem::Specification.new do |s|
|
|
74
78
|
s.summary = %q{lib for restful connections to the rightscale api}
|
75
79
|
s.test_files = [
|
76
80
|
"spec/server_internal_spec.rb",
|
81
|
+
"spec/spec_helper.rb",
|
77
82
|
"spec/method_missing_spec.rb",
|
83
|
+
"spec/server_template_internal.rb",
|
78
84
|
"spec/server_spec.rb",
|
85
|
+
"spec/right_script_internal.rb",
|
79
86
|
"spec/ec2_ssh_key_internal_spec.rb",
|
80
87
|
"spec/rs_internal_spec.rb",
|
81
88
|
"spec/tag_spec.rb",
|
data/spec/image_jockey.rb
CHANGED
@@ -19,12 +19,21 @@ describe MultiCloudImageInternal, "exercises the mci internal api" do
|
|
19
19
|
trash.class.should == Array
|
20
20
|
trash.first.class.should == Hash
|
21
21
|
@really_new_st.delete_multi_cloud_image(@mci.href)
|
22
|
+
|
23
|
+
# test clone
|
24
|
+
@new_mci_test = @mci2.clone
|
25
|
+
|
26
|
+
# test commit
|
27
|
+
@new_mci_test.commit("hello commits world")
|
28
|
+
|
22
29
|
end
|
23
30
|
|
24
31
|
after(:all) do
|
32
|
+
@int_new_mci_test = MultiCloudImageInternal.new(:href => @new_mci_test.href)
|
25
33
|
@new_st.destroy
|
26
|
-
|
27
|
-
|
34
|
+
@mci.destroy
|
35
|
+
@mci2.destroy
|
36
|
+
@int_new_mci_test.destroy
|
28
37
|
end
|
29
38
|
|
30
39
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'ruby-debug'
|
3
|
+
|
4
|
+
describe RightScriptInternal, "exercises the right_script internal api" do
|
5
|
+
|
6
|
+
it "should do some stuff" do
|
7
|
+
@some_script = RightScriptInternal.new(:href => "https://my.rightscale.com/api/acct/2901/right_scripts/256669")
|
8
|
+
|
9
|
+
# Test commit
|
10
|
+
@some_script.commit("hello commits world")
|
11
|
+
|
12
|
+
# Test clone
|
13
|
+
@new_script = @some_script.clone
|
14
|
+
|
15
|
+
# Test update
|
16
|
+
@same_script = RightScriptInternal.new(:href => @new_script.href)
|
17
|
+
@same_script.name = "newname123"
|
18
|
+
@same_script.save
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
# can't cleanup, don't have destroy calls
|
24
|
+
#@new_script.destroy
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'ruby-debug'
|
3
|
+
|
4
|
+
describe ServerTemplateInternal, "exercises the server_template internal api" do
|
5
|
+
|
6
|
+
it "should do some stuff" do
|
7
|
+
some_image_href = "https://moo.rightscale.com/api/acct/0/ec2_images/ami-0859bb61?cloud_id=1"
|
8
|
+
@mci = MultiCloudImageInternal.create(:name => "123deleteme-test test 1234", :description => "woah")
|
9
|
+
@new_setting = MultiCloudImageCloudSettingInternal.create(:multi_cloud_image_href => @mci.href, :cloud_id => 1, :ec2_image_href => some_image_href, :aws_instance_type => "m1.small")
|
10
|
+
@new_st = ServerTemplate.create(:multi_cloud_image_href => @mci.href, :nickname => "123deleteme-test test 123456", :description => "1234")
|
11
|
+
@executable = Executable.new('right_script' => {:href => "https://moo.rightscale.com/api/acct/2901/right_scripts/256669"})
|
12
|
+
@st = ServerTemplateInternal.new(:href => @new_st.href)
|
13
|
+
|
14
|
+
# Test commit
|
15
|
+
@st.commit('hello commits world')
|
16
|
+
|
17
|
+
# Test clone
|
18
|
+
@clone = @new_st.clone
|
19
|
+
@clone.reload
|
20
|
+
|
21
|
+
# Test add_executable
|
22
|
+
@st.add_executable(@executable, "boot")
|
23
|
+
|
24
|
+
# Test delete_executable
|
25
|
+
@st.delete_executable(@executable, "boot")
|
26
|
+
end
|
27
|
+
|
28
|
+
after(:all) do
|
29
|
+
@new_st.destroy
|
30
|
+
@mci.destroy
|
31
|
+
@clone.destroy
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Deininger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb
|
100
100
|
- lib/rest_connection/rightscale/multi_cloud_image_internal.rb
|
101
101
|
- lib/rest_connection/rightscale/right_script.rb
|
102
|
+
- lib/rest_connection/rightscale/right_script_internal.rb
|
102
103
|
- lib/rest_connection/rightscale/rightscale_api_base.rb
|
103
104
|
- lib/rest_connection/rightscale/rightscale_api_internal.rb
|
104
105
|
- lib/rest_connection/rightscale/rightscale_api_resources.rb
|
@@ -115,9 +116,12 @@ files:
|
|
115
116
|
- spec/ec2_ssh_key_internal_spec.rb
|
116
117
|
- spec/image_jockey.rb
|
117
118
|
- spec/method_missing_spec.rb
|
119
|
+
- spec/right_script_internal.rb
|
118
120
|
- spec/rs_internal_spec.rb
|
119
121
|
- spec/server_internal_spec.rb
|
120
122
|
- spec/server_spec.rb
|
123
|
+
- spec/server_template_internal.rb
|
124
|
+
- spec/spec_helper.rb
|
121
125
|
- spec/tag_spec.rb
|
122
126
|
has_rdoc: true
|
123
127
|
homepage: http://github.com/jeremyd/rest_connection
|
@@ -155,8 +159,11 @@ specification_version: 3
|
|
155
159
|
summary: lib for restful connections to the rightscale api
|
156
160
|
test_files:
|
157
161
|
- spec/server_internal_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
158
163
|
- spec/method_missing_spec.rb
|
164
|
+
- spec/server_template_internal.rb
|
159
165
|
- spec/server_spec.rb
|
166
|
+
- spec/right_script_internal.rb
|
160
167
|
- spec/ec2_ssh_key_internal_spec.rb
|
161
168
|
- spec/rs_internal_spec.rb
|
162
169
|
- spec/tag_spec.rb
|