This policy framework enables scalable administration of the Web NMS server and the network elements managed by it. The primary goal of the policy engine is to enable administration of complex functions easily. In Web NMS, policies can be used to customize the behaviour of the NMS and to provide a framework for adding policies for different network elements.
Web NMS policies can be broadly classified into two categories :
You may require a notification whenever a policy is added, updated, deleted, executed or stopped from execution. This is possible by registering an observer with the policy engine.
Procedure to register as an observer
Two possibilities arise while registering as an observer :
Server and Client on
When the server and the client
run on the same JVM, you use the static method getPolicyAPI() present under
NmsClientUtil to get a NmsPolicyAPI handle.
| com.adventnet.nms.db.NmsPolicyAPIapi=com.adventnet.nms.util.NmsClientUtil.getPolicyAPI(); |
Server and Client runing in different JVMs
When the server and the client
run on different JVMs, NmsPolicyAPI handle is obtained using RMI
lookup
| com.adventnet.nms.db.NmsPolicyAPIapi= (NmsPolicyAPI) Naming.lookup("//"+hostname+"//NmsPolicyAPI"); |
Once NmsPolicyAPI handle
is got, you register an observer as follows.
| api.register(Observer); |
| Note : You should take care of the number of TopoObservers as well as the amount of work done by the observers, which might cause performance issues. |
For every change in Policy, each observer gets notified with a Properties Object comprising
intaction-integer.parseInt((String)prop.get("action"));
The following table lists
the type of actions.
| Action Type | Description |
| NmsPolicyAPI_POLICY_ADDED | This is for policy addition |
| NmsPolicyAPI.POLICY_UPDATED | This is for policy update |
| NmsPolicyAPI.POLICY_DELETED | This will be the action type when a policy gets deleted from the PolicyEngine |
| NmsPolicyAPI.POLICY_STOPPED | This will be the action type when a policy gets stopped |
| NmsPolicyAPI.POLICY_EXECUTED | This is for policy execution. |
Policy Name
String Name= (String)prop.get("name");
Group Name
String GroupName = (String)prop.get("groupName");
Current Status
intcurrentStatus = Integer.parseInt((String)prop.get("currentStatus"));
The following table lists
various status possibilities :
| Status | Description |
| NmsPolicyAPI.POLICY_DISABLED | This will be the status, if the policy is in the diaabled state. |
| NmsPolicyAPI.POLICY_STOPPED | If the policy is not under execution, this will be the status. |
| NmsPolicyAPI.POLICY_SCHEDULED | This will be the status, when the policy is under Scheduled state |
| NmsPolicyAPI.POLICY_EXECUTED | When policy is executed, update to observers will be with this policy status. |
If you require more properties about the policy, you can do so using NmsPolicyAPI.
Classpath SettingsSet the CLASSPATH as <WebNMS Home>\classes; <Web NMS Home>\ classes\AdventNetFramework.jar;
Compiling and Bundling with Web NMS
Compile it over the destination directory using the following syntax in the command prompt.
javac -d <Web NMS Home>/classes PolicyObserverExample.java.
javac -d <Web NMS Home>/classes ExecutePolicyObserverExample.java.
rmic -d <Web NMS Home>/classes test.PolicyObserverExample
Invoking the Example
If Web NMS is running in other hosts execute the following command :
java test.ExecutePolicyObserverExample -h <hostname> -p <RMI Port>
If Web NMS is running in localhost and the RMI registry is running in the default port 1099, no need for passing the arguments. The command for this case will be,
java test.ExecutePolicyObserverExample
Connecting the client
Upon doing any further operation like adding/deleting/executing/updating a policy, the following lines will be printed :