Module: PuppetX::VMware::Mapper
- Defined in:
- lib/puppet_x/vmware/mapper/cluster_config_spec_ex_map.rb,
lib/puppet_x/vmware/mapper.rb
Overview
Copyright © 2013 VMware, Inc.
Defined Under Namespace
Classes: ClusterConfigSpecExMap, Leaf, LeafData, Map, MapComponent, Node, NodeData
Class Method Summary
collapse
Class Method Details
.munge_to_i ⇒ Object
This is a set of tiny utilities for defining validation and munging routines in the input tree for Map. Some are simply static blocks wrapped in Proc, while others allow tailoring the block to specific cases.
288
289
290
|
# File 'lib/puppet_x/vmware/mapper.rb', line 288
def self.munge_to_i
Proc.new {|v| v.to_i}
end
|
.munge_to_sym ⇒ Object
302
303
304
305
306
|
# File 'lib/puppet_x/vmware/mapper.rb', line 302
def self.munge_to_sym
Proc.new do |v|
v.to_sym if String === v
end
end
|
.munge_to_tfsyms ⇒ Object
292
293
294
295
296
297
298
299
300
|
# File 'lib/puppet_x/vmware/mapper.rb', line 292
def self.munge_to_tfsyms
Proc.new do |v|
case v
when FalseClass then :false
when TrueClass then :true
else v
end
end
end
|
.new_map(mapname) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/puppet_x/vmware/mapper.rb', line 13
def self.new_map mapname
mapfile = PuppetX::VMware::Util.snakeize mapname
require 'pathname'
file_path = Pathname.new(__FILE__)
Puppet.debug "require \"#{file_path.parent}/#{file_path.basename '.rb'}/#{mapfile}\""
require "#{file_path.parent}/#{file_path.basename '.rb'}/#{mapfile}"
PuppetX::VMware::Mapper::const_get(mapname).new
rescue Exception => e
fail "#{self.name}: Error accessing or creating mapper \"#{mapname}\": #{e.message}"
end
|
.validate_i_ge(low) ⇒ Object
308
309
310
311
312
313
|
# File 'lib/puppet_x/vmware/mapper.rb', line 308
def self.validate_i_ge(low)
Proc.new do |v|
v = Integer v
fail "value #{v} not greater than nor equal to #{low}" unless low <= v
end
end
|
.validate_i_in(range) ⇒ Object
322
323
324
325
326
327
|
# File 'lib/puppet_x/vmware/mapper.rb', line 322
def self.validate_i_in(range)
Proc.new do |v|
v = Integer v
fail "value #{v} not in '#{range.inspect}'" unless range.include? v
end
end
|
.validate_i_le(high) ⇒ Object
315
316
317
318
319
320
|
# File 'lib/puppet_x/vmware/mapper.rb', line 315
def self.validate_i_le(high)
Proc.new do |v|
v = Integer v
fail "value #{v} not less than nor equal to #{high}" unless v <= high
end
end
|