An Event Procedure to copy the value of the device model name to a custom attribute on an interface model
search cancel

An Event Procedure to copy the value of the device model name to a custom attribute on an interface model

book

Article ID: 256126

calendar_today

Updated On:

Products

CA Spectrum DX NetOps

Issue/Introduction

The following is an Event Procedure to copy the value of the model name attribute of a device model to a custom attribute on an interface model.

This Event Procedure can be used to copy the value of other attribute from the device model to the interface model as well.

Environment

Version: Any
Component: Events and Alarms

Resolution

The first step is to create a custom attribute using the  Model Type Editor (MTE)

Spectrum uses a model type hierarchy. If one model type is used as a base model type for another, the new model automatically inherits the attribute from the base model type.

All model types start at the root model type.

NOTE: Using MTE requires having an X-Windows client loaded on the client system.

- Shutdown the SpectroSERVER

- If on Windows, Start a bash shell by running "bash -login"

- cd to the $SPECROOT/SS directory and enter the following command to start MTE:

../SS-Tools/mte -logging

NOTE: The reason for using the "-logging" parameter is because MTE will create an mte xml file that contains the changes made to the catalog. Then you can import this mte xml file into other SpectroSERVER database catalogs in the environment so the catalogs are all consistent. 

- Click on the Model Types tab in the Navigation panel, find and select the Root model type

- Click on the Attributes tab in the Contents panel

- Click on the plus "+" icon in the Attributes tab to create a new attribute

- Create a new attribute with the following information (The example below uses DevMdlName for the attribute name. You can use any attribute name for your environment.)

- Click the OK button

- Make a note of the attribute id of the new DevMdlName attribute

- Select File -> Commit to Database from the top level menu then click on the OK button to save the changes to the permanent catalog

- Select File -> Exit from the top level menu then click OK to exit

You should see something similar to the following in the bash shell where you started MTE:

[spectrum@spectrum1 SS]$ ../SS-Tools/mte -logging
This MTE session will be logged to mte_change.1213_113912.xml
Opening new log file mte_change.1213_113912.xml
[spectrum@spectrum1 SS]$

NOTE: mte_change.1213_113912.xml is the mte xml file that can be used to import into other SpectroSERVER database catalogs in the environment. This will be discuss later on in this knowledge article.

 

The next step is to create the Event Procedure to to take the value of the sysName attribute from the device model and copy it to the custom attribute.

In the same bash shell, cd to the $SPECROOT/custom/Events directory and add the following to the current EventDisp file if there. If not there, create a new EventDisp file. Replace 0xffff0000 with the attribute id of your DevMdlName attribute.

0x00010d67 E 50 C 0x00010d66 P "WriteAttribute( {C CURRENT_MODEL}, {H 0xffff0000},  ReadAttribute( ReadAttribute({ C CURRENT_MODEL}, {H 0x10069}), {H 0x1006e }))"

The 0x00010d67 event is generated on an interface model at model activation when the SpectroSERVER is restarted and when a new interface model is created.

The 0x10069 attribute on the interface model contains the model handle of the interfaces associated device model.

Attribute 0x1006e is the attribute id for the model name.

When the 0x00010d67 event is generated on the interface model, the Event Procedure grabs the model handle of the associated device model, gets the value of the model name from the device model and writes it to the custom attribute (0xffff0000 in the example above).

- Start the SpectroSERVER as normal

- Restart tomcat and webtomcat on all OneClick systems

- Log into OneClick, select an interface model, open the Component Detail panel, click on the Attributes tab and filter for the new DevMdlName attribute. It should now be populated with the model name of the parent device model.

Additional Information

To import the mte xml file on other SpectroSERVER systems:

- Run a backup of the SpectroSERVER database in case there are issues with the import

- Copy the mte xml file to the $SPECROOT/SS directory

- Log into the SpectroSERVER system

- Shutdown the SpectroSERVER as normal

- If on Windows, start a bash shell by running "bash -login"

- cd to the $SPECROOT/SS directory and enter the following command where <MTE> is the file name of the mte xml file:

../SS-Tools/dbtool/import <MTE>

- Start the SpectroSERVER as normal

- Restart tomcat and webtomcat on all OneClick systems