Class: Simp::Cli::Config::Item::IPAddress
- Inherits:
-
Simp::Cli::Config::Item
- Object
- Simp::Cli::Config::Item
- Simp::Cli::Config::Item::IPAddress
- Defined in:
- lib/simp/cli/config/item/ipaddress.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
-
#initialize ⇒ IPAddress
constructor
A new instance of IPAddress.
-
#os_value ⇒ Object
TODO: comment upon the hell-logic below Config::Items are happiest when @fact if set and Facter returns a value.
-
#recommended_value ⇒ Object
Always recommend the configured IP.
- #validate(x) ⇒ Object
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
#initialize ⇒ IPAddress
Returns a new instance of IPAddress.
8 9 10 11 12 13 |
# File 'lib/simp/cli/config/item/ipaddress.rb', line 8 def initialize super @key = 'ipaddress' @description = 'The IP address of this system' @__warning = false end |
Instance Method Details
#os_value ⇒ Object
TODO: comment upon the hell-logic below Config::Items are happiest when @fact if set and Facter returns a value
But any Item that relies on the value of interface has a problem in that facter can’t know which ipaddress_* fact to query until the value of interface is known.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/simp/cli/config/item/ipaddress.rb', line 22 def os_value ip = nil nic = @config_items.fetch( 'network::interface' ).value if nic || @fact @fact = @fact || "ipaddress_#{nic}" ip = super if ip.nil? and !@__warning warning = "WARNING: #{@key}: No IP Address found for NIC #{nic}" say "<%= color(%q{#{warning}}, YELLOW) %>\n" @__warning = true end end ip end |
#recommended_value ⇒ Object
Always recommend the configured IP
39 |
# File 'lib/simp/cli/config/item/ipaddress.rb', line 39 def recommended_value; os_value; end |
#validate(x) ⇒ Object
42 43 44 |
# File 'lib/simp/cli/config/item/ipaddress.rb', line 42 def validate( x ) Simp::Cli::Config::Utils.validate_ip x end |