Class: Torpedo::Cleanup

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/torpedo/cleanup.rb

Instance Method Summary collapse

Instance Method Details

#test_999_cleanupObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/torpedo/cleanup.rb', line 10

def test_999_cleanup
  if ORCHESTRATION_ENABLED and CLEAN_UP_STACKS then
    orchestration_conn = Torpedo::Orchestration::Helper::get_connection
    orchestration_conn.stacks.each do |stack|
      stack = orchestration_conn.stacks.get(stack.id)
      if stack.stack_name == 'torpedo'
        #puts 'Deleting torpedo stack'
        assert(stack.destroy)
        # We wait for the stack to be deleted here to avoid pulling
        # the rug on heat (and causing a potential log ERROR)
        begin
          timeout(STACK_CREATE_TIMEOUT) do
            until orchestration_conn.stacks.get(stack.id).nil? do
              sleep(1)
            end
          end
        rescue Timeout::Error => te
          fail('Timeout deleting stack.')
        end

      end
    end
  end
  compute_conn = Torpedo::Compute::Helper::get_connection
  if CLEAN_UP_SERVERS
    compute_conn.servers.each do |server|
      server = compute_conn.servers.get(server.id)
      if server.name == 'torpedo'
        #puts 'Deleting torpedo server'
        assert(server.destroy)
      end
    end
  end
  if CLEAN_UP_IMAGES
    compute_conn.images.each do |image|
      image = compute_conn.images.get(image.id)
      if image.name == 'torpedo'
        #puts 'Deleting torpedo image'
        assert(image.destroy)
      end
    end
  end
  if KEYPAIR_ENABLED and CLEAN_UP_KEYPAIRS then
    compute_conn.key_pairs.each do |key_pair|
      key_pair = compute_conn.key_pairs.get(key_pair.name)
      if key_pair.name == 'torpedo'
        #puts 'Deleting torpedo key_pair'
        assert(key_pair.destroy)
      end
    end
  end
  if VOLUME_ENABLED and CLEAN_UP_VOLUMES then
    volume_conn = Torpedo::Volume::Helper::get_connection
    volume_conn.volumes.each do |volume|
      volume = volume_conn.volumes.get(volume.id)
      if volume.display_name == 'torpedo'
        #puts 'Deleting torpedo volume'
        assert(volume.destroy)
      end
    end
  end
end