Web NMS Backup Policy - Example



 

Feature Overview

The word 'policy', in general, refers to a plan of action. Here, in Web NMS context, it refers to executing a task or set of tasks at a specified time based on a set of specified conditions. Policies are tasks that are executed by Web NMS at a system level, at a specified point of time. In Network Management, policies are used to control a variety of network activities like automated backups, routing & prioritization of network traffic, bandwidth allocation, cleaning up database tables, deleting failed nodes, etc.

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 :

For more details, refer to the following section of our documentation : Developer Guide --> Policy Framework

Example Overview

Example name : WebNMSBackupPolicy
Related files : WebNMSBackupPolicy.java
Location : <Web NMS Home>/default_impl/policies

The data stored in the database of Web NMS is of critical importance and human error, system crash and other disasters can result in the loss of valuable data which could prove to be costly. To overcome any such eventuality, Web NMS provides Backup Service. As the name itself indicates, backup refers to the process of taking a copy of the data and keeping it separately. In case, any data loss occurs, the backedup contents can be restored to the database and made use of. The backup of data can be taken at any time as well as any desired periodic interval. This example explains how backup of the Web NMS system can be taken using policies.

Web NMS BackupPolicy extends PolicyObject of com.adventnet.management.policydb package. The important methods of the Policy are

setProperties()

The"setProperties(properties p) " method  sets the Base and User Properties. The User Properties are first removed in this method. They are then set  to avoid duplication of Property names. The User Properties that are set are"BackUpClassNames" and"test.BackupImpl" "BackUpClassNames" is the Property name and "test.BackupImpl" is the name of the class to be invoked for backing up of Web NMS.

The user-written backup class should implement the com.adventnet.nms.startnms.BackUpInterface. The Base Properties in this Policy are helpURL, Status and Group Name. The super.setBaseProperties() method is invoked to set  the Base Properties.

getProperties()  method returns the Base and UserProperties.

The getPolicyObjectCustomizer() method returns the customizer class if any.

The getHelpURL() method returns the  Help URL  of theWebNMSBackupPolicy. The URL must be relative to the Help Directory

The executeAction() method is the main method from where the execution of the Policy begins.

Code Snippets
 
public void executeAction(PolicyEvent policyEvt)
    {
        String backUpClassNames = getUserProperty("BackUpClassNames");
        if( backUpClassNames == null || backUpClassNames.length() == 0)
        {
            System.out.println(" No Class name is specified to run BackUp");
            return;
        }
 try
        {
            com.adventnet.nms.startnms.StartWebNMSBackUp backup = new
com.adventnet.nms.startnms.StartWebNMSBackUp(backUpClassNames);
        }
 
This is the main method where the execution of the policy starts. If a class has been already written by you for backup then Web NMS takes care to take a back up and store it in that class,or else a error message is displayed to the user

Working with the Example

Implementation has been provided for WebNMSBackupPolicy, by default. So, there is no need to make any classpath settings. However, if you want to customize the WebNMSBackupPolicy.java file, you will have to integrate it separately as shown below :

Classpath Settings

Set 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 WebNMSBackupPolicy.java.

If you want to write your own Policy you should make an entry in relationalclasses.conf file. A sample entry from that file is shown below :

com.adventnet.nms.policies.UserDefinedPolicy policydb RelationalPolicyObject PolicyObject

To work on the Policy from the client end make an entry in Policy.conf file

Policy.conf file sample

  <POLICY

       classname="com.adventnet.nms.policies.User Defined Policy"

       display_name="User Defined Policy" />

(The "classname"should be the fully qualified classname of your Policy and the "display name" should be name of the policy)

Invoking the Example

Broader Scope

This Policy is only for taking a Backup of Web NMS tables. You can write a similar Policy to create a backup for the other tables in the database.

Sample Output

On successful execution of this policy, a file with name in the structure BackUp_<Month Date>_<Year>_<Min>_<Sec>.data will be created under <Web NMS Home>/backup directory. That file would contain the backedup contents.


Copyright © 1996-2002, AdventNet Inc. All Rights Reserved.