Class: Ucert::StbTracker
- Inherits:
-
Object
- Object
- Ucert::StbTracker
- Includes:
- Utils
- Defined in:
- lib/ucert/stb_tracker.rb
Overview
Class to handle STB user account IDs
Instance Attribute Summary collapse
-
#file_stb_user_map ⇒ Object
Class constant variables.
-
#stb_2_ad_user ⇒ Object
readonly
Returns the value of attribute stb_2_ad_user.
-
#stb_user_entitlement ⇒ Object
readonly
Returns the value of attribute stb_user_entitlement.
-
#stb_user_entitlement_report ⇒ Object
Class constant variables.
-
#stb_user_group_entitlement ⇒ Object
readonly
Returns the value of attribute stb_user_group_entitlement.
-
#stb_user_status_report ⇒ Object
Class constant variables.
-
#verbose ⇒ Object
Class constant variables.
Instance Method Summary collapse
-
#db_search_by_dn(dn) ⇒ Object
(also: #search_by_dn)
Search user entitlement record by AD DN.
-
#dn_2_index(dn) ⇒ Object
Retrieve the user index from the @stb_user_entitlement data structure.
-
#initialize(params = {}) ⇒ StbTracker
constructor
Instance default variables.
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 = {}) ⇒ StbTracker
Instance default variables
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ucert/stb_tracker.rb', line 19 def initialize (params ={}) @verbose=params.fetch(:verbose, false) # STB user entitlement report generation: Logon to STBAdmin program in the production VM # Once logon, click "Reports" -> "Users" -> "Print Report"-> Save to PDF file # Convert PDF file into CSV file using online utility https://pdftables.com/ # @stb_user_entitlement_report = File.dirname(__FILE__)+"/../../data/stb/STB_USERS.csv" # STB to AD user map file @file_stb_user_map = File.dirname(__FILE__)+"/../../data/stb/stb_user_map.txt" # Load user map from the local cacsh file @stb_2_ad_user=load_known_user_map_from_file(@file_stb_user_map) # Load the user entitlement instance variable from the user report @stb_user_entitlement=parse_stb_user_entitlement_report(@stb_user_entitlement_report) # Procedure to add DN foreign key to the @stb_user_entitlement, by performing the AD search insert_dn # Save the user map to local cache file save! end |
Instance Attribute Details
#file_stb_user_map ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/stb_tracker.rb', line 15 def file_stb_user_map @file_stb_user_map end |
#stb_2_ad_user ⇒ Object (readonly)
Returns the value of attribute stb_2_ad_user.
16 17 18 |
# File 'lib/ucert/stb_tracker.rb', line 16 def stb_2_ad_user @stb_2_ad_user end |
#stb_user_entitlement ⇒ Object (readonly)
Returns the value of attribute stb_user_entitlement.
16 17 18 |
# File 'lib/ucert/stb_tracker.rb', line 16 def stb_user_entitlement @stb_user_entitlement end |
#stb_user_entitlement_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/stb_tracker.rb', line 15 def stb_user_entitlement_report @stb_user_entitlement_report end |
#stb_user_group_entitlement ⇒ Object (readonly)
Returns the value of attribute stb_user_group_entitlement.
16 17 18 |
# File 'lib/ucert/stb_tracker.rb', line 16 def stb_user_group_entitlement @stb_user_group_entitlement end |
#stb_user_status_report ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/stb_tracker.rb', line 15 def stb_user_status_report @stb_user_status_report end |
#verbose ⇒ Object
Class constant variables
15 16 17 |
# File 'lib/ucert/stb_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
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/ucert/stb_tracker.rb', line 184 def db_search_by_dn (dn) begin puts "Perform search on the user entitlement records by AD DN: #{dn}" if @verbose @stb_user_entitlement.each do |key, val| return val if @stb_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 @stb_user_entitlement data structure
96 97 98 99 100 101 102 103 104 |
# File 'lib/ucert/stb_tracker.rb', line 96 def dn_2_index (dn) begin (1..@stb_user_entitlement.count).map do |index| return index if @stb_user_entitlement[index]["DN"]==dn end rescue => ee puts "Exception on method #{__method__}: #{ee}" end end |