rest_connection 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -0,0 +1,20 @@
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 Ec2EbsSnapshot
18
+ include RightScale::Api::Base
19
+ extend RightScale::Api::BaseExtend
20
+ end
@@ -0,0 +1,20 @@
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 Ec2EbsVolume
18
+ include RightScale::Api::Base
19
+ extend RightScale::Api::BaseExtend
20
+ end
@@ -26,3 +26,6 @@ require 'rest_connection/rightscale/multi_cloud_image'
26
26
  require 'rest_connection/rightscale/tag'
27
27
  require 'rest_connection/rightscale/rs_internal'
28
28
  require 'rest_connection/rightscale/audit_entry'
29
+ require 'rest_connection/rightscale/ec2_ebs_volume'
30
+ require 'rest_connection/rightscale/ec2_ebs_snapshot'
31
+
@@ -139,9 +139,15 @@ class Server
139
139
  @params.merge! connection.get(serv_href.path + "/monitoring")
140
140
  end
141
141
 
142
- def reboot
142
+ # takes Bool argument to wait for state change (insurance that we can detect a reboot happened)
143
+ def reboot(wait_for_state = false)
144
+ reload
145
+ old_state = self.state
143
146
  serv_href = URI.parse(self.href)
144
147
  connection.post(serv_href.path + "/reboot")
148
+ if wait_for_state
149
+ wait_for_state_change(old_state)
150
+ end
145
151
  end
146
152
 
147
153
  def events
@@ -156,6 +162,20 @@ class Server
156
162
  self.start
157
163
  end
158
164
 
165
+ def wait_for_state_change(old_state = nil)
166
+ timeout = 60*7
167
+ timer = 0
168
+ while(timer < timeout)
169
+ reload
170
+ old_state = self.state unless old_state
171
+ connection.logger("#{nickname} is #{self.state}")
172
+ return true if self.state != old_state
173
+ sleep 5
174
+ timer += 5
175
+ connection.logger("waiting for server #{nickname} to change from #{old_state} state.")
176
+ end
177
+ raise("FATAL: timeout after #{timeout}s waiting for state change")
178
+ end
159
179
 
160
180
  # DOES NOT WORK: fragile web scraping
161
181
  # def relaunch
@@ -20,6 +20,8 @@ require 'net/ssh'
20
20
  # The mixin typically used from Server#run_recipe
21
21
  module SshHax
22
22
 
23
+ SSH_RETRY_COUNT = 3
24
+
23
25
  def ssh_key_config(item)
24
26
  if item.is_a?(Array)
25
27
  ssh_keys = item
@@ -146,6 +148,10 @@ module SshHax
146
148
  connection.logger "SSHing to #{host_dns} using key(s) #{ssh_key_config(ssh_key)}"
147
149
  status = nil
148
150
  output = ""
151
+ success = false
152
+ retry_count = 0
153
+ while (!success && retry_count < SSH_RETRY_COUNT) do
154
+ begin
149
155
  Net::SSH.start(host_dns, 'root', :keys => ssh_key_config(ssh_key)) do |ssh|
150
156
  cmd_channel = ssh.open_channel do |ch1|
151
157
  ch1.on_request('exit-status') do |ch, data|
@@ -158,7 +164,6 @@ module SshHax
158
164
  status = 1
159
165
  end
160
166
  ch2.on_data do |ch, data|
161
-
162
167
  output += data
163
168
  end
164
169
  ch2.on_extended_data do |ch, type, data|
@@ -167,6 +172,11 @@ module SshHax
167
172
  end
168
173
  end
169
174
  end
175
+ rescue Exception => e
176
+ retry_count += 1 # opening the ssh channel failed -- try again.
177
+ sleep 10
178
+ end
179
+ end
170
180
  connection.logger output
171
181
  return {:status => status, :output => output}
172
182
  end
@@ -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.4"
8
+ s.version = "0.0.5"
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-04-15}
12
+ s.date = %q{2010-04-20}
13
13
  s.description = %q{provides rest_connection}
14
14
  s.email = %q{jeremy@rubyonlinux.org}
15
15
  s.extra_rdoc_files = [
@@ -34,6 +34,8 @@ Gem::Specification.new do |s|
34
34
  "lib/rest_connection.rb",
35
35
  "lib/rest_connection/rightscale/audit_entry.rb",
36
36
  "lib/rest_connection/rightscale/deployment.rb",
37
+ "lib/rest_connection/rightscale/ec2_ebs_snapshot.rb",
38
+ "lib/rest_connection/rightscale/ec2_ebs_volume.rb",
37
39
  "lib/rest_connection/rightscale/ec2_security_group.rb",
38
40
  "lib/rest_connection/rightscale/ec2_server_array.rb",
39
41
  "lib/rest_connection/rightscale/ec2_ssh_key.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Deininger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-15 00:00:00 +00:00
17
+ date: 2010-04-20 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,8 @@ files:
80
80
  - lib/rest_connection.rb
81
81
  - lib/rest_connection/rightscale/audit_entry.rb
82
82
  - lib/rest_connection/rightscale/deployment.rb
83
+ - lib/rest_connection/rightscale/ec2_ebs_snapshot.rb
84
+ - lib/rest_connection/rightscale/ec2_ebs_volume.rb
83
85
  - lib/rest_connection/rightscale/ec2_security_group.rb
84
86
  - lib/rest_connection/rightscale/ec2_server_array.rb
85
87
  - lib/rest_connection/rightscale/ec2_ssh_key.rb