Class: Berta::Utils::Filter
- Inherits:
-
Object
- Object
- Berta::Utils::Filter
- Defined in:
- lib/berta/utils/filter.rb
Overview
Base Filter class, filters out invalid states
Direct Known Subclasses
Constant Summary collapse
- IGNORED_STATES =
VM states to ignore
%w[PENDING HOLD].freeze
Instance Method Summary collapse
-
#initialize(ids, users, groups, clusters) ⇒ Filter
constructor
Constructs Filter object.
-
#run(vmhs) ⇒ Array<Berta::VirtualMachineHandler>
Execute this filter.
Constructor Details
#initialize(ids, users, groups, clusters) ⇒ Filter
Constructs Filter object.
14 15 16 17 18 19 20 21 |
# File 'lib/berta/utils/filter.rb', line 14 def initialize(ids, users, groups, clusters) @ids = ids || [] @users = users || [] @groups = groups || [] @clusters = clusters || [] logger.debug "Filter type: #{self.class}" log_filter end |
Instance Method Details
#run(vmhs) ⇒ Array<Berta::VirtualMachineHandler>
Execute this filter
27 28 29 30 31 32 33 |
# File 'lib/berta/utils/filter.rb', line 27 def run(vmhs) fvmhs = vmhs.select { |vmh| takes_resources?(vmh) } logger.debug "Filtered based on RESOURCE: #{(vmhs - fvmhs).map { |vmh| vmh.handle.id }}" fvmhs = filter(fvmhs) logger.debug "VMS after filter : #{fvmhs.map { |vmh| vmh.handle.id }}" fvmhs end |