rest_connection 0.1.0 → 0.1.1
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 +7 -3
- data/lib/rest_connection/rightscale/child_account.rb +4 -0
- data/lib/rest_connection/rightscale/cloud.rb +4 -0
- data/lib/rest_connection/rightscale/cloud_account.rb +37 -0
- data/lib/rest_connection/rightscale/deployment.rb +18 -1
- data/lib/rest_connection/rightscale/mc_datacenter.rb +4 -0
- data/lib/rest_connection/rightscale/mc_deployment.rb +4 -0
- data/lib/rest_connection/rightscale/mc_image.rb +4 -0
- data/lib/rest_connection/rightscale/mc_instance.rb +17 -0
- data/lib/rest_connection/rightscale/mc_instance_type.rb +4 -0
- data/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +4 -0
- data/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +4 -0
- data/lib/rest_connection/rightscale/mc_security_group.rb +4 -0
- data/lib/rest_connection/rightscale/mc_server.rb +4 -0
- data/lib/rest_connection/rightscale/mc_server_array.rb +6 -0
- data/lib/rest_connection/rightscale/mc_server_template.rb +50 -0
- data/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb +48 -0
- data/lib/rest_connection/rightscale/mc_ssh_key.rb +4 -0
- data/lib/rest_connection/rightscale/mc_volume.rb +4 -0
- data/lib/rest_connection/rightscale/mc_volume_attachment.rb +4 -0
- data/lib/rest_connection/rightscale/mc_volume_snapshot.rb +4 -0
- data/lib/rest_connection/rightscale/mc_volume_type.rb +4 -0
- data/lib/rest_connection/rightscale/monitoring_metric.rb +4 -0
- data/lib/rest_connection/rightscale/permission.rb +4 -0
- data/lib/rest_connection/rightscale/rightscale_api_base.rb +8 -1
- data/lib/rest_connection/rightscale/rightscale_api_gateway.rb +17 -0
- data/lib/rest_connection/rightscale/rightscale_api_resources.rb +3 -0
- data/lib/rest_connection/rightscale/server.rb +33 -4
- data/lib/rest_connection/rightscale/server_template.rb +8 -0
- data/lib/rest_connection/rightscale/user.rb +4 -0
- data/lib/rest_connection/rightscale/vpc_dhcp_option.rb +19 -0
- data/lib/rest_connection/ssh_hax.rb +6 -1
- data/rest_connection.gemspec +48 -9
- metadata +8 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/rest_connection.rb
CHANGED
@@ -24,13 +24,17 @@ require 'logger'
|
|
24
24
|
require 'highline/import'
|
25
25
|
|
26
26
|
module RestConnection
|
27
|
-
AWS_CLOUDS = [
|
27
|
+
AWS_CLOUDS = [
|
28
|
+
{"cloud_id" => 1, "name" => "AWS US-East"},
|
28
29
|
{"cloud_id" => 2, "name" => "AWS EU"},
|
29
30
|
{"cloud_id" => 3, "name" => "AWS US-West"},
|
30
31
|
{"cloud_id" => 4, "name" => "AWS AP-Singapore"},
|
31
|
-
{"cloud_id" => 5, "name" => "AWS AP-Tokyo"}
|
32
|
+
{"cloud_id" => 5, "name" => "AWS AP-Tokyo"},
|
33
|
+
{"cloud_id" => 6, "name" => "AWS US-Oregon"},
|
34
|
+
{"cloud_id" => 7, "name" => "AWS SA-Sao Paulo"},
|
35
|
+
]
|
32
36
|
|
33
|
-
|
37
|
+
# Check for API 0.1 Access
|
34
38
|
def self.api0_1?
|
35
39
|
unless class_variable_defined?("@@api0_1")
|
36
40
|
begin
|
@@ -0,0 +1,37 @@
|
|
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
|
+
# You must have Beta v1.5 API access to use these internal API calls.
|
18
|
+
#
|
19
|
+
class CloudAccount
|
20
|
+
include RightScale::Api::Gateway
|
21
|
+
extend RightScale::Api::GatewayExtend
|
22
|
+
|
23
|
+
def cloud_id
|
24
|
+
self.cloud.split("/").last
|
25
|
+
end
|
26
|
+
|
27
|
+
def create(opts)
|
28
|
+
location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts)
|
29
|
+
if location =~ /aws/
|
30
|
+
return "AWS Cloud Added successfully"
|
31
|
+
else
|
32
|
+
newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ])
|
33
|
+
newrecord.reload
|
34
|
+
return newrecord
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -19,6 +19,10 @@ class Deployment
|
|
19
19
|
include RightScale::Api::Taggable
|
20
20
|
extend RightScale::Api::TaggableExtend
|
21
21
|
|
22
|
+
def self.filters
|
23
|
+
[:description, :nickname]
|
24
|
+
end
|
25
|
+
|
22
26
|
def reload
|
23
27
|
uri = URI.parse(self.href)
|
24
28
|
@params ? @params.merge!(connection.get(uri.path)) : @params = connection.get(uri.path)
|
@@ -45,7 +49,10 @@ class Deployment
|
|
45
49
|
|
46
50
|
def servers_no_reload
|
47
51
|
connection.logger("WARNING: No Servers in the Deployment!") if @params['servers'].empty?
|
48
|
-
@params['servers'].
|
52
|
+
unless @params['servers'].reduce(true) { |bool,s| bool && s.is_a?(ServerInterface) }
|
53
|
+
@params['servers'].map! { |s| ServerInterface.new(self.cloud_id, s, self.rs_id) }
|
54
|
+
end
|
55
|
+
@params['servers']
|
49
56
|
end
|
50
57
|
|
51
58
|
def servers
|
@@ -71,4 +78,14 @@ class Deployment
|
|
71
78
|
end
|
72
79
|
connection.delete(deploy_href.path)
|
73
80
|
end
|
81
|
+
|
82
|
+
def start_all
|
83
|
+
deploy_href = URI.parse(self.href)
|
84
|
+
connection.post(deploy_href.path + "/start_all")
|
85
|
+
end
|
86
|
+
|
87
|
+
def stop_all
|
88
|
+
deploy_href = URI.parse(self.href)
|
89
|
+
connection.post(deploy_href.path + "/stop_all")
|
90
|
+
end
|
74
91
|
end
|
@@ -44,6 +44,23 @@ class McInstance
|
|
44
44
|
"clouds/#{cloud_id}/"
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.filters
|
48
|
+
[
|
49
|
+
:datacenter_href,
|
50
|
+
:deployment_href,
|
51
|
+
:name,
|
52
|
+
:os_platform,
|
53
|
+
:parent_href,
|
54
|
+
:private_dns_name,
|
55
|
+
:private_ip_address,
|
56
|
+
:public_dns_name,
|
57
|
+
:public_ip_address,
|
58
|
+
:resource_uid,
|
59
|
+
:server_template_href,
|
60
|
+
:state
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
47
64
|
def show
|
48
65
|
inst_href = URI.parse(self.href)
|
49
66
|
@params.merge! connection.get(inst_href.path, 'view' => "full")
|
@@ -40,6 +40,10 @@ class McInstanceType
|
|
40
40
|
"clouds/#{cloud_id}/"
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.filters
|
44
|
+
[:cpu_architecture, :description, :name, :resource_uid]
|
45
|
+
end
|
46
|
+
|
43
47
|
def show
|
44
48
|
inst_href = URI.parse(self.href)
|
45
49
|
@params.merge! connection.get(inst_href.path, 'view' => "default")
|
@@ -39,9 +39,14 @@ class McServerTemplate
|
|
39
39
|
"server_template"
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.filters
|
43
|
+
[:description, :multi_cloud_image_href, :name, :revision]
|
44
|
+
end
|
45
|
+
|
42
46
|
def get_mcis_and_settings
|
43
47
|
@params["multi_cloud_images"] = McMultiCloudImage.find_all(self.rs_id)
|
44
48
|
@params["multi_cloud_images"].each { |mci| mci.get_settings }
|
49
|
+
@mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href)
|
45
50
|
end
|
46
51
|
|
47
52
|
def multi_cloud_images
|
@@ -50,4 +55,49 @@ class McServerTemplate
|
|
50
55
|
end
|
51
56
|
@params["multi_cloud_images"]
|
52
57
|
end
|
58
|
+
|
59
|
+
def add_multi_cloud_image(mci_href)
|
60
|
+
@mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href)
|
61
|
+
if @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href }
|
62
|
+
connection.logger("WARNING: MCI #{mci_href} is already attached")
|
63
|
+
else
|
64
|
+
ret = McServerTemplateMultiCloudImage.create(:multi_cloud_image_href => mci_href,
|
65
|
+
:server_template_href => self.href)
|
66
|
+
get_mcis_and_settings
|
67
|
+
ret
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def detach_multi_cloud_image(mci_href)
|
72
|
+
@mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href)
|
73
|
+
if link = @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href }
|
74
|
+
ret = link.destroy
|
75
|
+
get_mcis_and_settings
|
76
|
+
ret
|
77
|
+
else
|
78
|
+
connection.logger("WARNING: MCI #{mci_href} is not attached")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def set_default_multi_cloud_image(mci_href)
|
83
|
+
@mci_links = McServerTemplateMultiCloudImage.find_with_filter(:server_template_href => self.href)
|
84
|
+
if link = @mci_links.detect { |mci_link| mci_link.multi_cloud_image == mci_href }
|
85
|
+
ret = link.make_default
|
86
|
+
get_mcis_and_settings
|
87
|
+
ret
|
88
|
+
else
|
89
|
+
connection.logger("WARNING: MCI #{mci_href} is not attached")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def commit(message, commit_head_dependencies, freeze_repositories)
|
94
|
+
options = {:commit_message => "#{message}",
|
95
|
+
:commit_head_dependencies => (commit_head_dependencies && true),
|
96
|
+
:freeze_repositories => (freeze_repositories && true)}
|
97
|
+
t = URI.parse(self.href)
|
98
|
+
location = connection.post(t.path + "/commit", options)
|
99
|
+
newrecord = McServerTemplate.new('links' => [ {'rel' => 'self', 'href' => location } ])
|
100
|
+
newrecord.reload
|
101
|
+
newrecord
|
102
|
+
end
|
53
103
|
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
# You must have Beta v1.5 API access to use these internal API calls.
|
18
|
+
#
|
19
|
+
|
20
|
+
class McServerTemplateMultiCloudImage
|
21
|
+
include RightScale::Api::Gateway
|
22
|
+
extend RightScale::Api::GatewayExtend
|
23
|
+
|
24
|
+
def resource_plural_name
|
25
|
+
"server_template_multi_cloud_images"
|
26
|
+
end
|
27
|
+
|
28
|
+
def resource_singular_name
|
29
|
+
"server_template_multi_cloud_image"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.resource_plural_name
|
33
|
+
"server_template_multi_cloud_images"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.resource_singular_name
|
37
|
+
"server_template_multi_cloud_image"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.filters
|
41
|
+
[:is_default, :multi_cloud_image_href, :server_template_href]
|
42
|
+
end
|
43
|
+
|
44
|
+
def make_default
|
45
|
+
my_href = URI.parse(self.href)
|
46
|
+
connection.post(my_href + "/make_default")
|
47
|
+
end
|
48
|
+
end
|
@@ -40,6 +40,10 @@ class McSshKey
|
|
40
40
|
"clouds/#{cloud_id}/"
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.filters
|
44
|
+
[:resource_uid]
|
45
|
+
end
|
46
|
+
|
43
47
|
def self.create(opts)
|
44
48
|
create_opts = { self.resource_singular_name.to_sym => opts }
|
45
49
|
location = connection.post("clouds/#{opts['cloud_id']}/#{self.resource_plural_name}", create_opts)
|
@@ -42,6 +42,10 @@ class McVolume
|
|
42
42
|
"clouds/#{cloud_id}/"
|
43
43
|
end
|
44
44
|
|
45
|
+
def self.filters
|
46
|
+
[:datacenter_href, :description, :name, :parent_volume_snapshot_href, :resource_uid]
|
47
|
+
end
|
48
|
+
|
45
49
|
def show
|
46
50
|
inst_href = URI.parse(self.href)
|
47
51
|
@params.merge! connection.get(inst_href.path, 'view' => 'extended')
|
@@ -41,6 +41,10 @@ class McVolumeAttachment
|
|
41
41
|
return "clouds/#{cloud_id}/volumes/#{instance_id}/" if instance_id
|
42
42
|
end
|
43
43
|
|
44
|
+
def self.filters
|
45
|
+
[:instance_href, :resource_uid, :volume_href]
|
46
|
+
end
|
47
|
+
|
44
48
|
def show
|
45
49
|
inst_href = URI.parse(self.href)
|
46
50
|
@params.merge! connection.get(inst_href.path)
|
@@ -43,6 +43,10 @@ class McVolumeSnapshot
|
|
43
43
|
return "clouds/#{cloud_id}/volumes/#{volume_id}/" if volume_id
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.filters
|
47
|
+
[:description, :name, :parent_volume_href, :resource_uid]
|
48
|
+
end
|
49
|
+
|
46
50
|
def show
|
47
51
|
inst_href = URI.parse(self.href)
|
48
52
|
@params.merge! connection.get(inst_href.path)
|
@@ -24,6 +24,10 @@ class MonitoringMetric
|
|
24
24
|
"clouds/#{cloud_id}/instances/#{instance_id}/"
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.filters
|
28
|
+
[:plugin, :view]
|
29
|
+
end
|
30
|
+
|
27
31
|
def data(start_time = "-60", end_time = "0")
|
28
32
|
params = {'start' => start_time.to_s, 'end' => end_time.to_s}
|
29
33
|
monitor = connection.get(URI.parse(self.href).path + "/data", params)
|
@@ -109,8 +109,11 @@ module RightScale
|
|
109
109
|
def find_with_filter(filter = {})
|
110
110
|
filter_params = []
|
111
111
|
filter.each { |key,val|
|
112
|
+
unless self.filters.include?(key.to_sym)
|
113
|
+
raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
|
114
|
+
end
|
112
115
|
filter_params << "#{key}=#{val}"
|
113
|
-
|
116
|
+
}
|
114
117
|
a = Array.new
|
115
118
|
connection.get(self.resource_plural_name, :filter => filter_params).each do |object|
|
116
119
|
a << self.new(object)
|
@@ -118,6 +121,10 @@ module RightScale
|
|
118
121
|
return a
|
119
122
|
end
|
120
123
|
|
124
|
+
def filters()
|
125
|
+
[]
|
126
|
+
end
|
127
|
+
|
121
128
|
def [](*args)
|
122
129
|
ret = []
|
123
130
|
args.each { |arg|
|
@@ -180,6 +180,16 @@ module RightScale
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
+
def find(*args)
|
184
|
+
if args.length > 1
|
185
|
+
id = args.pop
|
186
|
+
url = "#{parse_args(*args)}#{self.resource_plural_name}/#{id}"
|
187
|
+
return self.new(connection.get(url))
|
188
|
+
else
|
189
|
+
return super(*args)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
183
193
|
def find_all(*args)
|
184
194
|
# self.find_with_filter(*args, {})
|
185
195
|
a = Array.new
|
@@ -195,6 +205,9 @@ module RightScale
|
|
195
205
|
filter = {}
|
196
206
|
filter = args.pop if args.last.is_a?(Hash)
|
197
207
|
filter.each { |key,val|
|
208
|
+
unless self.filters.include?(key.to_sym)
|
209
|
+
raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
|
210
|
+
end
|
198
211
|
filter_params << "#{key}==#{val}"
|
199
212
|
}
|
200
213
|
a = Array.new
|
@@ -221,6 +234,10 @@ module RightScale
|
|
221
234
|
nil
|
222
235
|
end
|
223
236
|
|
237
|
+
def filters()
|
238
|
+
[]
|
239
|
+
end
|
240
|
+
|
224
241
|
def create(opts)
|
225
242
|
location = connection.post(self.resource_plural_name, self.resource_singular_name.to_sym => opts)
|
226
243
|
newrecord = self.new('links' => [ {'rel' => 'self', 'href' => location } ])
|
@@ -21,6 +21,7 @@ require 'rest_connection/rightscale/rightscale_api_taggable'
|
|
21
21
|
require 'rest_connection/rightscale/rightscale_api_mc_taggable'
|
22
22
|
require 'rest_connection/rightscale/rightscale_api_mc_input'
|
23
23
|
require 'rest_connection/rightscale/executable'
|
24
|
+
require 'rest_connection/rightscale/cloud_account'
|
24
25
|
require 'rest_connection/rightscale/server'
|
25
26
|
require 'rest_connection/rightscale/deployment'
|
26
27
|
require 'rest_connection/rightscale/status'
|
@@ -28,6 +29,7 @@ require 'rest_connection/rightscale/server_template'
|
|
28
29
|
require 'rest_connection/rightscale/right_script'
|
29
30
|
require 'rest_connection/rightscale/instance'
|
30
31
|
require 'rest_connection/rightscale/ec2_security_group'
|
32
|
+
require 'rest_connection/rightscale/vpc_dhcp_option'
|
31
33
|
require 'rest_connection/rightscale/ec2_ssh_key'
|
32
34
|
require 'rest_connection/rightscale/multi_cloud_image'
|
33
35
|
require 'rest_connection/rightscale/tag'
|
@@ -49,6 +51,7 @@ require 'rest_connection/rightscale/mc_instance'
|
|
49
51
|
require 'rest_connection/rightscale/monitoring_metric'
|
50
52
|
require 'rest_connection/rightscale/mc_multi_cloud_image_setting'
|
51
53
|
require 'rest_connection/rightscale/mc_multi_cloud_image'
|
54
|
+
require 'rest_connection/rightscale/mc_server_template_multi_cloud_image'
|
52
55
|
require 'rest_connection/rightscale/mc_server_template'
|
53
56
|
require 'rest_connection/rightscale/ec2_ssh_key_internal'
|
54
57
|
require 'rest_connection/rightscale/server_template_internal'
|
@@ -22,6 +22,18 @@ class Server
|
|
22
22
|
include RightScale::Api::Taggable
|
23
23
|
extend RightScale::Api::TaggableExtend
|
24
24
|
|
25
|
+
def self.filters
|
26
|
+
[
|
27
|
+
:aws_id,
|
28
|
+
:created_at,
|
29
|
+
:deployment_href,
|
30
|
+
:ip_address,
|
31
|
+
:nickname,
|
32
|
+
:private_ip_address,
|
33
|
+
:updated_at
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
25
37
|
def self.create(opts)
|
26
38
|
create_options = Hash.new
|
27
39
|
create_options[self.resource_singular_name.to_sym] = opts
|
@@ -73,6 +85,7 @@ class Server
|
|
73
85
|
catch_early_terminated = 60 / step
|
74
86
|
while(timeout > 0)
|
75
87
|
return true if state =~ /#{st}/
|
88
|
+
return true if state =~ /terminated|stopped/ && st =~ /terminated|stopped/
|
76
89
|
raise "FATAL error, this server is stranded and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('stranded') && !st.include?('stranded')
|
77
90
|
raise "FATAL error, this server went to error state and needs to be #{st}: #{nickname}, see audit: #{self.audit_link}" if state.include?('error') && st !~ /error|terminated|stopped/
|
78
91
|
connection.logger("waiting for server #{nickname} to go #{st}, state is #{state}")
|
@@ -144,13 +157,25 @@ class Server
|
|
144
157
|
|
145
158
|
# Uses ServerInternal api to start and stop EBS based instances
|
146
159
|
def start_ebs
|
147
|
-
@server_internal = ServerInternal.new(:href => self.href)
|
148
|
-
@server_internal.start
|
160
|
+
# @server_internal = ServerInternal.new(:href => self.href)
|
161
|
+
# @server_internal.start
|
162
|
+
if self.state == "stopped"
|
163
|
+
t = URI.parse(self.href)
|
164
|
+
return connection.post(t.path + '/start_ebs')
|
165
|
+
else
|
166
|
+
connection.logger("WARNING: was in #{self.state} so skiping start_ebs call")
|
167
|
+
end
|
149
168
|
end
|
150
169
|
|
151
170
|
def stop_ebs
|
152
|
-
@server_internal = ServerInternal.new(:href => self.href)
|
153
|
-
@server_internal.stop
|
171
|
+
# @server_internal = ServerInternal.new(:href => self.href)
|
172
|
+
# @server_internal.stop
|
173
|
+
if self.current_instance_href
|
174
|
+
t = URI.parse(self.href)
|
175
|
+
connection.post(t.path + '/stop_ebs')
|
176
|
+
else
|
177
|
+
connection.logger("WARNING: was in #{self.state} and had a current_instance_href so skiping stop_ebs call")
|
178
|
+
end
|
154
179
|
end
|
155
180
|
|
156
181
|
# Works on v4 and v5 images.
|
@@ -260,6 +285,10 @@ class Server
|
|
260
285
|
end
|
261
286
|
end
|
262
287
|
|
288
|
+
def alert_specs
|
289
|
+
# TODO
|
290
|
+
end
|
291
|
+
|
263
292
|
def relaunch
|
264
293
|
self.stop
|
265
294
|
self.wait_for_state("stopped")
|
@@ -23,6 +23,14 @@ class ServerTemplate
|
|
23
23
|
@params = params
|
24
24
|
end
|
25
25
|
|
26
|
+
def reload
|
27
|
+
ret = connection.get(URI.parse(self.href).path, :include_mcis => true)
|
28
|
+
@params ? @params.merge!(ret) : @params = ret
|
29
|
+
@params["multi_cloud_images"].map! { |mci_params| MultiCloudImage.new(mci_params) }
|
30
|
+
@params["default_multi_cloud_image"] = MultiCloudImage.new(@params["default_multi_cloud_image"])
|
31
|
+
@params
|
32
|
+
end
|
33
|
+
|
26
34
|
def executables
|
27
35
|
unless @params["executables"]
|
28
36
|
fetch_executables
|
@@ -0,0 +1,19 @@
|
|
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
|
+
class VpcDhcpOption
|
17
|
+
include RightScale::Api::Base
|
18
|
+
extend RightScale::Api::BaseExtend
|
19
|
+
end
|
@@ -154,7 +154,11 @@ module SshHax
|
|
154
154
|
while (!success && retry_count < SSH_RETRY_COUNT) do
|
155
155
|
begin
|
156
156
|
# Test for ability to connect; Net::SSH.start sometimes hangs under certain server-side sshd configs
|
157
|
-
test_ssh =
|
157
|
+
test_ssh = ""
|
158
|
+
[5, 15, 60].each { |timeout_max|
|
159
|
+
test_ssh = `ssh -o \"BatchMode=yes\" -o \"ConnectTimeout #{timeout_max}\" root@#{host_dns} -C \"exit\" 2>&1`.chomp
|
160
|
+
break if test_ssh =~ /permission denied/i or test_ssh.empty?
|
161
|
+
}
|
158
162
|
raise test_ssh unless test_ssh =~ /permission denied/i or test_ssh.empty?
|
159
163
|
|
160
164
|
Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key), :user_known_hosts_file => "/dev/null") do |ssh|
|
@@ -179,6 +183,7 @@ module SshHax
|
|
179
183
|
retry_count += 1 # opening the ssh channel failed -- try again.
|
180
184
|
connection.logger "ERROR during SSH session to #{host_dns}, retrying #{retry_count}: #{e} #{e.backtrace}"
|
181
185
|
sleep 10
|
186
|
+
raise e unless retry_count < SSH_RETRY_COUNT
|
182
187
|
end
|
183
188
|
end
|
184
189
|
connection.logger "SSH Run: #{command} on #{host_dns}. Retry was #{retry_count}. Exit status was #{status}. Output below ---\n#{output}\n---" unless do_not_log_result
|
data/rest_connection.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0
|
7
|
+
s.name = "rest_connection"
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jeremy Deininger"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Jeremy Deininger", "Timothy Rodriguez"]
|
12
|
+
s.date = "2011-11-01"
|
13
|
+
s.description = "provides rest_connection"
|
14
|
+
s.email = ["jeremy@rubyonlinux.org", "tw.rodriguez@gmail.com"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
@@ -29,9 +29,16 @@ Gem::Specification.new do |s|
|
|
29
29
|
"examples/cucumber/step_definitions/spot_check_steps.rb",
|
30
30
|
"examples/relaunch_deployment.rb",
|
31
31
|
"examples/right_scale_ec2_instances_api_test.rb",
|
32
|
+
"git_hooks/post-commit.disabled",
|
33
|
+
"git_hooks/post-merge.disabled",
|
34
|
+
"git_hooks/pre-commit",
|
32
35
|
"lib/rest_connection.rb",
|
36
|
+
"lib/rest_connection/patches.rb",
|
37
|
+
"lib/rest_connection/rightscale/account.rb",
|
33
38
|
"lib/rest_connection/rightscale/alert_spec.rb",
|
34
39
|
"lib/rest_connection/rightscale/audit_entry.rb",
|
40
|
+
"lib/rest_connection/rightscale/child_account.rb",
|
41
|
+
"lib/rest_connection/rightscale/cloud.rb",
|
35
42
|
"lib/rest_connection/rightscale/credential.rb",
|
36
43
|
"lib/rest_connection/rightscale/deployment.rb",
|
37
44
|
"lib/rest_connection/rightscale/ec2_ebs_snapshot.rb",
|
@@ -43,29 +50,58 @@ Gem::Specification.new do |s|
|
|
43
50
|
"lib/rest_connection/rightscale/ec2_ssh_key_internal.rb",
|
44
51
|
"lib/rest_connection/rightscale/executable.rb",
|
45
52
|
"lib/rest_connection/rightscale/instance.rb",
|
53
|
+
"lib/rest_connection/rightscale/instance_type.rb",
|
54
|
+
"lib/rest_connection/rightscale/macro.rb",
|
55
|
+
"lib/rest_connection/rightscale/mc_datacenter.rb",
|
56
|
+
"lib/rest_connection/rightscale/mc_deployment.rb",
|
57
|
+
"lib/rest_connection/rightscale/mc_image.rb",
|
58
|
+
"lib/rest_connection/rightscale/mc_instance.rb",
|
59
|
+
"lib/rest_connection/rightscale/mc_instance_type.rb",
|
60
|
+
"lib/rest_connection/rightscale/mc_multi_cloud_image.rb",
|
61
|
+
"lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb",
|
62
|
+
"lib/rest_connection/rightscale/mc_security_group.rb",
|
46
63
|
"lib/rest_connection/rightscale/mc_server.rb",
|
64
|
+
"lib/rest_connection/rightscale/mc_server_array.rb",
|
65
|
+
"lib/rest_connection/rightscale/mc_server_template.rb",
|
66
|
+
"lib/rest_connection/rightscale/mc_ssh_key.rb",
|
67
|
+
"lib/rest_connection/rightscale/mc_tag.rb",
|
68
|
+
"lib/rest_connection/rightscale/mc_volume.rb",
|
69
|
+
"lib/rest_connection/rightscale/mc_volume_attachment.rb",
|
70
|
+
"lib/rest_connection/rightscale/mc_volume_snapshot.rb",
|
71
|
+
"lib/rest_connection/rightscale/mc_volume_type.rb",
|
72
|
+
"lib/rest_connection/rightscale/monitoring_metric.rb",
|
47
73
|
"lib/rest_connection/rightscale/multi_cloud_image.rb",
|
48
74
|
"lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb",
|
49
75
|
"lib/rest_connection/rightscale/multi_cloud_image_internal.rb",
|
76
|
+
"lib/rest_connection/rightscale/permission.rb",
|
50
77
|
"lib/rest_connection/rightscale/right_script.rb",
|
51
78
|
"lib/rest_connection/rightscale/right_script_internal.rb",
|
52
79
|
"lib/rest_connection/rightscale/rightscale_api_base.rb",
|
53
80
|
"lib/rest_connection/rightscale/rightscale_api_gateway.rb",
|
54
81
|
"lib/rest_connection/rightscale/rightscale_api_internal.rb",
|
82
|
+
"lib/rest_connection/rightscale/rightscale_api_mc_input.rb",
|
83
|
+
"lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb",
|
55
84
|
"lib/rest_connection/rightscale/rightscale_api_resources.rb",
|
85
|
+
"lib/rest_connection/rightscale/rightscale_api_taggable.rb",
|
56
86
|
"lib/rest_connection/rightscale/rs_internal.rb",
|
87
|
+
"lib/rest_connection/rightscale/s3_bucket.rb",
|
57
88
|
"lib/rest_connection/rightscale/server.rb",
|
89
|
+
"lib/rest_connection/rightscale/server_interface.rb",
|
58
90
|
"lib/rest_connection/rightscale/server_internal.rb",
|
59
91
|
"lib/rest_connection/rightscale/server_template.rb",
|
60
92
|
"lib/rest_connection/rightscale/server_template_internal.rb",
|
61
93
|
"lib/rest_connection/rightscale/status.rb",
|
62
94
|
"lib/rest_connection/rightscale/tag.rb",
|
95
|
+
"lib/rest_connection/rightscale/task.rb",
|
96
|
+
"lib/rest_connection/rightscale/user.rb",
|
63
97
|
"lib/rest_connection/ssh_hax.rb",
|
64
98
|
"rest_connection.gemspec",
|
65
99
|
"spec/ec2_server_array_spec.rb",
|
66
100
|
"spec/ec2_ssh_key_internal_spec.rb",
|
67
101
|
"spec/image_jockey.rb",
|
102
|
+
"spec/mcserver_spec.rb",
|
68
103
|
"spec/method_missing_spec.rb",
|
104
|
+
"spec/multi.rb",
|
69
105
|
"spec/right_script_internal.rb",
|
70
106
|
"spec/rs_internal_spec.rb",
|
71
107
|
"spec/server_internal_spec.rb",
|
@@ -74,10 +110,10 @@ Gem::Specification.new do |s|
|
|
74
110
|
"spec/spec_helper.rb",
|
75
111
|
"spec/tag_spec.rb"
|
76
112
|
]
|
77
|
-
s.homepage =
|
113
|
+
s.homepage = "http://github.com/twrodriguez/rest_connection"
|
78
114
|
s.require_paths = ["lib"]
|
79
|
-
s.rubygems_version =
|
80
|
-
s.summary =
|
115
|
+
s.rubygems_version = "1.7.2"
|
116
|
+
s.summary = "lib for restful connections to the rightscale api"
|
81
117
|
|
82
118
|
if s.respond_to? :specification_version then
|
83
119
|
s.specification_version = 3
|
@@ -86,15 +122,18 @@ Gem::Specification.new do |s|
|
|
86
122
|
s.add_runtime_dependency(%q<activesupport>, ["= 2.3.10"])
|
87
123
|
s.add_runtime_dependency(%q<net-ssh>, ["= 2.1.4"])
|
88
124
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
125
|
+
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
89
126
|
else
|
90
127
|
s.add_dependency(%q<activesupport>, ["= 2.3.10"])
|
91
128
|
s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
|
92
129
|
s.add_dependency(%q<json>, [">= 0"])
|
130
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
93
131
|
end
|
94
132
|
else
|
95
133
|
s.add_dependency(%q<activesupport>, ["= 2.3.10"])
|
96
134
|
s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
|
97
135
|
s.add_dependency(%q<json>, [">= 0"])
|
136
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
98
137
|
end
|
99
138
|
end
|
100
139
|
|
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: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Deininger
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-12-17 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/rest_connection/rightscale/audit_entry.rb
|
113
113
|
- lib/rest_connection/rightscale/child_account.rb
|
114
114
|
- lib/rest_connection/rightscale/cloud.rb
|
115
|
+
- lib/rest_connection/rightscale/cloud_account.rb
|
115
116
|
- lib/rest_connection/rightscale/credential.rb
|
116
117
|
- lib/rest_connection/rightscale/deployment.rb
|
117
118
|
- lib/rest_connection/rightscale/ec2_ebs_snapshot.rb
|
@@ -136,6 +137,7 @@ files:
|
|
136
137
|
- lib/rest_connection/rightscale/mc_server.rb
|
137
138
|
- lib/rest_connection/rightscale/mc_server_array.rb
|
138
139
|
- lib/rest_connection/rightscale/mc_server_template.rb
|
140
|
+
- lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb
|
139
141
|
- lib/rest_connection/rightscale/mc_ssh_key.rb
|
140
142
|
- lib/rest_connection/rightscale/mc_tag.rb
|
141
143
|
- lib/rest_connection/rightscale/mc_volume.rb
|
@@ -167,6 +169,7 @@ files:
|
|
167
169
|
- lib/rest_connection/rightscale/tag.rb
|
168
170
|
- lib/rest_connection/rightscale/task.rb
|
169
171
|
- lib/rest_connection/rightscale/user.rb
|
172
|
+
- lib/rest_connection/rightscale/vpc_dhcp_option.rb
|
170
173
|
- lib/rest_connection/ssh_hax.rb
|
171
174
|
- rest_connection.gemspec
|
172
175
|
- spec/ec2_server_array_spec.rb
|
@@ -211,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
214
|
requirements: []
|
212
215
|
|
213
216
|
rubyforge_project:
|
214
|
-
rubygems_version: 1.
|
217
|
+
rubygems_version: 1.8.10
|
215
218
|
signing_key:
|
216
219
|
specification_version: 3
|
217
220
|
summary: lib for restful connections to the rightscale api
|