Iterate over table and create records

Sven Brose
Tera Guru

Hello,

I have created a custom Discovery Pattern that runs against a MySQL server and retrieves a table containing the database names along with their sizes.

For each of these database entries, I would like to:

  1. Create or update a record in the table u_cmdb_ci_mysql_database.

  2. Create the appropriate relationship to the discovered MySQL instance.

My questions:

  • How can I achieve this in the Pattern Designer?

  • How can I iterate over the table and create one record in u_cmdb_ci_mysql_database for each entry?

Could using a Library Reference—a separate Pattern that creates the database CI—be a solution here?

How can I trigger the Library for each row in the parsed table?

How can I pass the data from the main Pattern to the Library?


Thank you for any advice.
(I will be on vacation for the next two weeks)

1 ACCEPTED SOLUTION

Sven Brose
Tera Guru

Found the solution by myself:

Looping through tables is possible by Transform Table step. 
Assumed Table MySQLTables contains values in columns Name and Memory. In Target-records the fields will be set via 
name = $MySQLTables[].Name
used_memory = $MySQLTables[].Memory

[] causes the iteration

Also its necessary to create the approbiate identifiers and relationships defined in Class Manager .

Good look!

 

View solution in original post

3 REPLIES 3

palanikumar
Mega Sage

Hi,

Refer the OOTB pattern "My SQL server On Windows and Linux" and create you pattern similar to this. You can use CI type as your custom CI table name

 

Thank you,
Palani

I will try after my vacation. Thanks so far.

Sven Brose
Tera Guru

Found the solution by myself:

Looping through tables is possible by Transform Table step. 
Assumed Table MySQLTables contains values in columns Name and Memory. In Target-records the fields will be set via 
name = $MySQLTables[].Name
used_memory = $MySQLTables[].Memory

[] causes the iteration

Also its necessary to create the approbiate identifiers and relationships defined in Class Manager .

Good look!