openstack_taster 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28a2216a1227c110a1f9b252dcce6c1722c32d66
4
- data.tar.gz: 9841da2981dc1fd82e1802c163d42d0faa9ab114
3
+ metadata.gz: 05a553071d6d302a7fe9e703b5ac460b017ed0d8
4
+ data.tar.gz: a82133b64313108f02b673512bbc359fe0e1bdce
5
5
  SHA512:
6
- metadata.gz: 0e1282ef3506e2bc619c79c96f9a9bb60a6de3d15277ac2b6ae008bb2778e48d71b5588bf70d8dc97269bd638b73a35db965131b2b316170429b25333bd87930
7
- data.tar.gz: 40b7a43e131aefa39410c701eb887e62bdfb8eb186696ba36b555a068fd249fce5070d71f8a47bfa6d2c65bf4b89af7274b0341b726bc75b96be5f46403b5107
6
+ metadata.gz: 41bd0949cdca2c50661844235fbd9a074e27be8dc1a24f6ef8176c76db3f3a3f237ebdaac763b15af70513636d78cb9f1bc5172535f34377074e46196e82f3ed
7
+ data.tar.gz: f6ae5f21e1eebc08bf489f555c858d5bb60139d89e71cbeff99d2f2e61c996b055bf0fc95c43ad23a286697c3b55ae62d6a40f9ad611426711f122d96e30f668
@@ -279,37 +279,37 @@ class OpenStackTaster
279
279
  if volume_attach?(instance, volume)
280
280
  vdev = @volume_service.volumes.find_by_id(volume.id).attachments.first['device']
281
281
  mkfs_command = [
282
- ["sudo parted --script #{vdev} mklabel gpt mkpart primary 1 100%", ''],
283
- ["sudo mkfs.#{VOLUME_FILESYSTEM} -Fq #{vdev}1", '']
282
+ ["sudo parted --script #{vdev} mklabel gpt mkpart primary 1 100%", /^$/],
283
+ ["sudo mkfs.#{VOLUME_FILESYSTEM} -Fq #{vdev}1", /(^$)|(done\n)?/]
284
284
  ]
285
285
  with_ssh(instance, username) do |ssh|
286
286
  mkfs_command.each do |command, expected|
287
287
  result = ssh.exec!(command)
288
- next unless result != expected
288
+ next unless result !~ expected
289
289
  error_log(
290
290
  instance.logger,
291
291
  'error',
292
292
  "Failure while running '#{command}':\n\texpected '#{expected}'\n\tgot '#{result}'",
293
293
  true
294
294
  )
295
+ _detach = volume_detach?(instance, volume)
296
+ volume_delete(instance, volume)
295
297
  return false
296
298
  end
297
299
  end
298
300
  mount = volume_mount_unmount?(instance, username, volume)
299
301
  detach = volume_detach?(instance, volume)
302
+ volume_delete(instance, volume)
300
303
  else
301
304
  error_log(instance.logger, 'error', "Volume '#{volume.id}' failed to attach.", true)
305
+ volume_delete(instance, volume)
302
306
  return false
303
307
  end
304
308
 
305
309
  if mount && detach
306
- error_log(instance.logger, 'info', "Deleting volume #{volume.id}.", true)
307
- volume.destroy if volume.ready?
308
310
  error_log(instance.logger, 'info', "\nVolume testing passed!.", true)
309
311
  true
310
312
  else
311
- error_log(instance.logger, 'info', "Deleting volume #{volume.id}.", true)
312
- volume.destroy if volume.ready?
313
313
  error_log(
314
314
  instance.logger,
315
315
  'error',
@@ -468,4 +468,22 @@ class OpenStackTaster
468
468
  error_log(instance.logger, 'error', e.message)
469
469
  false
470
470
  end
471
+
472
+ # Delete volume
473
+ # @param instance [Fog::Compute::OpenStack::Server] the instance from which to detach
474
+ # @param volume [Fog::Volume::OpenStack::Volume] the volume to detach
475
+ def volume_delete(instance, volume)
476
+ error_log(instance.logger, 'info', "Deleting volume #{volume.name}.", true)
477
+ loop do
478
+ volume.reload
479
+ sleep 2
480
+ break if volume.ready?
481
+ error_log(instance.logger, 'info', "volume #{volume.name} not ready, waiting...", true)
482
+ end
483
+ volume.destroy
484
+ error_log(instance.logger, 'info', "Deleted volume #{volume.name}.", true)
485
+ rescue Excon::Error => e
486
+ puts 'Failed to delete. check log for details.'
487
+ error_log(instance.logger, 'error', e.message)
488
+ end
471
489
  end
data/tests/inspec.yml CHANGED
@@ -4,4 +4,4 @@ maintainer: OSU Open Source Lab
4
4
  copyright: Oregon State University
5
5
  license: Apache License, Version 2.0
6
6
  summary: Verify that an image has correctly configured security settings.
7
- version: 1.1.3
7
+ version: 1.1.4
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstack_taster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - OSU Open Source Lab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inspec