in reply to Re: Need help with complex hash of hashes.
in thread Need help with complex hash of hashes.
I need the positions. The reason is I don't know anything about the data, and need to keep track fo things by column header. Yes, I will fix the cleanup, it was quick an dirty to just get rid of crap in the CMDB that shouldn't be there to begin with.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Need help with complex hash of hashes.
by poj (Abbot) on Jan 27, 2016 at 14:18 UTC | |
I don't understand this. With XML the order of the tags shouldn't matter. Anyway, here is my best guess at what you are trying to do, create a CSV of all the data and a hash structure of some of it.
Read more... (2 kB)
poj | [reply] [d/l] [select] |
by vlturner (Sexton) on Jan 27, 2016 at 16:23 UTC | |
I need to use that final hash to build out this CSV file. Now your code is great because it properly dumps the XML.csv, and now while I have the data in the big hash build out this secondary CSV file too. You can see where the list of member IP's need to go separated bu semicolons. member1;member2;member3
| [reply] [d/l] |
by vlturner (Sexton) on Jan 28, 2016 at 18:35 UTC | |
So my original code contained the following.
And POJ's code contains the following.
POJ's code when I do 10000 records is blowing up in the Twig module as follows.
It is deep in the Twig module when I single step, but I think its tied to some sort of overflow condition. Any ideas as to how to fix this? POJ, why did you change those lines? Here is the current code.
| [reply] [d/l] [select] |
by poj (Abbot) on Jan 28, 2016 at 20:04 UTC | |
Try changing last lines of record subroutine to this poj | [reply] [d/l] [select] |
by vlturner (Sexton) on Feb 02, 2016 at 01:45 UTC | |
by vlturner (Sexton) on Jan 29, 2016 at 23:36 UTC | |
|
Re^3: Need help with complex hash of hashes.
by jcb (Parson) on Jan 28, 2016 at 02:52 UTC | |
Does the first row returned contain a set of empty tags and subsequent rows contain the same tags with data? Something like:
Until, of course, you get to:
And your parsing by position produces bogus results. Or is it really XML-encoded CSV? More like:
In the former case, you don't need the positions after all, and the fact that they change from run to run should indicate that they are not significant. In the latter case, your CMDB belongs on the Daily WTF. Your code mentions an option for JSON output. Perhaps that module is less broken? | [reply] [d/l] [select] |
by vlturner (Sexton) on Jan 28, 2016 at 15:26 UTC | |
So there are 250K CI records. You have CI's for devices with their IP addresses where 'name' is the hostname and a referral CI ( 'u_application_id' )to the application they are children of, and you have CI's that are the application, where 'name' is the application name. You have no control of the order of the records. If the class name 'sys_class_name' is equal to 'cmdb_ci_appl' then it is an application name. If not then it is probably a device and if its 'u_application_id' CI matches and application CI 'u_ci_id' then its 'ip_address' is a member of that application. Now all lines have a CI 'u_ci_id' something like CI10001127. I hope this helps. We are trying to end up with a hash that looks like this.
But are ending up with this.
With no members.....
| [reply] [d/l] [select] |
by jcb (Parson) on Jan 29, 2016 at 04:05 UTC | |
After parsing the XML into something sane (see my previous comment), the next step is to build the hash you want:
This code has minimal consistency checks. Making it fully robust is left as an exercise for the reader. | [reply] [d/l] |
by vlturner (Sexton) on Jan 28, 2016 at 15:55 UTC | |
Here is an XML record
| [reply] [d/l] |
by poj (Abbot) on Jan 28, 2016 at 17:43 UTC | |
If you run this against your XML it will filter out the relevant tags
Result poj | [reply] [d/l] [select] |
by vlturner (Sexton) on Jan 28, 2016 at 18:56 UTC | |
by poj (Abbot) on Jan 28, 2016 at 19:33 UTC | |
| |
by poj (Abbot) on Jan 28, 2016 at 19:31 UTC | |
by jcb (Parson) on Jan 29, 2016 at 03:52 UTC | |
So here is some sample code that parses this into a hash with the sample XML embedded in the script at the __DATA__ marker:
This puts the entries into a hash and then dumps the hash to show that parsing works. I'll elaborate further in the other subthread. | [reply] [d/l] |