[rt-users] RTAT Import?

Matthew Keller kellermg at potsdam.edu
Tue Apr 29 11:26:41 EDT 2008


The script below takes a tab-delimited file of format:

AssetTag Make Model Serial Building Room MACAddress

And populated a bunch of CFs. Salt to taste.



On Tue, 2008-04-29 at 14:01 +0000, Jean-Sebastien Morisset wrote:
> Has anyone developed a script or something to import an inventory into
> AT (from a csv file, for example)?
> 
> js.


#!/usr/bin/perl


use lib qw(/opt/rt3/local/lib /opt/rt3/lib);

use RT;
use RTx::AssetTracker::Asset;
RT::LoadConfig();
RT::Init();

use strict;


#### MAIN ########################


        my $BFILE="/opt/rt3/wslist";


        open(BF,"<$BFILE") or die "$!\n";

        my $ass = RTx::AssetTracker::Asset->new(RT->SystemUser);

        while(<BF>) {
                # 12478 Gateway E4100   0032459740      KEL-HL  219
00:0C:F1:D5:49:2E
                chomp;
                my @lineparts=split(/\t/);
                my $sysname=$lineparts[4];
                $sysname =~ s/\W.*$//; # Strip from non-word to eol
                $sysname .= $lineparts[5] . "-" . $lineparts[0];

                my ($id, undef, undef) = $ass->Create(Type =>
'Workstations', 
                                                        Name =>
"$sysname",
                                                        Status =>
'production',
                                                        'CustomField-7'
=> "$lineparts[0]", # Decal
                                                        'CustomField-3'
=> "$lineparts[1]", # Make
                                                        'CustomField-4'
=> "$lineparts[2]", # Model
                                                        'CustomField-8'
=> "$lineparts[3]", # Serial
                                                        'CustomField-59'
=> "$lineparts[4]", # Building
                                                        'CustomField-60'
=> "$lineparts[5]", # Room
                                                        'CustomField-62'
=> "$lineparts[6]", # MAC address
                                                        );
                print "$sysname created with id $id\n";
        }





More information about the rt-users mailing list