Tuesday, March 11, 2008

Managing ITM 6.1 MSLs using SOAP

One of the current limitations of ITM 6.1 is the lack of a command line utility to manipulate Managed System Lists (MSLs). Such a utility could be used to implement automation in very large environments where systems could be automatically added to custom MSLs without the need of operator interaction. As it turns out, a MSL is simply a number of rows in the EIB table O4SRV.TNODELST. Here is some basic info on how to populate this table and a proof of concept Perl script using the ITM 6.1 SOAP interface.

The O4SRV.TNODEST table contains the columns AFFINITIES, LOCFLAG, LSTDATE, LSTUSRPRF, NODE, NODELIST, NODETYPE, and QIBCLASSID. The NODELIST column represents the MSL name when the NODETYPE column is "M" and when this column is "V" the NODELST contains the managed system name. The AFFINITIES column is a long string that through some pattern matching specifies the application such as "Windows Systems" or "Linux Systems", but this value is not a unique identifier for each system. I am still trying to work out how the affinities work.
To create a MSL or add entries to a MSL, all you have to do is insert rows into the table. The trick is finding the affinity of the managed system and using some "magic" values for LOCFLAG, LSTDATE, and QIBCLASSID. LOCFLAG should be "" and LSTDATE "C". The "C" value appears to populate the column with the current timestamp. Use the value "5529" for QIBCLASSID. This value is the class ID for the IDDefNodeList object. The NODETYPE will be "M" as we will be dealing with a MSL.
To find out the AFFINITIES column value, we need to query the table to find the AFFINITIES value where the NODELIST equals the managed system we want to add and the NODETYPE is "V". As long as the affinities are the same, the managed system will show up in correct application. For example, if you select all LZ managed systems, then the new MSL will appear in the "Linux OS" section of the "Edit Managed System Lists" dialog window. If different types of systems are mixed then the MSL will appear in only one of the sections in the dialog. In order to create a MSL that will be displayed in the "All Managed Systems" group, each system affinity will have to be modified with the first 24 characters changed to "##################################". So the affinity 000800000000000000000000000000000G00000w0a7 would have to be inserted as ##################################00000w0a7.
The LSTUSRPRF column is the user doing the insert, i.e. "SYSADMIN"
So, to create an MSL called my_msl with the managed systems linux1:LZ and Linux2:LZ our SQL would be:
INSERT INTO O4SRV.TNODELST (AFFINITIES,LOCFLAG,LSTDATE,LSTUSRPRF NODE,NODELIST,NODETYPE,QIBCLASSID) VALUES("0000000000000000000000G0000000000200000w0a7","","C","SYSADMIN","linux1:LZ","my_msl","M","5529")
INSERT INTO O4SRV.TNODELST (AFFINITIES,LOCFLAG,LSTDATE,LSTUSRPRF NODE,NODELIST,NODETYPE,QIBCLASSID) VALUES("0000000000000000000000G0000000000200000w0a7","","C","SYSADMIN","linux2:LZ","my_msl","M","5529")

The insert statement can be executed using the SOAP interface:
<CT_Get>
<userid>SYSADMIN</userid>
<password>secret</password>
<action>start</action>
<table>O4SRV.LOCALTIME</table>
<sql>
INSERT INTO O4SRV.TNODELST (AFFINITIES,LOCFLAG,LSTDATE,LSTUSRPRF NODE,NODELIST,NODETYPE,QIBCLASSID) VALUES("0000000000000000000000G0000000000200000w0a7","","C","SYSADMIN","linux1:LZ","my_msl","M","5529")
</sql>
</CT_Get>
I have put together a rough Perl script you can use to create and list MSLs. Here is a usage summary:

msl.pl -lmsl.pl -l MSLmsl.pl -c NEW_MSL ManagedSystem [ManagedSystem2 ...]msl.pl -h -l     : Lists all managed system lists-l MSL : Lists all managed systems in a MSL-c NEW_MSL ManagedSystem [ManagedSystem2 ...]    Creates a Managed system list and adds the specified managed system to the list or adds the systems to an existing MSL-h : Prints help text 

You can download the Perl script here. This script will not create an MSL that shows up as an "All Managed Systems" MSL.
Look for an updated version gbscmd that will implement MSL management.

No comments: