Class: Simp::Cli::Config::Item::Netmask

Inherits:
Simp::Cli::Config::Item show all
Defined in:
lib/simp/cli/config/item/netmask.rb

Instance Attribute Summary

Attributes inherited from Simp::Cli::Config::Item

#allow_user_apply, #config_items, #description, #die_on_apply_fail, #fact, #fail_on_missing_answer, #key, #next_items_tree, #silent, #skip_apply, #skip_query, #skip_yaml, #value

Instance Method Summary collapse

Methods inherited from Simp::Cli::Config::Item

#apply, #default_value, #highline_question_type, #next_items, #not_valid_message, #print_banner, #print_summary, #puppet_value, #query, #query_ask, #query_extras, #query_status, #safe_apply, #say_blue, #say_green, #say_red, #say_yellow, #to_yaml_s

Constructor Details

#initializeNetmask

Returns a new instance of Netmask.



9
10
11
12
13
14
# File 'lib/simp/cli/config/item/netmask.rb', line 9

def initialize
  super
  @key         = 'netmask'
  @description = %q{The netmask of the system.}
  @__warning   = false
end

Instance Method Details

#os_valueObject

TODO: comment upon the hell-logic below TODO: possibly refactor ip and netmask os_value into shared parent



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/simp/cli/config/item/netmask.rb', line 22

def os_value
  netmask = nil
  nic = @config_items.fetch('network::interface').value
  if nic || @fact
    @fact = @fact || "netmask_#{nic}"
    netmask = super
    if netmask.nil? and !@__warning
      warning = "WARNING: #{@key}: No Netmask found for NIC #{nic}"
      say "<%= color(%q{#{warning}}, YELLOW) %>\n"
      @__warning = true
    end
  end
  netmask
end


37
# File 'lib/simp/cli/config/item/netmask.rb', line 37

def recommended_value; os_value; end

#validate(x) ⇒ Object



16
17
18
# File 'lib/simp/cli/config/item/netmask.rb', line 16

def validate( x )
  Simp::Cli::Config::Utils.validate_netmask x
end