CloudyScripts 1.5.23 → 1.5.24

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.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/help/state_transition_helper.rb +35 -13
  3. metadata +25 -14
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'CloudyScripts'
15
- s.version = '1.5.23'
15
+ s.version = '1.5.24'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
18
  s.summary = 'Scripts to facilitate programming for infrastructure clouds.'
@@ -232,23 +232,34 @@ module StateTransitionHelper
232
232
  # * temp_device_name => device name to be used for attaching (e.g. /dev/sdj1)
233
233
  def attach_volume(volume_id, instance_id, temp_device_name)
234
234
  post_message("going to attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name}...")
235
- @logger.debug "attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name}"
235
+ @logger.info "attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name}"
236
236
  ec2_handler().attach_volume(:volume_id => volume_id,
237
237
  :instance_id => instance_id,
238
238
  :device => temp_device_name
239
239
  )
240
240
  done = false
241
- while !done
242
- sleep(5)
243
- #TODO: check for timeout?
241
+ timeout = 120
242
+ while timeout > 0
244
243
  res = ec2_handler().describe_volumes(:volume_id => volume_id)
245
- state = res['volumeSet']['item'][0]['status']
246
- @logger.debug "storage attaching: #{state}"
247
- if state == 'in-use'
244
+ vol_state = res['volumeSet']['item'][0]['status']
245
+ attachment_state = res['volumeSet']['item'][0]['attachmentSet']['item'][0]['status']
246
+ @logger.debug "storage attaching: volume state: #{vol_state}, attachment state: #{attachment_state}"
247
+ if vol_state == 'in-use' && attachment_state == 'attached'
248
248
  done = true
249
+ timeout = 0
249
250
  end
251
+ sleep(5)
252
+ timeout -= 5
253
+ end
254
+ msg = ""
255
+ if !done
256
+ msg = "Failed to attach volume '#{volume_id}' to instance '#{instance_id}"
257
+ raise Exception.new("volume #{mount_point} not attached")
258
+ else
259
+ msg = "volume #{volume_id} successfully attached"
250
260
  end
251
- post_message("volume successfully attached")
261
+ @logger.error "#{msg}"
262
+ post_message("#{msg}")
252
263
  end
253
264
 
254
265
  # Detach an EBS volume from an instance.
@@ -256,22 +267,33 @@ module StateTransitionHelper
256
267
  # * volume_id => EC2 ID for the EBS Volume to be detached
257
268
  # * instance_id => EC2 ID for the instance to detach from
258
269
  def detach_volume(volume_id, instance_id)
259
- post_message("going to detach volume #{volume_id}...")
260
- @logger.debug "detach volume #{volume_id}"
270
+ post_message("going to detach volume #{volume_id} from instance #{instance_id}...")
271
+ @logger.info "detach volume #{volume_id} from instance #{instance_id}"
261
272
  ec2_handler().detach_volume(:volume_id => volume_id,
262
273
  :instance_id => instance_id
263
274
  )
264
275
  done = false
265
- while !done
276
+ timeout = 120
277
+ while timeout > 0
266
278
  sleep(3)
267
- #TODO: check for timeout?
268
279
  res = ec2_handler().describe_volumes(:volume_id => volume_id)
269
280
  @logger.debug "volume detaching: #{res.inspect}"
270
281
  if res['volumeSet']['item'][0]['status'] == 'available'
271
282
  done = true
283
+ timeout = 0
272
284
  end
285
+ sleep(5)
286
+ timeout -= 5
287
+ end
288
+ msg = ""
289
+ if !done
290
+ msg = "Failed to detach volume '#{volume_id}' from instance '#{instance_id}"
291
+ raise Exception.new("volume #{mount_point} not detached")
292
+ else
293
+ msg = "volume #{volume_id} successfully detached"
273
294
  end
274
- post_message("volume #{volume_id} detached.")
295
+ @logger.error "#{msg}"
296
+ post_message("#{msg}")
275
297
  end
276
298
 
277
299
  # Delete an EBS volume.
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudyScripts
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 5
8
- - 23
9
- version: 1.5.23
9
+ - 24
10
+ version: 1.5.24
10
11
  platform: ruby
11
12
  authors:
12
13
  - Matthias Jung
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-24 00:00:00 +01:00
18
+ date: 2011-03-09 00:00:00 +00:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: amazon-ec2
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: net-ssh
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -45,9 +50,11 @@ dependencies:
45
50
  name: net-scp
46
51
  prerelease: false
47
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
51
58
  segments:
52
59
  - 0
53
60
  version: "0"
@@ -66,20 +73,20 @@ files:
66
73
  - LICENSE
67
74
  - README.rdoc
68
75
  - Rakefile
69
- - lib/cloudyscripts.rb
70
- - lib/help/dm_crypt_helper.rb
71
- - lib/help/ec2_helper.rb
72
- - lib/help/progress_message_listener.rb
73
- - lib/help/remote_command_handler.rb
74
- - lib/help/script_execution_state.rb
75
- - lib/help/state_change_listener.rb
76
- - lib/help/state_transition_helper.rb
76
+ - lib/scripts/ec2/dm_encrypt.rb
77
77
  - lib/scripts/ec2/ami2_ebs_conversion.rb
78
78
  - lib/scripts/ec2/copy_ami.rb
79
79
  - lib/scripts/ec2/copy_snapshot.rb
80
- - lib/scripts/ec2/dm_encrypt.rb
81
- - lib/scripts/ec2/download_snapshot.rb
82
80
  - lib/scripts/ec2/ec2_script.rb
81
+ - lib/scripts/ec2/download_snapshot.rb
82
+ - lib/help/ec2_helper.rb
83
+ - lib/help/dm_crypt_helper.rb
84
+ - lib/help/state_transition_helper.rb
85
+ - lib/help/script_execution_state.rb
86
+ - lib/help/progress_message_listener.rb
87
+ - lib/help/remote_command_handler.rb
88
+ - lib/help/state_change_listener.rb
89
+ - lib/cloudyscripts.rb
83
90
  has_rdoc: true
84
91
  homepage: http://elastic-security.com
85
92
  licenses: []
@@ -90,23 +97,27 @@ rdoc_options: []
90
97
  require_paths:
91
98
  - lib
92
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
93
101
  requirements:
94
102
  - - ">="
95
103
  - !ruby/object:Gem::Version
104
+ hash: 3
96
105
  segments:
97
106
  - 0
98
107
  version: "0"
99
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
100
110
  requirements:
101
111
  - - ">="
102
112
  - !ruby/object:Gem::Version
113
+ hash: 3
103
114
  segments:
104
115
  - 0
105
116
  version: "0"
106
117
  requirements: []
107
118
 
108
119
  rubyforge_project: cloudyscripts
109
- rubygems_version: 1.3.6
120
+ rubygems_version: 1.3.7
110
121
  signing_key:
111
122
  specification_version: 3
112
123
  summary: Scripts to facilitate programming for infrastructure clouds.