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 :
Failed Node Deletion Policy allows you to delete nodes of status major and critical in the database,that exists for more than 7 days without any change in status .
Description
The NodeDeletePolicy class extends PeriodicPolicyObject of com.adventnet.management.policy db package. Policies which need to be called at fixed time interval extend this class.
The methods in NodeDeletePolicy are
public void setProperties(Properties p)
This method sets theUser and Base properties for the policy object.The User Properties which are declared in nodedelete() are first removed and then set .This is done to avoid duplication of Property names..The User Properties that are set are "delete after days" i.e.,the property name and (ii)"7" the property value. All failed nodes existing in the database for more than 7 days gets deleted. You can set your own property value.
The super.setBaseProperties() " method is invoked to set the Base Properties. The Base Properties that are set are GroupName,Status,Help URL and Period of the policy object.
public Properties getProperties()The getProperties() method returns the Base and UserProperties.
public String getHelpURL()The getHelpURL() method returns the Help URL of the NodeDeletePolicy object. The URL must be relative to the Help Directory
public String getPolicyObjectCustomizer()
The getPolicyObjectCustomizer() method helps you to invoke your own customizer class if any.
public void executeAction(PolicyEvent policyEvt)
The executeAction() method is the main method from where the execution of the Policy begins.
Code Snippets
The execution of the Policy
starts from this method
| TopoAPI api = (TopoAPI)NmsUtil.getAPI("Topo");
if (api == null) { return; } Vector nodes = api.getNodes(); for (Enumeration en = nodes.elements();en.hasMoreElements();) { Node node = api.getNode((String) en.nextElement()); |
TopoAPI gives the list of
nodes in the database
| int status = node.getStatus();
............................................................ if ((status != sev1) && (status != sev2)) continue; |
The status of the node is
checked. If the status of the node Critical or Major - the loop continues
| if ( node.getStatusChangeTime()
>
((new Date()).getTime() - (24*60*60*1000* deleteAfter)) ) |
For nodes with status critical or major, the date and time is fetched .If such nodes exists for more than 7 days (on calculation) the nodes get deleted provided the node has only one interface. Nodes with multiple interfaces remains in the database and do not get deleted
Classpath Settings
Set the classpath as <Web NMS Home>\classes; <Web NMS Home>\ classes\AdventNetFramework.jar;
Compiling and Bundling with Web NMS
From Java UI