Class: Simp::Cli::Config::Item::LdapUri

Inherits:
ListItem show all
Defined in:
lib/simp/cli/config/item/ldap_uri.rb

Overview

FIXME: what is this for?

Instance Attribute Summary

Attributes inherited from ListItem

#allow_empty_list

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 ListItem

#highline_question_type, #not_valid_message, #query_extras, #validate

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, #validate

Constructor Details

#initializeLdapUri

Returns a new instance of LdapUri.



11
12
13
14
15
# File 'lib/simp/cli/config/item/ldap_uri.rb', line 11

def initialize
  super
  @key         = 'ldap::uri'
  @description = %Q{List of OpenLDAP servers in URI form (ldap://server)}
end

Instance Method Details

#os_valueObject



18
19
20
21
22
23
24
# File 'lib/simp/cli/config/item/ldap_uri.rb', line 18

def os_value
  values = `grep URI /etc/openldap/ldap.conf`.split("\n").map do |line|
    line =~ /^\s*URI\s+(.+)\s*/
    $1
  end.compact
  values
end


27
28
29
30
31
# File 'lib/simp/cli/config/item/ldap_uri.rb', line 27

def recommended_value
  if item = @config_items.fetch( 'hostname', nil )
    [ "ldap://#{item.value}" ]
  end
end

#validate_item(item) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/simp/cli/config/item/ldap_uri.rb', line 34

def validate_item item
  ( item =~ %r{^ldap://.+} ) ? true : false &&
  (
    Simp::Cli::Config::Utils.validate_hostname( item ) ||
    Simp::Cli::Config::Utils.validate_fqdn( item )     ||
    Simp::Cli::Config::Utils.validate_ip( item )
  )
end