ebs_conductor 0.0.1 → 0.0.2

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/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem "fog", "~> 0.8.2"
7
- gem "skeme", ">= 0"
7
+ gem "skeme", "~> 0.0.6"
8
8
  gem "rest_connection", ">= 0.0.21"
9
9
 
10
10
  # Add dependencies to develop your gem here.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ebs_conductor}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Geyer"]
12
- s.date = %q{2011-06-02}
12
+ s.date = %q{2011-06-06}
13
13
  s.description = %q{= ebs_conductor
14
14
 
15
15
  The EBS Conductor is a library for managing Amazon Elastic Block Storage volumes and snapshots. It is designed to persist a specific set of data (a "lineage") between different compute instances.
@@ -73,7 +73,7 @@ further details.
73
73
  s.homepage = %q{http://github.com/rgeyer/ebs_conductor}
74
74
  s.licenses = ["MIT"]
75
75
  s.require_paths = ["lib"]
76
- s.rubygems_version = %q{1.5.2}
76
+ s.rubygems_version = %q{1.6.2}
77
77
  s.summary = %q{A RightScale/Amazon EC2 EBS library}
78
78
  s.test_files = [
79
79
  "test/helper.rb"
@@ -84,7 +84,7 @@ further details.
84
84
 
85
85
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
86
86
  s.add_runtime_dependency(%q<fog>, ["~> 0.8.2"])
87
- s.add_runtime_dependency(%q<skeme>, [">= 0"])
87
+ s.add_runtime_dependency(%q<skeme>, ["~> 0.0.6"])
88
88
  s.add_runtime_dependency(%q<rest_connection>, [">= 0.0.21"])
89
89
  s.add_development_dependency(%q<shoulda>, [">= 0"])
90
90
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -92,7 +92,7 @@ further details.
92
92
  s.add_development_dependency(%q<rcov>, [">= 0"])
93
93
  else
94
94
  s.add_dependency(%q<fog>, ["~> 0.8.2"])
95
- s.add_dependency(%q<skeme>, [">= 0"])
95
+ s.add_dependency(%q<skeme>, ["~> 0.0.6"])
96
96
  s.add_dependency(%q<rest_connection>, [">= 0.0.21"])
97
97
  s.add_dependency(%q<shoulda>, [">= 0"])
98
98
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -101,7 +101,7 @@ further details.
101
101
  end
102
102
  else
103
103
  s.add_dependency(%q<fog>, ["~> 0.8.2"])
104
- s.add_dependency(%q<skeme>, [">= 0"])
104
+ s.add_dependency(%q<skeme>, ["~> 0.0.6"])
105
105
  s.add_dependency(%q<rest_connection>, [">= 0.0.21"])
106
106
  s.add_dependency(%q<shoulda>, [">= 0"])
107
107
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
data/lib/ebs_conductor.rb CHANGED
@@ -25,6 +25,7 @@ module Rgeyer
25
25
  @@logger = nil
26
26
  @@default_timeout = 5*60
27
27
  @@timeout_backoff = [2,5,10,15]
28
+ @@rs_region_hash = {'us-east-1' => 1, 'eu-west-1' => 2, 'us-west-1' => 3, 'ap-northeast-1' => 4, 'ap-southeast-1' => 5}
28
29
 
29
30
  # Instantiates a new EbsConductor
30
31
  #
@@ -67,11 +68,12 @@ module Rgeyer
67
68
  })
68
69
 
69
70
  if options[:rs_email] && options[:rs_pass] && options[:rs_acct_num]
71
+ pass = options[:rs_pass].gsub('"', '\\"')
70
72
  ::RightScale::Api::BaseExtend.class_eval <<-EOF
71
73
  @@connection ||= RestConnection::Connection.new
72
74
  @@connection.settings = {
73
75
  :user => "#{options[:rs_email]}",
74
- :pass => "#{options[:rs_pass]}",
76
+ :pass => "#{pass}",
75
77
  :api_url => "https://my.rightscale.com/api/acct/#{options[:rs_acct_num]}",
76
78
  :common_headers => {
77
79
  "X_API_VERSION" => "1.0"
@@ -82,7 +84,7 @@ module Rgeyer
82
84
  @@connection ||= RestConnection::Connection.new
83
85
  @@connection.settings = {
84
86
  :user => "#{options[:rs_email]}",
85
- :pass => "#{options[:rs_pass]}",
87
+ :pass => "#{pass}",
86
88
  :api_url => "https://my.rightscale.com/api/acct/#{options[:rs_acct_num]}",
87
89
  :common_headers => {
88
90
  "X_API_VERSION" => "1.0"
@@ -162,14 +164,18 @@ module Rgeyer
162
164
  timeout_message = "Timed out waiting for EBS volume to be created and attached to (#{server.id}). Elapsed time was #{options[:timeout]} seconds"
163
165
  block_until_timeout(timeout_message, options[:timeout]) {
164
166
  keep_baking = false
165
- server = @@fog_aws_computes[region].servers.get(instance_id)
166
- # Check things out on AWS
167
- check_vol = server.block_device_mapping.select { |dev| dev['volumeId'] == new_vol.id }.first
168
- keep_baking = true if !check_vol || check_vol['status'] != "attached"
167
+ ec2_found = false
168
+ unless ec2_found
169
+ server = @@fog_aws_computes[region].servers.get(instance_id)
170
+ # Check things out on AWS
171
+ check_vol = server.block_device_mapping.select { |dev| dev['volumeId'] == new_vol.id }.first
172
+ keep_baking = true if !check_vol || check_vol['status'] != "attached"
173
+ ec2_found = !keep_baking
174
+ end
169
175
 
170
176
  # Check things out in RS if we've got RS credentials
171
177
  if @@have_rs
172
- vol = Ec2EbsVolume.find(:first) { |vol| vol.aws_id == new_vol.id }
178
+ vol = Ec2EbsVolume.find_by_cloud_id(@@rs_region_hash[region]).select { |v| v.aws_id == new_vol.id }.first
173
179
  keep_baking = (vol == nil)
174
180
  end
175
181
 
@@ -223,7 +229,7 @@ module Rgeyer
223
229
  vol_hash.each do |region,vols|
224
230
  # TODO: warn about multiples in a region?
225
231
  vols.each do |vol|
226
- if ["available", "in-use"].include? vol.status
232
+ if ["available", "in-use"].include? vol.state
227
233
  description = "Created by EBS Conductor for the (#{lineage}) lineage while the volume was #{vol.server_id ? "attached to #{vol.server_id}" : "detatched"}"
228
234
 
229
235
  excon_resp = @@fog_aws_computes[region].create_snapshot(vol.id, description)
@@ -231,7 +237,7 @@ module Rgeyer
231
237
 
232
238
  tags = options[:tags] || []
233
239
  tags << lineage_tag(lineage)
234
- tag_hash[snapshot_id] = {:snapshot_tags => tags, :volume_tags => vol.tags.keys}
240
+ tag_hash[snapshot_id] = {:snapshot_tags => tags, :volume_tags => vol.tags.keys, :region => region}
235
241
  else
236
242
  @@logger.warn("Volume (#{vol.id}) had a status of (#{vol.status}). A snapshot could not be created..")
237
243
  end
@@ -243,7 +249,12 @@ module Rgeyer
243
249
  keep_baking = false
244
250
 
245
251
  if @@have_rs
246
- snaps = Ec2EbsSnapshot.find(:all) { |snap| tag_hash.keys.include? snap.aws_id }
252
+ snaps = []
253
+ tag_hash.each do |snapshot_id,val_hash|
254
+ snap = Ec2EbsSnapshot.find_by_cloud_id(@@rs_region_hash[val_hash[:region]]).select { |s| snapshot_id == s.aws_id }.first
255
+ snaps << snap if snap
256
+ end
257
+ #snaps = Ec2EbsSnapshot.find_by_cloud_id(:all) { |snap| tag_hash.keys.include? snap.aws_id }
247
258
  keep_baking = (snaps.count != tag_hash.keys.count)
248
259
  end
249
260
 
@@ -330,6 +341,7 @@ module Rgeyer
330
341
  end
331
342
 
332
343
  def block_until_timeout(timeout_message, timeout, &block)
344
+ @@logger.info("Entered block_until and timeout is (#{timeout})")
333
345
  begin
334
346
  idx=0
335
347
  Timeout::timeout(timeout) do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebs_conductor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Geyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-02 00:00:00 -07:00
18
+ date: 2011-06-06 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -40,12 +40,14 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 19
46
46
  segments:
47
47
  - 0
48
- version: "0"
48
+ - 0
49
+ - 6
50
+ version: 0.0.6
49
51
  name: skeme
50
52
  version_requirements: *id002
51
53
  - !ruby/object:Gem::Dependency
@@ -216,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
218
  requirements: []
217
219
 
218
220
  rubyforge_project:
219
- rubygems_version: 1.5.2
221
+ rubygems_version: 1.6.2
220
222
  signing_key:
221
223
  specification_version: 3
222
224
  summary: A RightScale/Amazon EC2 EBS library