Adding Admin or Site Information to Hosts in TADDM

The TADDM Model can be a pain in the ass. Customers don’t normally ask me to add site information or admin information to Objects in TADDM. The last time it happened was over 2 years ago, however, my current customer asked me to add it from a spreadsheet that they provided to me (never mind that the spreadsheet contained host information that was more than 6 months old (since prior to Hurricane Sandy).

Ok, so I looked back to try to find the code form the previous time I added site info programmatically and I couldn’t locate it. Oh well, its not rocket science.

I wrote a shell script which used awk to pull the fields out of the provided spreadsheet (in CSV format) and then wrote a java program to create a SiteInfo object and add it to the computer system which was fetched by name from TADDM using an api call.

Here is the important part of the shell script:

h=`echo $line |awk -F, ‘{print $3}’`
site=`echo $line |awk -F, ‘{print $1}’`
rackpos=`echo $line |awk -F, ‘{print $4}’`
busDesc=`echo $line |awk -F, ‘{print $5}’`
busOwn=`echo $line |awk -F, ‘{print $7, “,”, $8}’`

And the call to the java program:

java SetAdminInfo localhost administrator collation “$h” “$site” “$rackpos” “$busDesc” “$busOwn”

Now, the tricky bit. If you were going to set something in TADDM that shows up in the details panel as “site”, you might search through the model and eventually settle on the SiteInfo class (which is what I did). You’d be wrong.

I went to all the work of adding the stuff to the computer system object by attaching a populated instance of SiteInfo only to find that it didn’t show up in the UI. I went through all the standard troubleshooting assuming it was a problem with TADDM (restarted the UI, etc.) but to no avail.

Turns out the proper object to populate is AdminInfo. Here is the salient parts of the java program:

 /* create new AdminInfo */
Class aClass=com.collation.platform.model.topology.admin.AdminInfo.class;
AdminInfo admininfo=(AdminInfo)ModelObjectFactory.newInstance(aClass);
admininfo.setObjGuid(comp.getGuid());
admininfo.setSite(sitename);
admininfo.setName(comp.getName());
admininfo.setDescription(busdesc);
api.update(admininfo,null);
aClass=com.collation.platform.model.topology.admin.SiteInfo.class;
SiteInfo siteinfo=(SiteInfo)ModelObjectFactory.newInstance(aClass);
siteinfo.setName(sitename);
siteinfo.setRackPosition(rackpos);
comp.setSiteInfo(siteinfo);
api.update(comp,null);

As you can see from the code, I needed to set BOTH AdminInfo and SiteInfo because AdminInfo doesn’t have a place to set rack location….

Success! Except, I now notice that SiteInfo doesn’t show up on the details panel…. I opened RFE 33221 on that.

 

Comments are closed.