cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2324
Views
5
Helpful
8
Replies

Importing inventory file created by Data Extraction Engine into a database

jeff.whitmore
Level 1
Level 1

The inventory XML file created by cwexport does not create a file that is easy to parse because it does not contain the key relationships between the entities. This inventory xml file is "several layers deep", it is very difficult to work with. Is there a way to include the keys in the inventory export file - such as device id, so when we import this file into a relational database, all we have to do is restablish the primary key/foreign key relationships. When I try to import the inventory xml file into Access, several tables are created including Additional Information, Cisco_Backplane, Cisco_Card, Cisco_Chassis, Cisco_ComputerSystemPackage, Cisco_FlashDevice, Cisco_FLashfile, Cisco_FlashPartition, Cisco_Ifentry, Cisco_IPProtocolEndpoint, Cisco_LogicModule, Cisco_MemoryPool, Cisco_NetworkElement, Cisco_OSElement, Cisco_PhysicalMemory, Cisco_Port, SchemaInfo and SoftwareIdentity. There is no way to establish relationships between these tables to run queries because the keys are missing. Is there a way to have the keys put into the inventory xml file by editing the QueryFile.xml or the SchemaFile.xml ? Most XML files are flat files that are easy to import, this XML file is in a tree structure, which makes if very difficult to work with. Has anyone done anything like this before ?

8 Replies 8

getwithrob
Level 3
Level 3

Were you ever to make anything work with this? I tried to bring the xml file into Access and ran into the same problem yesterday. I've learned that a style sheet can be written and applied to the xml file to allow it to be opened with a browser in a table/column like report. I'm not a programmer so the stylesheet isn't very good that I put together. The stylesheet can be found on another post I sent out in this forum. Another guy posted a perl script that's probably the best way to go but I want to find solution taking this route since I've already spent so much time on it.

I made good progess today opening the xml file with Excel in office '03. I still have some work to do before it's right though. Once the Excel file is right, this could be loaded into Access.

This does nothing for the primay/forein key problem you found but it makes it possible to create a report with any number of columns of data arranged in any way one would like.

Again, please let me know if you've found a way to make the keys work so relationships can be built between the tables so this could opened/used with Access or other relational databases.

minielsen
Level 2
Level 2

Did you look at DevExp (http://sourceforge.net/docman/display_doc.php?docid=4812&group_id=25401) or DEEsv (http://sourceforge.net/docman/display_doc.php?docid=12909&group_id=25401)? They can export the inventory information from RME and DEE in CSV format.

Michael.

The problem with DEEsv.pl is there is too much information in the file making it very, very difficult to sort through several thousand devices and take out what's not needed once it's copied and pasted into excel. Too much information isn't much better, in this case, than any inforamtion.

It would be most useful if protocol endpoint, memory pool, interface and port information wasn't there but it is.

Our customer only cares about reporting on some information in that file not EVERYTHING.

I'm hoping mfreeman451 will post a perl script to make a report on the xml file containing the following:

Hostname

Chassis Model

Chassis Serial Number

Number of Slots

Card Type

Card Slot

Card Model

Card Serial Number

Number of Ports

Card HW Version

Card SW-FW Version

Daughter Cards (connects to some modules) is found in under AD in the xml file.

If he does that, I will most grateful and the user community probably will be as well.

Here we go..

#!/usr/bin/perl

# DEE Tool XML parser

###############################################

# To understand this, read the XML::Simple #

# Manpage and the XML file you are processing #

###############################################

use strict;

use XML::Simple;

use Data::Dumper;

my $xmlfile = shift @ARGV;

my $ref = XMLin("$xmlfile");

my $foo = $ref->{RMEPlatform};

my @array = @$foo;

foreach (@array) {

print "=-=-=-=-=-=-=-=-=-=-=-\n";

print "Offical Host Name: $_->{Cisco_NetworkElement}{OfficialHostName}\n";

print "Physical Position: $_->{Cisco_NetworkElement}{PhysicalPosition}\n";

print "Instance Name: $_->{Cisco_NetworkElement}{InstanceName}\n";

print "Description: $_->{Cisco_NetworkElement}{Description}\n";

print "Model: $_->{Cisco_Chassis}{Model}\n";

print "Serial Number: $_->{Cisco_Chassis}{SerialNumber}\n";

print "Chassis Type: $_->{Cisco_Chassis}{ChassisSystemType}\n";

print "Cards: \n";

my $bar = $_->{Cisco_Chassis}{Cisco_Card};

if (ref $bar) {

my @cards = @$bar;

foreach my $card (@cards) {

next unless ($card->{CardType});

print "\tCard Type: $card->{CardType}\n";

print "\tFirmware Version: $card->{SoftwareIdentity}[0]{VersionString}\n" if (ref($card) eq "ARRAY");

print "\tSoftware Version: $card->{SoftwareIdentity}[1]{VersionString}\n" if (ref($card) eq "ARRAY");

print "\tSerial Number: $card->{SerialNumber}\n";

print "\tHardware Version: $card->{HardwareVersion}\n";

print "\tModel: $card->{Model}\n";

print "\t=-=-=-=-=-=-=-=\n";

}

}

}

Hope this helps.

mfreeman@netcogov.com

This is awesome!!! I can't thank you enough. The xml module for perl isn't installed on any of the unix boxes running CW at work but I will open a ticket tomorrow to get someone in the unix group to put it on one if not all of them. In the mean time, I'll try to get it running on my pc and just ftp a file over to see it work.

Again, thank you so very much!!!

No problem. I think I wrote that 2 years ago under XP + ActiveState perl, so you shouldn't have any problems running it on your PC. If you have problems with your XML not being well-formed, let me know I have a few scripts kicking around that attempt to fix Cisco's broken XML..

mfreeman451
Level 1
Level 1

#!/usr/bin/perl

use XML::DT;

my $filename = shift @ARGV;

my % xml = ( Device => sub{"---- $v{name} ----\n$c"},

RMEServer => sub{"RME Server: $v{Name}\n$c"},

-default => sub{"$c"}

);

print dt($filename, %xml);

I forgot to mention what this does.. use this perl script if you want to simply print out all the crap in the XML files, it is a down tree processor, so it will remove all the tags.. You could use this to print out configs or inventory data straight into flatfiles or pump it into a blob in a database (yuck)

syntax: ./script.pl