Class: Ucert::AixTracker

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/ucert/aix_tracker.rb

Overview

Class to handle AIX user account IDs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#file_2_list, #is_fqdn?, #is_ip?, #is_url?, #list_2_file, #load_known_user_map_from_file, #nslookup, #search_ad, #update_dn

Constructor Details

#initialize(params = {}) ⇒ AixTracker

Instance default variables



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ucert/aix_tracker.rb', line 19

def initialize (params ={})
   @verbose=params.fetch(:verbose, false)
   # AIX user entitlement report generation:
	# Contact IT Department to provide a copy of the ''/etc/passwd' file on each AIX system
	# rename the 'passwd' file to 'hostname.txt' and send them to us.
   #
	# define a list of AIX password files that we'll need to obain and upload to the server here
	@aix_passwd_file_list=["EGIFTS1.txt", "NYSWIFT1.txt", "T24_APP1.txt", "T24_DBP.txt"]
   @aix_passwd_files = @aix_passwd_file_list.map {|x| File.dirname(__FILE__) + "/../../data/aix/" + x}
   # AIX to AD user map file
   @file_aix_user_map =  File.dirname(__FILE__)+"/../../data/aix/aix_user_map.txt"
	# Load user map from the local cacsh file
	@aix_2_ad_user=load_known_user_map_from_file(@file_aix_user_map)
	# Load the user entitlement instance variable from the user report
	@aix_user_entitlement=parse_aix_passwd_files(@aix_passwd_files)
	# Procedure to add DN foreign key to the @aix_user_entitlement, by performing the AD search
	insert_dn
	# Save the user map to local cache file
	save!
end

Instance Attribute Details

#aix_2_ad_userObject (readonly)

Returns the value of attribute aix_2_ad_user.



16
17
18
# File 'lib/ucert/aix_tracker.rb', line 16

def aix_2_ad_user
  @aix_2_ad_user
end

#aix_passwd_file_listObject

Class constant variables



15
16
17
# File 'lib/ucert/aix_tracker.rb', line 15

def aix_passwd_file_list
  @aix_passwd_file_list
end

#aix_passwd_filesObject

Class constant variables



15
16
17
# File 'lib/ucert/aix_tracker.rb', line 15

def aix_passwd_files
  @aix_passwd_files
end

#aix_user_entitlementObject (readonly)

Returns the value of attribute aix_user_entitlement.



16
17
18
# File 'lib/ucert/aix_tracker.rb', line 16

def aix_user_entitlement
  @aix_user_entitlement
end

#aix_user_status_reportObject

Class constant variables



15
16
17
# File 'lib/ucert/aix_tracker.rb', line 15

def aix_user_status_report
  @aix_user_status_report
end

#file_aix_user_mapObject

Class constant variables



15
16
17
# File 'lib/ucert/aix_tracker.rb', line 15

def file_aix_user_map
  @file_aix_user_map
end

#verboseObject

Class constant variables



15
16
17
# File 'lib/ucert/aix_tracker.rb', line 15

def verbose
  @verbose
end

Instance Method Details

#db_search_by_dn(dn) ⇒ Object Also known as: search_by_dn

Search user entitlement record by AD DN



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/ucert/aix_tracker.rb', line 160

def db_search_by_dn (dn)
	begin
     puts "Perform search on the user entitlement records by AD DN: #{dn}" if @verbose
     @aix_user_entitlement.each do |key, val|
         return val if @aix_user_entitlement[key]['DN'].eql? dn
     end
		return nil
   rescue => ee
     puts "Exception on method #{__method__}: #{ee}"
   end
end

#dn_2_index(dn) ⇒ Object

Retrieve the user index from the @aix_user_entitlement data structure



83
84
85
86
87
88
89
90
91
# File 'lib/ucert/aix_tracker.rb', line 83

def dn_2_index (dn)
		begin
       (1..@aix_user_entitlement.count).map do |index|
         return index if @aix_user_entitlement[index]["DN"]==dn
       end
		rescue => ee
			puts "Exception on method #{__method__}: #{ee}"
		end
end