nagios-promoo 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +1,99 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'base_probe')
3
3
 
4
- class Nagios::Promoo::Occi::Probes::KindsProbe < Nagios::Promoo::Occi::Probes::BaseProbe
5
- class << self
6
- def description
7
- ['kinds', 'Run a probe checking for mandatory OCCI kind definitions']
8
- end
4
+ module Nagios
5
+ module Promoo
6
+ module Occi
7
+ module Probes
8
+ # Probe for checking OCCI kinds declared by sites.
9
+ #
10
+ # @author Boris Parak <parak@cesnet.cz>
11
+ class KindsProbe < Nagios::Promoo::Occi::Probes::BaseProbe
12
+ class << self
13
+ def description
14
+ ['kinds', 'Run a probe checking for mandatory OCCI kind definitions']
15
+ end
9
16
 
10
- def options
11
- [
12
- [:kinds, { type: :string, enum: %w(core infra all), default: 'all', desc: 'Collection of mandatory kinds to check' }],
13
- [:optional, { type: :array, default: [], desc: 'Identifiers of optional kinds (optional by force)' }],
14
- [:check_location, { type: :boolean, default: false, desc: 'Verify declared REST locations for INFRA resources' }],
15
- ]
16
- end
17
+ def options
18
+ [
19
+ [
20
+ :kinds,
21
+ {
22
+ type: :string, enum: %w[core infra all], default: 'all',
23
+ desc: 'Collection of mandatory kinds to check'
24
+ }
25
+ ],
26
+ [
27
+ :optional,
28
+ {
29
+ type: :array, default: [],
30
+ desc: 'Identifiers of optional kinds (optional by force)'
31
+ }
32
+ ],
33
+ [
34
+ :check_location,
35
+ {
36
+ type: :boolean, default: false,
37
+ desc: 'Verify declared REST locations for INFRA resources'
38
+ }
39
+ ]
40
+ ]
41
+ end
17
42
 
18
- def declaration
19
- "kinds"
20
- end
43
+ def declaration
44
+ 'kinds'
45
+ end
21
46
 
22
- def runnable?; true; end
23
- end
47
+ def runnable?
48
+ true
49
+ end
50
+ end
51
+
52
+ CORE_KINDS = %w[
53
+ http://schemas.ogf.org/occi/core#entity
54
+ http://schemas.ogf.org/occi/core#resource
55
+ http://schemas.ogf.org/occi/core#link
56
+ ].freeze
24
57
 
25
- CORE_KINDS = %w(
26
- http://schemas.ogf.org/occi/core#entity
27
- http://schemas.ogf.org/occi/core#resource
28
- http://schemas.ogf.org/occi/core#link
29
- )
58
+ INFRA_KINDS = %w[
59
+ http://schemas.ogf.org/occi/infrastructure#compute
60
+ http://schemas.ogf.org/occi/infrastructure#storage
61
+ http://schemas.ogf.org/occi/infrastructure#network
62
+ http://schemas.ogf.org/occi/infrastructure#storagelink
63
+ http://schemas.ogf.org/occi/infrastructure#networkinterface
64
+ ].freeze
30
65
 
31
- INFRA_KINDS = %w(
32
- http://schemas.ogf.org/occi/infrastructure#compute
33
- http://schemas.ogf.org/occi/infrastructure#storage
34
- http://schemas.ogf.org/occi/infrastructure#network
35
- http://schemas.ogf.org/occi/infrastructure#storagelink
36
- http://schemas.ogf.org/occi/infrastructure#networkinterface
37
- )
66
+ def run(_args = [])
67
+ kinds = []
68
+ kinds += CORE_KINDS if %w[core all].include?(options[:kinds])
69
+ kinds += INFRA_KINDS if %w[infra all].include?(options[:kinds])
70
+ kinds -= options[:optional] if options[:optional]
38
71
 
39
- def run(args = [])
40
- kinds = []
41
- kinds += CORE_KINDS if %w(core all).include?(options[:kinds])
42
- kinds += INFRA_KINDS if %w(infra all).include?(options[:kinds])
43
- kinds -= options[:optional] if options[:optional]
72
+ Timeout.timeout(options[:timeout]) do
73
+ kinds.each do |kind|
74
+ raise "#{kind.inspect} is missing" unless client.model.get_by_id(kind, true)
75
+ next unless options[:check_location] && INFRA_KINDS.include?(kind)
44
76
 
45
- Timeout::timeout(options[:timeout]) do
46
- kinds.each do |kind|
47
- fail "#{kind.inspect} is missing" unless client.model.get_by_id(kind, true)
48
- next unless options[:check_location] && INFRA_KINDS.include?(kind)
77
+ # Make sure declared locations are actually available as REST
78
+ # endpoints. Failure will raise an exception, no need to do
79
+ # anything here. To keep requirements reasonable, only INFRA
80
+ # kinds are considered relevant for this part of the check.
81
+ begin
82
+ client.list(kind)
83
+ rescue => err
84
+ raise "Failed to verify declared REST location for #{kind.inspect} (#{err.message})"
85
+ end
86
+ end
87
+ end
49
88
 
50
- # Make sure declared locations are actually available as REST
51
- # endpoints. Failure will raise an exception, no need to do
52
- # anything here. To keep requirements reasonable, only INFRA
53
- # kinds are considered relevant for this part of the check.
54
- begin
55
- client.list(kind)
56
- rescue => err
57
- fail "Failed to verify declared REST location for #{kind.inspect} (#{err.message})"
89
+ puts 'KINDS OK - All specified OCCI kinds were found'
90
+ rescue => ex
91
+ puts "KINDS CRITICAL - #{ex.message}"
92
+ puts ex.backtrace if options[:debug]
93
+ exit 2
94
+ end
58
95
  end
59
96
  end
60
97
  end
61
-
62
- puts 'KINDS OK - All specified OCCI kinds were found'
63
- rescue => ex
64
- puts "KINDS CRITICAL - #{ex.message}"
65
- puts ex.backtrace if options[:debug]
66
- exit 2
67
98
  end
68
99
  end
@@ -1,50 +1,75 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'base_probe')
3
3
 
4
- class Nagios::Promoo::Occi::Probes::MixinsProbe < Nagios::Promoo::Occi::Probes::BaseProbe
5
- class << self
6
- def description
7
- ['mixins', 'Run a probe checking for mandatory OCCI mixin definitions']
8
- end
4
+ module Nagios
5
+ module Promoo
6
+ module Occi
7
+ module Probes
8
+ # Probe for checking OCCI mixins declared by sites.
9
+ #
10
+ # @author Boris Parak <parak@cesnet.cz>
11
+ class MixinsProbe < Nagios::Promoo::Occi::Probes::BaseProbe
12
+ class << self
13
+ def description
14
+ ['mixins', 'Run a probe checking for mandatory OCCI mixin definitions']
15
+ end
9
16
 
10
- def options
11
- [
12
- [:mixins, { type: :string, enum: %w(infra context all), default: 'all', desc: 'Collection of mandatory mixins to check' }],
13
- [:optional, { type: :array, default: [], desc: 'Identifiers of optional mixins (optional by force)' }]
14
- ]
15
- end
17
+ def options
18
+ [
19
+ [
20
+ :mixins,
21
+ {
22
+ type: :string, enum: %w[infra context all],
23
+ default: 'all', desc: 'Collection of mandatory mixins to check'
24
+ }
25
+ ],
26
+ [
27
+ :optional,
28
+ {
29
+ type: :array, default: [],
30
+ desc: 'Identifiers of optional mixins (optional by force)'
31
+ }
32
+ ]
33
+ ]
34
+ end
16
35
 
17
- def declaration
18
- "mixins"
19
- end
36
+ def declaration
37
+ 'mixins'
38
+ end
20
39
 
21
- def runnable?; true; end
22
- end
40
+ def runnable?
41
+ true
42
+ end
43
+ end
23
44
 
24
- INFRA_MIXINS = %w(
25
- http://schemas.ogf.org/occi/infrastructure#os_tpl
26
- http://schemas.ogf.org/occi/infrastructure#resource_tpl
27
- )
45
+ INFRA_MIXINS = %w[
46
+ http://schemas.ogf.org/occi/infrastructure#os_tpl
47
+ http://schemas.ogf.org/occi/infrastructure#resource_tpl
48
+ ].freeze
28
49
 
29
- CONTEXT_MIXINS = %w(
30
- http://schemas.openstack.org/instance/credentials#public_key
31
- http://schemas.openstack.org/compute/instance#user_data
32
- )
50
+ CONTEXT_MIXINS = %w[
51
+ http://schemas.openstack.org/instance/credentials#public_key
52
+ http://schemas.openstack.org/compute/instance#user_data
53
+ ].freeze
33
54
 
34
- def run(args = [])
35
- mixins = []
36
- mixins += INFRA_MIXINS if %w(infra all).include?(options[:mixins])
37
- mixins += CONTEXT_MIXINS if %w(context all).include?(options[:mixins])
38
- mixins -= options[:optional] if options[:optional]
55
+ def run(_args = [])
56
+ mixins = []
57
+ mixins += INFRA_MIXINS if %w[infra all].include?(options[:mixins])
58
+ mixins += CONTEXT_MIXINS if %w[context all].include?(options[:mixins])
59
+ mixins -= options[:optional] if options[:optional]
39
60
 
40
- Timeout::timeout(options[:timeout]) do
41
- mixins.each { |mixin| fail "#{mixin.inspect} is missing" unless client.model.get_by_id(mixin, true) }
42
- end
61
+ Timeout.timeout(options[:timeout]) do
62
+ mixins.each { |mixin| raise "#{mixin.inspect} is missing" unless client.model.get_by_id(mixin, true) }
63
+ end
43
64
 
44
- puts 'MIXINS OK - All specified OCCI mixins were found'
45
- rescue => ex
46
- puts "MIXINS CRITICAL - #{ex.message}"
47
- puts ex.backtrace if options[:debug]
48
- exit 2
65
+ puts 'MIXINS OK - All specified OCCI mixins were found'
66
+ rescue => ex
67
+ puts "MIXINS CRITICAL - #{ex.message}"
68
+ puts ex.backtrace if options[:debug]
69
+ exit 2
70
+ end
71
+ end
72
+ end
73
+ end
49
74
  end
50
75
  end
@@ -1,7 +1,7 @@
1
1
  module Nagios
2
2
  module Promoo
3
3
  module Occi
4
- VERSION = "1.0.0"
4
+ VERSION = '1.1.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -4,41 +4,70 @@ require 'opennebula'
4
4
  # Internal deps
5
5
  require File.join(File.dirname(__FILE__), 'version')
6
6
 
7
- # Define modules
8
- module Nagios::Promoo::Opennebula; end
9
- module Nagios::Promoo::Opennebula::Probes; end
7
+ module Nagios
8
+ module Promoo
9
+ # Namespace for ONe-related code.
10
+ #
11
+ # @author Boris Parak <parak@cesnet.cz>
12
+ module Opennebula
13
+ # Namespace for ONe-related probes.
14
+ #
15
+ # @author Boris Parak <parak@cesnet.cz>
16
+ module Probes; end
17
+ end
18
+ end
19
+ end
20
+
10
21
  Dir.glob(File.join(File.dirname(__FILE__), 'probes', '*.rb')) { |probe| require probe.chomp('.rb') }
11
22
 
12
- class Nagios::Promoo::Opennebula::Master < ::Thor
13
- class << self
14
- # Hack to override the help message produced by Thor.
15
- # https://github.com/wycats/thor/issues/261#issuecomment-16880836
16
- def banner(command, namespace = nil, subcommand = nil)
17
- "#{basename} opennebula #{command.usage}"
18
- end
23
+ module Nagios
24
+ module Promoo
25
+ module Opennebula
26
+ # Master class for all OpenNebula probes.
27
+ #
28
+ # @author Boris Parak <parak@cesnet.cz>
29
+ class Master < ::Thor
30
+ class << self
31
+ # Hack to override the help message produced by Thor.
32
+ # https://github.com/wycats/thor/issues/261#issuecomment-16880836
33
+ def banner(command, _namespace = nil, _subcommand = nil)
34
+ "#{basename} opennebula #{command.usage}"
35
+ end
19
36
 
20
- def available_probes
21
- Nagios::Promoo::Opennebula::Probes.constants.collect { |probe| Nagios::Promoo::Opennebula::Probes.const_get(probe) }.reject { |probe| !probe.runnable? }
22
- end
23
- end
37
+ def available_probes
38
+ probes = Nagios::Promoo::Opennebula::Probes.constants.collect do |probe|
39
+ Nagios::Promoo::Opennebula::Probes.const_get(probe)
40
+ end
41
+ probes.select(&:runnable?)
42
+ end
43
+ end
24
44
 
25
- class_option :endpoint, type: :string, desc: 'OpenNebula XML-RPC endpoint', default: 'http://localhost:2633/RPC2'
26
- class_option :token, type: :string, desc: 'Authentication token', default: "file://#{ENV['HOME']}/.one/one_auth"
45
+ class_option :endpoint,
46
+ type: :string,
47
+ desc: 'OpenNebula XML-RPC endpoint',
48
+ default: 'http://localhost:2633/RPC2'
49
+ class_option :token,
50
+ type: :string,
51
+ desc: 'Authentication token',
52
+ default: "file://#{ENV['HOME']}/.one/one_auth"
27
53
 
28
- available_probes.each do |probe|
29
- desc *probe.description
30
- probe.options.each do |opt|
31
- option opt.first, opt.last
32
- end
33
- class_eval %Q^
54
+ available_probes.each do |probe|
55
+ desc(*probe.description)
56
+ probe.options.each do |opt|
57
+ option opt.first, opt.last
58
+ end
59
+ class_eval %^
34
60
  def #{probe.declaration}(*args)
35
61
  #{probe}.new(options).run(args)
36
62
  end
37
63
  ^
38
- end
64
+ end
39
65
 
40
- desc 'version', 'Print version of the OpenNebula probe set'
41
- def version
42
- puts Nagios::Promoo::Opennebula::VERSION
66
+ desc 'version', 'Print version of the OpenNebula probe set'
67
+ def version
68
+ puts Nagios::Promoo::Opennebula::VERSION
69
+ end
70
+ end
71
+ end
43
72
  end
44
73
  end
@@ -1,18 +1,41 @@
1
- class Nagios::Promoo::Opennebula::Probes::BaseProbe
2
- class << self
3
- def runnable?; false; end
4
- end
1
+ module Nagios
2
+ module Promoo
3
+ module Opennebula
4
+ module Probes
5
+ # Base probe for all ONe-related probes.
6
+ #
7
+ # @author Boris Parak <parak@cesnet.cz>
8
+ class BaseProbe
9
+ class << self
10
+ def runnable?
11
+ false
12
+ end
13
+ end
5
14
 
6
- attr_reader :options
15
+ attr_reader :options
7
16
 
8
- def initialize(options)
9
- @options = options
10
- end
17
+ def initialize(options)
18
+ @options = options
19
+ end
20
+
21
+ def client
22
+ return @_client if @_client
23
+
24
+ token = token_file? ? read_token : options[:token]
25
+ @_client = OpenNebula::Client.new(token.to_s, options[:endpoint])
26
+ end
27
+
28
+ private
11
29
 
12
- def client
13
- return @_client if @_client
30
+ def token_file?
31
+ options[:token].start_with?('file://')
32
+ end
14
33
 
15
- token = options[:token].start_with?('file://') ? File.read(options[:token].gsub('file://', '')) : options[:token]
16
- @_client = OpenNebula::Client.new("#{token}", options[:endpoint])
34
+ def read_token
35
+ File.read(options[:token].gsub('file://', ''))
36
+ end
37
+ end
38
+ end
39
+ end
17
40
  end
18
41
  end
@@ -1,106 +1,144 @@
1
1
  # Internal deps
2
2
  require File.join(File.dirname(__FILE__), 'base_probe')
3
3
 
4
- class Nagios::Promoo::Opennebula::Probes::VirtualMachineProbe < Nagios::Promoo::Opennebula::Probes::BaseProbe
5
- class << self
6
- def description
7
- ['virtual-machine', 'Run a probe instantiating a test instance in OpenNebula']
8
- end
9
-
10
- def options
11
- [
12
- [:template, { type: :string, default: 'monitoring', desc: 'Name referencing a template used for monitoring purposes' }],
13
- [:vm_timeout, { type: :numeric, default: 180, desc: 'Timeout for VM instantiation (in seconds)' }],
14
- [:cleanup, { type: :boolean, default: true, desc: 'Perform clean-up before launching a new instance' }],
15
- ]
16
- end
17
-
18
- def declaration
19
- "virtual_machine"
20
- end
21
-
22
- def runnable?; true; end
23
- end
24
-
25
- VM_NAME_PREFIX = "nagios-promoo"
26
-
27
- def run(args = [])
28
- fail "Timeout (#{options[:timeout]}) must be higher than "\
29
- "vm-timeout (#{options[:vm_timeout]}) " if options[:timeout] <= options[:vm_timeout]
30
-
31
- @_virtual_machine = nil
32
-
33
- Timeout::timeout(options[:timeout]) {
34
- cleanup if options[:cleanup]
35
- create
36
- wait4running
37
- }
38
-
39
- puts "VirtualMachine OK - Instance #{@_virtual_machine.id.inspect} of template "\
40
- "#{options[:template].inspect} successfully created & cleaned up"
41
- rescue => ex
42
- puts "VirtualMachine CRITICAL - #{ex.message}"
43
- puts ex.backtrace if options[:debug]
44
- exit 2
45
- ensure
46
- begin
47
- cleanup @_virtual_machine unless @_virtual_machine.blank?
48
- rescue => ex
49
- ## ignoring
50
- end
51
- end
52
-
53
- private
54
-
55
- def cleanup(virtual_machine = nil)
56
- virtual_machine ? shutdown_or_delete(virtual_machine) : search_and_destroy
57
- end
58
-
59
- def create
60
- template_pool = OpenNebula::TemplatePool.new(client)
61
- rc = template_pool.info_all
62
- fail rc.message if OpenNebula.is_error?(rc)
63
-
64
- template = template_pool.select { |tpl| tpl.name == options[:template] }.first
65
- fail "Template #{options[:template].inspect} could not be found" unless template
66
-
67
- vm_id = template.instantiate("#{VM_NAME_PREFIX}-#{Time.now.to_i}")
68
- fail vm_id.message if OpenNebula.is_error?(vm_id)
69
-
70
- virtual_machine = OpenNebula::VirtualMachine.new(OpenNebula::VirtualMachine.build_xml(vm_id), client)
71
- rc = virtual_machine.info
72
- fail rc.message if OpenNebula.is_error?(rc)
73
-
74
- @_virtual_machine = virtual_machine
75
- end
76
-
77
- def wait4running
78
- Timeout::timeout(options[:vm_timeout]) {
79
- while @_virtual_machine.lcm_state_str != 'RUNNING' do
80
- fail 'Instance deployment failed (resulting state is "*_FAILED")' if @_virtual_machine.lcm_state_str.include?('FAILURE')
81
- rc = @_virtual_machine.info
82
- fail rc.message if OpenNebula.is_error?(rc)
4
+ module Nagios
5
+ module Promoo
6
+ module Opennebula
7
+ module Probes
8
+ # Probe for checking VM instantiation via ONe RPC2.
9
+ #
10
+ # @author Boris Parak <parak@cesnet.cz>
11
+ class VirtualMachineProbe < Nagios::Promoo::Opennebula::Probes::BaseProbe
12
+ class << self
13
+ def description
14
+ ['virtual-machine', 'Run a probe instantiating a test instance in OpenNebula']
15
+ end
16
+
17
+ def options
18
+ [
19
+ [
20
+ :template,
21
+ {
22
+ type: :string, default: 'monitoring',
23
+ desc: 'Name referencing a template used for monitoring purposes'
24
+ }
25
+ ],
26
+ [
27
+ :vm_timeout,
28
+ {
29
+ type: :numeric, default: 180,
30
+ desc: 'Timeout for VM instantiation (in seconds)'
31
+ }
32
+ ],
33
+ [
34
+ :cleanup,
35
+ {
36
+ type: :boolean, default: true,
37
+ desc: 'Perform clean-up before launching a new instance'
38
+ }
39
+ ]
40
+ ]
41
+ end
42
+
43
+ def declaration
44
+ 'virtual_machine'
45
+ end
46
+
47
+ def runnable?
48
+ true
49
+ end
50
+ end
51
+
52
+ VM_NAME_PREFIX = 'nagios-promoo'.freeze
53
+
54
+ def run(_args = [])
55
+ if options[:timeout] <= options[:vm_timeout]
56
+ raise "Timeout (#{options[:timeout]}) must be higher than "\
57
+ "vm-timeout (#{options[:vm_timeout]}) "
58
+ end
59
+
60
+ @_virtual_machine = nil
61
+
62
+ Timeout.timeout(options[:timeout]) do
63
+ cleanup if options[:cleanup]
64
+ create
65
+ wait4running
66
+ end
67
+
68
+ puts "VirtualMachine OK - Instance #{@_virtual_machine.id.inspect} of template "\
69
+ "#{options[:template].inspect} successfully created & cleaned up"
70
+ rescue => ex
71
+ puts "VirtualMachine CRITICAL - #{ex.message}"
72
+ puts ex.backtrace if options[:debug]
73
+ exit 2
74
+ ensure
75
+ begin
76
+ cleanup @_virtual_machine unless @_virtual_machine.blank?
77
+ rescue => ex
78
+ puts "VirtualMachine CRITICAL - #{ex.message}"
79
+ puts ex.backtrace if options[:debug]
80
+ exit 2
81
+ end
82
+ end
83
+
84
+ private
85
+
86
+ def cleanup(virtual_machine = nil)
87
+ virtual_machine ? shutdown_or_delete(virtual_machine) : search_and_destroy
88
+ end
89
+
90
+ def create
91
+ template_pool = OpenNebula::TemplatePool.new(client)
92
+ rc = template_pool.info_all
93
+ raise rc.message if OpenNebula.is_error?(rc)
94
+
95
+ template = template_pool.select { |tpl| tpl.name == options[:template] }.first
96
+ raise "Template #{options[:template].inspect} could not be found" unless template
97
+
98
+ vm_id = template.instantiate("#{VM_NAME_PREFIX}-#{Time.now.to_i}")
99
+ raise vm_id.message if OpenNebula.is_error?(vm_id)
100
+
101
+ virtual_machine = OpenNebula::VirtualMachine.new(OpenNebula::VirtualMachine.build_xml(vm_id), client)
102
+ rc = virtual_machine.info
103
+ raise rc.message if OpenNebula.is_error?(rc)
104
+
105
+ @_virtual_machine = virtual_machine
106
+ end
107
+
108
+ def wait4running
109
+ Timeout.timeout(options[:vm_timeout]) do
110
+ while @_virtual_machine.lcm_state_str != 'RUNNING'
111
+ if @_virtual_machine.lcm_state_str.include?('FAILURE')
112
+ raise 'Instance deployment failed (resulting state is "*_FAILED")'
113
+ end
114
+
115
+ rc = @_virtual_machine.info
116
+ raise rc.message if OpenNebula.is_error?(rc)
117
+ end
118
+ end
119
+ rescue Timeout::Error
120
+ puts 'VirtualMachine WARNING - Execution timed out while waiting for ' \
121
+ "the instance to become active [#{options[:vm_timeout]}s]"
122
+ exit 1
123
+ end
124
+
125
+ def search_and_destroy
126
+ vm_pool = OpenNebula::VirtualMachinePool.new(client)
127
+ rc = vm_pool.info_mine
128
+ raise rc.message if OpenNebula.is_error?(rc)
129
+
130
+ candidates = vm_pool.select { |vm| vm.name.start_with?(VM_NAME_PREFIX) }
131
+ candidates.each { |vm| shutdown_or_delete(vm) }
132
+
133
+ candidates.count
134
+ end
135
+
136
+ def shutdown_or_delete(virtual_machine)
137
+ rc = virtual_machine.terminate true
138
+ raise rc.message if OpenNebula.is_error?(rc)
139
+ end
140
+ end
83
141
  end
84
- }
85
- rescue Timeout::Error => ex
86
- puts "VirtualMachine WARNING - Execution timed out while waiting for " \
87
- "the instance to become active [#{options[:vm_timeout]}s]"
88
- exit 1
89
- end
90
-
91
- def search_and_destroy
92
- vm_pool = OpenNebula::VirtualMachinePool.new(client)
93
- rc = vm_pool.info_mine
94
- fail rc.message if OpenNebula.is_error?(rc)
95
-
96
- candidates = vm_pool.select { |vm| vm.name.start_with?(VM_NAME_PREFIX) }
97
- candidates.each { |vm| shutdown_or_delete(vm) }
98
-
99
- candidates.count
100
- end
101
-
102
- def shutdown_or_delete(virtual_machine)
103
- rc = virtual_machine.terminate true
104
- fail rc.message if OpenNebula.is_error?(rc)
142
+ end
105
143
  end
106
144
  end