rest_connection 1.0.5 → 1.0.6
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/README.md +140 -0
- data/lib/rest_connection/rightscale/account.rb +1 -1
- data/lib/rest_connection/rightscale/alert_spec.rb +3 -0
- data/lib/rest_connection/rightscale/alert_spec_subject.rb +3 -0
- data/lib/rest_connection/rightscale/audit_entry.rb +3 -0
- data/lib/rest_connection/rightscale/backup.rb +1 -1
- data/lib/rest_connection/rightscale/child_account.rb +1 -1
- data/lib/rest_connection/rightscale/cloud.rb +1 -1
- data/lib/rest_connection/rightscale/cloud_account.rb +1 -1
- data/lib/rest_connection/rightscale/credential.rb +3 -0
- data/lib/rest_connection/rightscale/deployment.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_ebs_snapshot.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_ebs_volume.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_elastic_ip.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_security_group.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_server_array.rb +34 -3
- data/lib/rest_connection/rightscale/ec2_ssh_key.rb +3 -0
- data/lib/rest_connection/rightscale/ec2_ssh_key_internal.rb +3 -0
- data/lib/rest_connection/rightscale/executable.rb +3 -0
- data/lib/rest_connection/rightscale/instance.rb +5 -3
- data/lib/rest_connection/rightscale/instance_type.rb +1 -1
- data/lib/rest_connection/rightscale/macro.rb +3 -0
- data/lib/rest_connection/rightscale/mc_audit_entry.rb +1 -1
- data/lib/rest_connection/rightscale/mc_datacenter.rb +1 -1
- data/lib/rest_connection/rightscale/mc_deployment.rb +1 -1
- data/lib/rest_connection/rightscale/mc_image.rb +1 -1
- data/lib/rest_connection/rightscale/mc_instance.rb +9 -2
- data/lib/rest_connection/rightscale/mc_instance_type.rb +1 -1
- data/lib/rest_connection/rightscale/mc_multi_cloud_image.rb +1 -1
- data/lib/rest_connection/rightscale/mc_multi_cloud_image_setting.rb +1 -1
- data/lib/rest_connection/rightscale/mc_security_group.rb +1 -1
- data/lib/rest_connection/rightscale/mc_server.rb +3 -3
- data/lib/rest_connection/rightscale/mc_server_array.rb +1 -1
- data/lib/rest_connection/rightscale/mc_server_template.rb +1 -1
- data/lib/rest_connection/rightscale/mc_server_template_multi_cloud_image.rb +1 -1
- data/lib/rest_connection/rightscale/mc_ssh_key.rb +1 -1
- data/lib/rest_connection/rightscale/mc_tag.rb +1 -1
- data/lib/rest_connection/rightscale/mc_volume.rb +1 -1
- data/lib/rest_connection/rightscale/mc_volume_attachment.rb +1 -1
- data/lib/rest_connection/rightscale/mc_volume_snapshot.rb +1 -1
- data/lib/rest_connection/rightscale/mc_volume_type.rb +1 -1
- data/lib/rest_connection/rightscale/monitoring_metric.rb +1 -1
- data/lib/rest_connection/rightscale/multi_cloud_image.rb +3 -0
- data/lib/rest_connection/rightscale/multi_cloud_image_cloud_setting_internal.rb +3 -0
- data/lib/rest_connection/rightscale/multi_cloud_image_internal.rb +3 -0
- data/lib/rest_connection/rightscale/permission.rb +1 -1
- data/lib/rest_connection/rightscale/right_script.rb +3 -0
- data/lib/rest_connection/rightscale/right_script_attachment_internal.rb +3 -0
- data/lib/rest_connection/rightscale/right_script_internal.rb +3 -1
- data/lib/rest_connection/rightscale/rightscale_api_base.rb +28 -8
- data/lib/rest_connection/rightscale/rightscale_api_gateway.rb +12 -0
- data/lib/rest_connection/rightscale/rightscale_api_internal.rb +8 -0
- data/lib/rest_connection/rightscale/rightscale_api_mc_input.rb +1 -1
- data/lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb +1 -1
- data/lib/rest_connection/rightscale/rightscale_api_resources.rb +0 -1
- data/lib/rest_connection/rightscale/rs_internal.rb +1 -1
- data/lib/rest_connection/rightscale/s3_bucket.rb +3 -0
- data/lib/rest_connection/rightscale/security_group_rule.rb +1 -1
- data/lib/rest_connection/rightscale/server.rb +3 -0
- data/lib/rest_connection/rightscale/server_ec2_ebs_volume.rb +3 -0
- data/lib/rest_connection/rightscale/server_internal.rb +1 -1
- data/lib/rest_connection/rightscale/server_template.rb +3 -0
- data/lib/rest_connection/rightscale/server_template_internal.rb +3 -0
- data/lib/rest_connection/rightscale/session.rb +1 -1
- data/lib/rest_connection/rightscale/sqs_queue.rb +3 -0
- data/lib/rest_connection/rightscale/status.rb +3 -0
- data/lib/rest_connection/rightscale/tag.rb +3 -0
- data/lib/rest_connection/rightscale/task.rb +1 -1
- data/lib/rest_connection/rightscale/user.rb +1 -1
- data/lib/rest_connection/rightscale/vpc_dhcp_option.rb +3 -0
- data/lib/rest_connection/ssh_hax.rb +1 -1
- data/lib/rest_connection/version.rb +1 -1
- data/lib/rest_connection.rb +6 -0
- data/rest_connection.gemspec +2 -2
- metadata +43 -49
- data/Gemfile.lock +0 -43
- data/README.rdoc +0 -63
- data/lib/rest_connection/rightscale/ec2_server_array_internal.rb +0 -53
data/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# RightScale REST Connection
|
|
2
|
+
|
|
3
|
+
The rest_connection gem is a Ruby library for RightScale's API 0.1, 1.0 and 1.5.
|
|
4
|
+
|
|
5
|
+
Legacy clusters:
|
|
6
|
+
- API 0.1 AWS clouds
|
|
7
|
+
- API 1.0 AWS clouds
|
|
8
|
+
- API 1.5 non-AWS clouds
|
|
9
|
+
|
|
10
|
+
Unified clusters:
|
|
11
|
+
- API 1.0 AWS clouds
|
|
12
|
+
- API 1.5 all clouds
|
|
13
|
+
|
|
14
|
+
This gem also supports RightScale's instance facing API 1.0, which use the instance token to login.
|
|
15
|
+
The instance token is found in the instance's user data as 'RS_rn_auth' or alternatively as part of 'RS_api_url'.
|
|
16
|
+
The user data is available under the 'Info' tab on the server's page in the RightScale Dashboard.
|
|
17
|
+
|
|
18
|
+
This gem should be considered deprecated!
|
|
19
|
+
|
|
20
|
+
If you only use API 1.5, you should use the right_api_client gem instead:
|
|
21
|
+
https://rubygems.org/gems/right_api_client
|
|
22
|
+
|
|
23
|
+
- API 1.0 Documentation: http://support.rightscale.com/12-Guides/03-RightScale_API
|
|
24
|
+
- API 1.0 Reference Docs: http://reference.rightscale.com/api1.0
|
|
25
|
+
- API 1.5 Documentation: http://support.rightscale.com/12-Guides/RightScale_API_1.5
|
|
26
|
+
- API 1.5 Reference Docs: http://reference.rightscale.com/api1.5
|
|
27
|
+
|
|
28
|
+
Maintained by the RightScale "Yellow_team"
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Ruby 1.8.7 or higher is required.
|
|
33
|
+
|
|
34
|
+
### Installing from RubyGems
|
|
35
|
+
|
|
36
|
+
"gem install rest_connection"
|
|
37
|
+
|
|
38
|
+
### Installing from source
|
|
39
|
+
|
|
40
|
+
"git clone git@github.com:rightscale/rest_connection.git"
|
|
41
|
+
"cd rest_connection"
|
|
42
|
+
"gem install rconf"
|
|
43
|
+
"rconf" <- follow any further instructions from rconf
|
|
44
|
+
"bundle install"
|
|
45
|
+
|
|
46
|
+
## Versioning
|
|
47
|
+
|
|
48
|
+
This gem follows semantic versioning: http://semver.org
|
|
49
|
+
|
|
50
|
+
## Usage Instructions
|
|
51
|
+
|
|
52
|
+
You must setup '~/.rest_connection/rest_api_config.yaml' or '/etc/rest_connection/rest_api_config.yaml'
|
|
53
|
+
|
|
54
|
+
Copy the example from '$GEMHOME/rest_connection/config/rest_api_config.yaml.sample' and fill in your connection info.
|
|
55
|
+
|
|
56
|
+
Pro Tip: to find a $GEMHOME, use gemedit
|
|
57
|
+
|
|
58
|
+
"gem install gemedit"
|
|
59
|
+
"gem edit rest_connection"
|
|
60
|
+
|
|
61
|
+
The following examples assume an interactive ruby session (irb):
|
|
62
|
+
|
|
63
|
+
$ bundle exec irb
|
|
64
|
+
ruby> require 'rubygems'; require 'rest_connection'
|
|
65
|
+
|
|
66
|
+
### Look up and run a RightScript
|
|
67
|
+
|
|
68
|
+
first_fe = Server.find(:first) { |s| s.nickname =~ /Front End/ }
|
|
69
|
+
st = ServerTemplate.find(first_fe.server_template_href)
|
|
70
|
+
connect_script = st.executables.detect { |ex| ex.name =~ /LB [app|mongrels]+ to HA proxy connect/i }
|
|
71
|
+
state = first_fe.run_executable(connect_script)
|
|
72
|
+
state.wait_for_completed
|
|
73
|
+
|
|
74
|
+
### Stop a Deployment
|
|
75
|
+
|
|
76
|
+
deployment = Deployment.find(opts[:id])
|
|
77
|
+
my_servers = deployment.servers
|
|
78
|
+
my_servers.each { |s| s.stop }
|
|
79
|
+
my_servers.each { |s| s.wait_for_state("stopped") }
|
|
80
|
+
|
|
81
|
+
### Activate an Ec2ServerArray / Display instances IPs
|
|
82
|
+
|
|
83
|
+
my_array = Ec2ServerArray.find(opts[:href])
|
|
84
|
+
my_array.active = true
|
|
85
|
+
my_array.save
|
|
86
|
+
|
|
87
|
+
puts my_array.instances.map { |i| i['ip-address'] }
|
|
88
|
+
|
|
89
|
+
## Design Decisions
|
|
90
|
+
|
|
91
|
+
Currently, all API resources are represented by classes in 'lib/rest_connection/rightscale'.
|
|
92
|
+
Various helper modules are also located in this directory.
|
|
93
|
+
|
|
94
|
+
### API 0.1 resources
|
|
95
|
+
|
|
96
|
+
API 0.1 resources are often named with suffix '_internal'.
|
|
97
|
+
|
|
98
|
+
They often pull in common internal code:
|
|
99
|
+
|
|
100
|
+
include RightScale::Api::Internal
|
|
101
|
+
extend RightScale::Api::InternalExtend
|
|
102
|
+
|
|
103
|
+
### API 1.0 resources
|
|
104
|
+
|
|
105
|
+
API 1.0 resources are often named with prefix 'ec2_' for Amazon Elastic Compute Cloud.
|
|
106
|
+
|
|
107
|
+
They often pull in common internal code:
|
|
108
|
+
|
|
109
|
+
include RightScale::Api::Base
|
|
110
|
+
extend RightScale::Api::BaseExtend
|
|
111
|
+
|
|
112
|
+
### API 1.5 resources
|
|
113
|
+
|
|
114
|
+
API 1.5 resources are often named with prefix 'mc_' for MultiCloud.
|
|
115
|
+
They often talk to the MultiCloud gateway and therefore pull in some common gateway code:
|
|
116
|
+
|
|
117
|
+
include RightScale::Api::Gateway
|
|
118
|
+
extend RightScale::Api::GatewayExtend
|
|
119
|
+
|
|
120
|
+
## Troubleshooting
|
|
121
|
+
|
|
122
|
+
### Wrong ruby version
|
|
123
|
+
|
|
124
|
+
Ruby 1.8.7 or higher is required.
|
|
125
|
+
|
|
126
|
+
## Publishing
|
|
127
|
+
|
|
128
|
+
To cut a new gem and push to RubyGems:
|
|
129
|
+
|
|
130
|
+
Edit lib/rest_connection/version.rb with semantic version number.
|
|
131
|
+
|
|
132
|
+
"bundle exec gem build rest_connection.gemspec"
|
|
133
|
+
"ls *.gem" <- verify that gem was built
|
|
134
|
+
"cd /tmp"
|
|
135
|
+
"bundle exec gem install /path/to/local/rest_connection-X.Y.Z.gem" <- replace X.Y.Z with your new version number
|
|
136
|
+
"bundle exec gem uninstall rest_connection"
|
|
137
|
+
"cd -"
|
|
138
|
+
"bundle exec gem push rest_connection-X.Y.Z.gem"
|
|
139
|
+
|
|
140
|
+
Check it out: https://rubygems.org/gems/rest_connection
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
#++
|
|
23
23
|
|
|
24
|
+
#
|
|
25
|
+
# API 1.0
|
|
26
|
+
#
|
|
24
27
|
class Ec2ServerArray
|
|
25
28
|
include RightScale::Api::Base
|
|
26
29
|
extend RightScale::Api::BaseExtend
|
|
@@ -31,9 +34,6 @@ class Ec2ServerArray
|
|
|
31
34
|
|
|
32
35
|
def initialize(*args, &block)
|
|
33
36
|
super(*args, &block)
|
|
34
|
-
if RightScale::Api::api0_1?
|
|
35
|
-
@internal = Ec2ServerArrayInternal.new(*args, &block)
|
|
36
|
-
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Example:
|
|
@@ -50,6 +50,37 @@ class Ec2ServerArray
|
|
|
50
50
|
connection.post("#{serv_href.path}/run_script_on_all", options)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
#
|
|
54
|
+
# Run a script on individual instances in a ServerArray
|
|
55
|
+
#
|
|
56
|
+
# This was formerly located in Ec2ServerArrayInternal but has
|
|
57
|
+
# been moved here to Ec2ServerArray as the call has been ported
|
|
58
|
+
# from API 0.1 to API 1.0.
|
|
59
|
+
#
|
|
60
|
+
# Example: array.run_script_on_instances(right_script, server_href, options_hash)
|
|
61
|
+
#
|
|
62
|
+
def run_script_on_instances(script, ec2_instance_hrefs=[], opts={})
|
|
63
|
+
uri = URI.parse(self.href)
|
|
64
|
+
case script
|
|
65
|
+
when Executable then script = script.right_script
|
|
66
|
+
when String then script = RightScript.new('href' => script)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
params = {:right_script_href => script.href }
|
|
70
|
+
unless ec2_instance_hrefs.nil? || ec2_instance_hrefs.empty?
|
|
71
|
+
params[:ec2_instance_hrefs] = ec2_instance_hrefs
|
|
72
|
+
end
|
|
73
|
+
unless opts.nil? || opts.empty?
|
|
74
|
+
params[:parameters] = opts
|
|
75
|
+
end
|
|
76
|
+
params = {:ec2_server_array => params}
|
|
77
|
+
status_array=[]
|
|
78
|
+
connection.post(uri.path + "/run_script_on_instances", params).map do |work_unit|
|
|
79
|
+
status_array.push Status.new('href' => work_unit)
|
|
80
|
+
end
|
|
81
|
+
return(status_array)
|
|
82
|
+
end
|
|
83
|
+
|
|
53
84
|
def instances
|
|
54
85
|
serv_href = URI.parse(self.href)
|
|
55
86
|
connection.get("#{serv_href.path}/instances")
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
#++
|
|
23
23
|
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
24
|
+
#
|
|
25
|
+
# API 1.0
|
|
26
|
+
#
|
|
27
|
+
|
|
28
|
+
# Requires instance token for authentication
|
|
27
29
|
class Instance
|
|
28
30
|
include RightScale::Api::Base
|
|
29
31
|
extend RightScale::Api::BaseExtend
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
#++
|
|
23
23
|
|
|
24
24
|
#
|
|
25
|
-
#
|
|
25
|
+
# API 1.5
|
|
26
26
|
#
|
|
27
27
|
class McInstance
|
|
28
28
|
include RightScale::Api::Gateway
|
|
@@ -151,7 +151,7 @@ class McInstance
|
|
|
151
151
|
return href
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
def run_executable(executable, opts=nil)
|
|
154
|
+
def run_executable(executable, opts=nil, ignore_lock=false)
|
|
155
155
|
run_options = Hash.new
|
|
156
156
|
if executable.is_a?(Executable)
|
|
157
157
|
if executable.recipe?
|
|
@@ -165,8 +165,15 @@ class McInstance
|
|
|
165
165
|
raise "Invalid class passed to run_executable, needs Executable or RightScript, was:#{executable.class}"
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
+
if not opts.nil? and opts.has_key?(:ignore_lock)
|
|
169
|
+
run_options[:ignore_lock] = "true"
|
|
170
|
+
opts.delete(:ignore_lock)
|
|
171
|
+
opts = nil if opts.empty?
|
|
172
|
+
end
|
|
173
|
+
|
|
168
174
|
inst_href = URI.parse(self.href)
|
|
169
175
|
run_options[:inputs] = transform_inputs(:to_a, opts) unless opts.nil?
|
|
176
|
+
run_options[:ignore_lock] = "true" if ignore_lock
|
|
170
177
|
location = connection.post(inst_href.path + '/run_executable', run_options)
|
|
171
178
|
Task.new('href' => location)
|
|
172
179
|
end
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
#++
|
|
23
23
|
#
|
|
24
|
-
#
|
|
24
|
+
# API 1.5
|
|
25
25
|
#
|
|
26
26
|
class McServer < Server
|
|
27
27
|
include RightScale::Api::Gateway
|
|
@@ -161,9 +161,9 @@ class McServer < Server
|
|
|
161
161
|
raise "You shouldn't be here."
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
def run_executable(executable, opts=nil)
|
|
164
|
+
def run_executable(executable, opts=nil, ignore_lock=false)
|
|
165
165
|
raise "Instance isn't running; Can't run executable" unless @current_instance
|
|
166
|
-
@current_instance.run_executable(executable, opts)
|
|
166
|
+
@current_instance.run_executable(executable, opts, ignore_lock)
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
def transform_inputs(sym, parameters)
|