Wednesday, March 5, 2008

How to Do Remote Debugging from the RMB

In the RMB it is documented that you can debug a resource model on a remote Windows machine. However, it is not actually documented on how you can really do this
The scenario is that you want to test a resource model from your desktop and point to a remote machine's WMI CIM repository. The RMB has a built-in CIM browser that allows you to connect to other Windows machine's CIM repository. When you invoke the RMB Basic Resource Model wizard or when you add a new class you can point to another machine by prefixing the namespace with the hostname.

For Example:

//gbs100\root\cimv2

Hint: Use the lightning bolt, after you type in the namespace, to connect to another namespace.

The CIM browser will then ask you for a userid and password when you try to connect to a remote namespace. After you have selected a remote WMI class the wizard will generate a fully qualified namespace reference in the DefineClass method in your SetDefaultConfig function.

For Example:

// Dynamic model section
//<>
Svc.DefineClass ("CIM", "Win32_Service", "//gbs100\\root\\cimv2:Win32_Service",.
//<<\DATA_INFO>>

The problem is that, in most cases, if you try to run your resource model from the RMB it will fail because your local session will not be able to authenticate to the remote CIM repository. There is an undocumented method you can use to make the resource model do a remote authentication. It is called SetRemoteDataCollectionCredentials. You can call the SetRemoteCollectionCredentials method any where in the SetDefaultConfig function. However, since the SetRemoteDataCollectionCredentials method supplies the hostname, userid, and password as input parameters you will need to remove the hostname from the original DefineClass method generated by the wizard. Unfortunitly the namespace field is a display only field. Therefore, you have to move the DefineClass definition out of the dynamic model section before you can edit those method parameters. The easiest way to do this is to copy the DefineClass method to the bottom of your SetDefaultConfig function and then you can make the changes. You can also put the SetRemoteDataCollectionCredentials method call in the same place. Remember if you copy the DefineClass method from the Dynamic Model section you will need to make sure you delete the class definition from the RMB IDE (Integrated Developement Environment). You can delete the Event element from the left hand pane in the RMB). Otherwise the IDE will put the DefineClass right back into your SetDefaultCOnfig routine in the Dynamic model section and you will have two DefineClass defintions. Here is an example of what the source code should look like in your final SetDefaultConfig function:

// Dynamic model section
//<>
//<<\DATA_INFO>>

Svc.DefineClass("CIM", "Win32_Service", "root\\cimv2:Win32_Service", "", "..", "..", "None", "", 0,1);

Svc.SetRemoteDataCollectionCredentials(1,"gbs100","DS\\jwillis","mypassword");

By the way, you can also use this technique outside of the RMB when you are running your resource model on an endpoint. If you want to create a resource model that connects to a remote machine's WMI you can use the same SetRemoteDataCollectionCredentials method as described above. The downside is that you will have to hardwire the password in your code.


No comments: