rest_connection 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/rest_connection/rightscale/ec2_server_array_internal.rb +7 -5
- data/lib/rest_connection.rb +15 -1
- metadata +18 -5
- data/rest_connection.gemspec +0 -155
data/README.rdoc
CHANGED
@@ -53,4 +53,4 @@ Copy the example from GEMHOME/rest_connection/examples/rest_api_config.yaml.samp
|
|
53
53
|
rake gemspec
|
54
54
|
rake install
|
55
55
|
visit www.rubygems.org
|
56
|
-
gem push rest_connection-0.0.0.gem (use your new version number in this command)
|
56
|
+
gem push pkg/rest_connection-0.0.0.gem (use your new version number in this command)
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
@@ -16,9 +16,9 @@
|
|
16
16
|
class Ec2ServerArrayInternal
|
17
17
|
include RightScale::Api::Base
|
18
18
|
extend RightScale::Api::BaseExtend
|
19
|
-
include RightScale::Api::
|
20
|
-
extend RightScale::Api::
|
21
|
-
|
19
|
+
include RightScale::Api::Internal
|
20
|
+
extend RightScale::Api::InternalExtend
|
21
|
+
|
22
22
|
deny_methods :index, :show, :create, :update, :destroy
|
23
23
|
|
24
24
|
def run_script_on_instances(script, ec2_instance_hrefs=[], opts={})
|
@@ -28,7 +28,7 @@ class Ec2ServerArrayInternal
|
|
28
28
|
when String then script = RightScript.new('href' => script)
|
29
29
|
end
|
30
30
|
|
31
|
-
params = {:right_script_href => script.href}
|
31
|
+
params = {:right_script_href => script.href }
|
32
32
|
unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty?
|
33
33
|
params[:ec2_instance_hrefs] = ec2_instance_hrefs
|
34
34
|
end
|
@@ -36,8 +36,10 @@ class Ec2ServerArrayInternal
|
|
36
36
|
params[:parameters] = opts
|
37
37
|
end
|
38
38
|
params = {:ec2_server_array => params}
|
39
|
+
status_array=[]
|
39
40
|
connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit|
|
40
|
-
Status.new('href' =>
|
41
|
+
status_array.push Status.new('href' => work_unit)
|
41
42
|
end
|
43
|
+
return(status_array)
|
42
44
|
end
|
43
45
|
end
|
data/lib/rest_connection.rb
CHANGED
@@ -22,6 +22,7 @@ require 'rest_connection/rightscale/rightscale_api_resources'
|
|
22
22
|
require 'rest_connection/patches'
|
23
23
|
require 'logger'
|
24
24
|
require 'highline/import'
|
25
|
+
require 'nokogiri'
|
25
26
|
|
26
27
|
module RestConnection
|
27
28
|
class Connection
|
@@ -204,8 +205,21 @@ module RestConnection
|
|
204
205
|
# decoding and post processing goes here. This is where you may need some customization if you want to handle the response differently (or not at all!). Luckily it's easy to modify based on this handler.
|
205
206
|
def handle_response(res)
|
206
207
|
if res.code.to_i == 201 or res.code.to_i == 202
|
207
|
-
|
208
|
+
#
|
209
|
+
# In most cases, it's safe to return the location
|
210
|
+
#
|
211
|
+
if res['Location']
|
212
|
+
return res['Location']
|
213
|
+
else
|
214
|
+
#
|
215
|
+
# Ec2ServerArrayInternal.run_script_on_instances returns XML.
|
216
|
+
# We need to parse it to retrieve the href's to audit entries.
|
217
|
+
#
|
218
|
+
xml_response = Nokogiri::XML(res.body)
|
219
|
+
return xml_response.xpath('audit-entries/audit-entry/href').map { |href| href.content }
|
220
|
+
end
|
208
221
|
elsif [200,203,204].detect { |d| d == res.code.to_i }
|
222
|
+
|
209
223
|
if res.body
|
210
224
|
begin
|
211
225
|
return JSON.load(res.body)
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
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: 2012-03-
|
19
|
+
date: 2012-03-14 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
version: "0"
|
93
93
|
type: :runtime
|
94
94
|
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: nokogiri
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
type: :runtime
|
108
|
+
version_requirements: *id006
|
95
109
|
description: "A Modular RESTful API library. Current implemented modules: RightScale API"
|
96
110
|
email:
|
97
111
|
- daniel.onorato@rightscale.com
|
@@ -194,7 +208,6 @@ files:
|
|
194
208
|
- lib/rest_connection/rightscale/user.rb
|
195
209
|
- lib/rest_connection/rightscale/vpc_dhcp_option.rb
|
196
210
|
- lib/rest_connection/ssh_hax.rb
|
197
|
-
- rest_connection.gemspec
|
198
211
|
- spec/ec2_server_array_spec.rb
|
199
212
|
- spec/ec2_ssh_key_internal_spec.rb
|
200
213
|
- spec/image_jockey.rb
|
data/rest_connection.gemspec
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "rest_connection"
|
8
|
-
s.version = "0.1.6"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jeremy Deininger", "Timothy Rodriguez"]
|
12
|
-
s.date = "2012-03-06"
|
13
|
-
s.description = "A Modular RESTful API library. Current implemented modules: RightScale API"
|
14
|
-
s.email = ["daniel.onorato@rightscale.com"]
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
"README.rdoc",
|
20
|
-
"Rakefile",
|
21
|
-
"VERSION",
|
22
|
-
"config/rest_api_config.yaml.sample",
|
23
|
-
"examples/README.txt",
|
24
|
-
"examples/console.rb",
|
25
|
-
"examples/cucumber/2mysql_5.x_v2_beta_from_scratch.feature",
|
26
|
-
"examples/cucumber/step_definitions/deployment_steps.rb",
|
27
|
-
"examples/cucumber/step_definitions/mysql_steps.rb",
|
28
|
-
"examples/cucumber/step_definitions/recipe_steps.rb",
|
29
|
-
"examples/cucumber/step_definitions/spot_check_steps.rb",
|
30
|
-
"examples/relaunch_deployment.rb",
|
31
|
-
"examples/right_scale_ec2_instances_api_test.rb",
|
32
|
-
"git_hooks/post-commit",
|
33
|
-
"git_hooks/post-commit.disabled",
|
34
|
-
"git_hooks/post-merge.disabled",
|
35
|
-
"git_hooks/pre-commit",
|
36
|
-
"lib/rest_connection.rb",
|
37
|
-
"lib/rest_connection/patches.rb",
|
38
|
-
"lib/rest_connection/rightscale/account.rb",
|
39
|
-
"lib/rest_connection/rightscale/alert_spec.rb",
|
40
|
-
"lib/rest_connection/rightscale/alert_spec_subject.rb",
|
41
|
-
"lib/rest_connection/rightscale/audit_entry.rb",
|
42
|
-
"lib/rest_connection/rightscale/backup.rb",
|
43
|
-
"lib/rest_connection/rightscale/child_account.rb",
|
44
|
-
"lib/rest_connection/rightscale/cloud.rb",
|
45
|
-
"lib/rest_connection/rightscale/cloud_account.rb",
|
46
|
-
"lib/rest_connection/rightscale/credential.rb",
|
47
|
-
"lib/rest_connection/rightscale/deployment.rb",
|
48
|
-
"lib/rest_connection/rightscale/ec2_ebs_snapshot.rb",
|
49
|
-
"lib/rest_connection/rightscale/ec2_ebs_volume.rb",
|
50
|
-
"lib/rest_connection/rightscale/ec2_elastic_ip.rb",
|
51
|
-
"lib/rest_connection/rightscale/ec2_security_group.rb",
|
52
|
-
"lib/rest_connection/rightscale/ec2_server_array.rb",
|
53
|
-
"lib/rest_connection/rightscale/ec2_server_array_internal.rb",
|
54
|
-
"lib/rest_connection/rightscale/ec2_ssh_key.rb",
|
55
|
-
"lib/rest_connection/rightscale/ec2_ssh_key_internal.rb",
|
56
|
-
"lib/rest_connection/rightscale/executable.rb",
|
57
|
-
"lib/rest_connection/rightscale/instance.rb",
|
58
|
-
"lib/rest_connection/rightscale/instance_type.rb",
|
59
|
-
"lib/rest_connection/rightscale/macro.rb",
|
60
|
-
"lib/rest_connection/rightscale/mc_audit_entry.rb",
|
61
|
-
"lib/rest_connection/rightscale/mc_datacenter.rb",
|
62
|
-
"lib/rest_connection/rightscale/mc_deployment.rb",
|
63
|
-
"lib/rest_connection/rightscale/mc_image.rb",
|
64
|
-
"lib/rest_connection/rightscale/mc_instance.rb",
|
65
|
-
"lib/rest_connection/rightscale/mc_instance_type.rb",
|
66
|
-
"lib/rest_connection/rightscale/mc_multi_cloud_image.rb",
|
67
|
-
"lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb",
|
68
|
-
"lib/rest_connection/rightscale/mc_security_group.rb",
|
69
|
-
"lib/rest_connection/rightscale/mc_server.rb",
|
70
|
-
"lib/rest_connection/rightscale/mc_server_array.rb",
|
71
|
-
"lib/rest_connection/rightscale/mc_server_template.rb",
|
72
|
-
"lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb",
|
73
|
-
"lib/rest_connection/rightscale/mc_ssh_key.rb",
|
74
|
-
"lib/rest_connection/rightscale/mc_tag.rb",
|
75
|
-
"lib/rest_connection/rightscale/mc_volume.rb",
|
76
|
-
"lib/rest_connection/rightscale/mc_volume_attachment.rb",
|
77
|
-
"lib/rest_connection/rightscale/mc_volume_snapshot.rb",
|
78
|
-
"lib/rest_connection/rightscale/mc_volume_type.rb",
|
79
|
-
"lib/rest_connection/rightscale/monitoring_metric.rb",
|
80
|
-
"lib/rest_connection/rightscale/multi_cloud_image.rb",
|
81
|
-
"lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb",
|
82
|
-
"lib/rest_connection/rightscale/multi_cloud_image_internal.rb",
|
83
|
-
"lib/rest_connection/rightscale/permission.rb",
|
84
|
-
"lib/rest_connection/rightscale/right_script.rb",
|
85
|
-
"lib/rest_connection/rightscale/right_script_attachment_internal.rb",
|
86
|
-
"lib/rest_connection/rightscale/right_script_internal.rb",
|
87
|
-
"lib/rest_connection/rightscale/rightscale_api_base.rb",
|
88
|
-
"lib/rest_connection/rightscale/rightscale_api_gateway.rb",
|
89
|
-
"lib/rest_connection/rightscale/rightscale_api_internal.rb",
|
90
|
-
"lib/rest_connection/rightscale/rightscale_api_mc_input.rb",
|
91
|
-
"lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb",
|
92
|
-
"lib/rest_connection/rightscale/rightscale_api_resources.rb",
|
93
|
-
"lib/rest_connection/rightscale/rightscale_api_taggable.rb",
|
94
|
-
"lib/rest_connection/rightscale/rs_internal.rb",
|
95
|
-
"lib/rest_connection/rightscale/s3_bucket.rb",
|
96
|
-
"lib/rest_connection/rightscale/security_group_rule.rb",
|
97
|
-
"lib/rest_connection/rightscale/server.rb",
|
98
|
-
"lib/rest_connection/rightscale/server_ec2_ebs_volume.rb",
|
99
|
-
"lib/rest_connection/rightscale/server_interface.rb",
|
100
|
-
"lib/rest_connection/rightscale/server_internal.rb",
|
101
|
-
"lib/rest_connection/rightscale/server_template.rb",
|
102
|
-
"lib/rest_connection/rightscale/server_template_internal.rb",
|
103
|
-
"lib/rest_connection/rightscale/session.rb",
|
104
|
-
"lib/rest_connection/rightscale/sqs_queue.rb",
|
105
|
-
"lib/rest_connection/rightscale/status.rb",
|
106
|
-
"lib/rest_connection/rightscale/tag.rb",
|
107
|
-
"lib/rest_connection/rightscale/task.rb",
|
108
|
-
"lib/rest_connection/rightscale/user.rb",
|
109
|
-
"lib/rest_connection/rightscale/vpc_dhcp_option.rb",
|
110
|
-
"lib/rest_connection/ssh_hax.rb",
|
111
|
-
"rest_connection.gemspec",
|
112
|
-
"spec/ec2_server_array_spec.rb",
|
113
|
-
"spec/ec2_ssh_key_internal_spec.rb",
|
114
|
-
"spec/image_jockey.rb",
|
115
|
-
"spec/mcserver_spec.rb",
|
116
|
-
"spec/method_missing_spec.rb",
|
117
|
-
"spec/multi.rb",
|
118
|
-
"spec/right_script_internal.rb",
|
119
|
-
"spec/rs_internal_spec.rb",
|
120
|
-
"spec/server_internal_spec.rb",
|
121
|
-
"spec/server_spec.rb",
|
122
|
-
"spec/server_template_internal.rb",
|
123
|
-
"spec/spec_helper.rb",
|
124
|
-
"spec/tag_spec.rb"
|
125
|
-
]
|
126
|
-
s.homepage = "http://github.com/rightscale/rest_connection"
|
127
|
-
s.require_paths = ["lib"]
|
128
|
-
s.rubygems_version = "1.8.17"
|
129
|
-
s.summary = "Modular RESTful API library"
|
130
|
-
|
131
|
-
if s.respond_to? :specification_version then
|
132
|
-
s.specification_version = 3
|
133
|
-
|
134
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
135
|
-
s.add_runtime_dependency(%q<activesupport>, ["= 2.3.10"])
|
136
|
-
s.add_runtime_dependency(%q<net-ssh>, ["= 2.1.4"])
|
137
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
138
|
-
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
139
|
-
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
140
|
-
else
|
141
|
-
s.add_dependency(%q<activesupport>, ["= 2.3.10"])
|
142
|
-
s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
|
143
|
-
s.add_dependency(%q<json>, [">= 0"])
|
144
|
-
s.add_dependency(%q<highline>, [">= 0"])
|
145
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
146
|
-
end
|
147
|
-
else
|
148
|
-
s.add_dependency(%q<activesupport>, ["= 2.3.10"])
|
149
|
-
s.add_dependency(%q<net-ssh>, ["= 2.1.4"])
|
150
|
-
s.add_dependency(%q<json>, [">= 0"])
|
151
|
-
s.add_dependency(%q<highline>, [">= 0"])
|
152
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|