#!/opt/vdops/bin/perl # This script queries Soma for all hosts with a defined 'os_hostname' # (typically boxes reporting a NetBIOS name), queries LDAP servers # for the associated OU, and then updates the 'hosts.ad_ou' with the # results # Load modules use strict; use warnings; use Perl6::Say; use lib '/home/soma/lib'; use FHCRC::VDOPS::QueryLDAP; use FHCRC::VDOPS::QuerySoma; use FHCRC::VDOPS::SomaCrud; use FHCRC::VDOPS::SomaData; use FHCRC::VDOPS::Utilities; # Declare variables my $osHostname; # Ref to hash of hosts.os_hostname keyed by hosts.hostid my $ou; # Ref to hash of OUs keyed by hosts.hostid # Threads and debugs $debug = 0; $thrMode = 0; # Notify operator log_it("Beginning $0"); say "Beginning $0" if $job eq 'interactive'; # Build os_hostname hash $osHostname = grab_os_hostname(); # Build ad_ou hash $ou = gather_ou($osHostname); exit 0 unless defined $ou; # Update Soma iu_hosts_adou($ou); # Notify operator log_it("Ending $0"); say "Ending $0" if $job eq 'interactive';