ems tutorial

154

Upload: chakravarthi-chittajallu

Post on 23-Dec-2015

31 views

Category:

Documents


4 download

DESCRIPTION

NMS4

TRANSCRIPT

Page 1: Ems Tutorial
Page 2: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 1

Table Of Contents

EMS TUTORIAL ........................................................................................................ 3

1.1 Foreword........................................................................................................................ 4 1.2 Introduction .................................................................................................................... 8 1.3 EMS Tutorial Tour........................................................................................................ 10 1.4 Application Overview ................................................................................................... 11

2. TRY IT YOURSELF ............................................................................................. 14

3. APPLICATION DESIGN ...................................................................................... 19

4. MODELING THE MANAGED RESOURCES....................................................... 22

4.1 Detailed Resource Modeling........................................................................................ 25

5. IMPLEMENTATION............................................................................................. 28

5.1 Creating EMS Project .................................................................................................. 30 5.2 Modeling the Switch and Its Components ................................................................... 31

5.2.1 Managed Resource Modeling...............................................................................................32 5.2.2 Customizing TrunkPort Object..............................................................................................35 5.2.3 Customizing Port Object for Status Polling...........................................................................36 5.2.4 Customizing Other Objects...................................................................................................38

5.3 Discovering Switch Devices......................................................................................... 39 5.3.1 Creating Discovery Filter ......................................................................................................41 5.3.2 Customizing Discovery Filter Code.......................................................................................42 5.3.3 Adding Device Components in Database.............................................................................45 5.3.4 Adding Trunk Objects in Database.......................................................................................50 5.3.5 Making Database Transaction Rollback Compliant..............................................................53

5.4 Creating Maps ............................................................................................................. 56 5.4.1 Adding Custom Map - Switch Map .......................................................................................57 5.4.2 Creating Map Filter ...............................................................................................................58 5.4.3 Customizing Map Filter Code ...............................................................................................59 5.4.4 Creating Chassis View..........................................................................................................60

5.5 Fault Management of Switch Devices ......................................................................... 62 5.5.1 Creating Trap Filter ...............................................................................................................63 5.5.2 Customizing Trap handling filter's code................................................................................65 5.5.3 Status Polling ........................................................................................................................68

Page 3: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 2

5.6 Configuring the Switch................................................................................................. 69 5.6.1 Switch Configuration.............................................................................................................70

5.7 Client-side Implementation .......................................................................................... 72 5.7.1 Building Chassis ...................................................................................................................73

5.7.1.1 Designing Main Screen............................................................................................................... 77 5.7.1.2 Designing Shelf Screen .............................................................................................................. 80 5.7.1.2 .1 Designing Access Card ......................................................................................................... 81 5.7.1.2 .2 Designing Trunk Card ........................................................................................................... 90 5.7.1.2.3 Building Property Screen........................................................................................................ 97

5.7.1.3 Chassis Configuration............................................................................................................... 103 5.7.1.4 Compiling and Packaging the Application................................................................................. 105

5.7.2 Building Configuration Screen ............................................................................................107 5.7.2.1 Designing Main Screen - Switch Configuration Screen............................................................. 110 5.7.2.2. Designing Panels for Main Screen........................................................................................... 116 5.7.2.2.1 Designing System Configuration Panel ................................................................................ 117 5.7.2.2.2 Designing Spanning Tree Details Panel............................................................................... 119 5.7.2.2.3 Designing Port Parameters Panel ........................................................................................ 121

5.7.2.3 Integrating Panels and Adding Actions for Button..................................................................... 125 5.7.2.4 Compiling and Packaging the Application................................................................................. 131

5.8 Packaging the Project................................................................................................ 133 5.9 Making the Switch configuration secured .................................................................. 134

5.9.1 Using Authorization Service to implement Security............................................................136 5.9.2 Customizing Configuration screen code to implement Security .........................................138

5.10 Re-branding............................................................................................................. 139

6. FAST TRACK IMPLEMENTATION ................................................................... 140

7. DEPLOYMENT AND TESTING ......................................................................... 141

7.1 Installation Notes ....................................................................................................... 141

7.2 Testing the Application .............................................................................................. 143

8. HOW DOES THE APPLICATION WORK? ....................................................... 145

9. KNOWN ISSUES ............................................................................................... 149

10. TROUBLE SHOOTING TIPS........................................................................... 150

11. GLOSSARY ..................................................................................................... 152

12. OTHER TUTORIALS ....................................................................................... 153

Page 4: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 3

EMS Tutorial

Element Management System AdventNet Web NMS Tutorial Version 1.0 A simple guide to developers on how to build an Element Management System on AdventNet Web NMS 5 using the AdventNet Web NMS Eclipse Plugin. AdventNet, Inc. 4900 Hopyard Rd., Suite 310 Pleasanton, CA 94588, USA Phone: +1-925-924-9500 Fax : +1-925-924-9600 http://www.adventnet.com [email protected]

Page 5: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 4

1.1 Foreword AdventNet Web NMS aims at providing real world network management solutions to telecommunications and enterprise markets. It meets the demand of the market for advanced network management features. It fulfills the need of the market for shortest possible deployment time. EMS tutorial will demonstrate how the above market expectations are met by AdventNet Web NMS.

• Real World Network Management Solutions

• Why AdventNet Web NMS

• Application Life Cycle

Real World Network Management Solutions Real world network management applications that can be made available on AdventNet Web NMS, categorized by specific domains are

Core Network Optical and IP/ATM core. Metro Network SONET/DWDM/Ethernet metro equipment. Edge and Access Network

Cable, DSL, Optical, and Wireless-based Broadband access technologies, with IP, ATM, and SONET protocols.

The list of Web NMS applications goes on. Why AdventNet Web NMS AdventNet Web NMS fulfills your specific network management needs. It comes with the most sought after features in the market. They are

• Massive scalability

• High availability

• Customization o Modeling managed systems o Extending management services o Supporting variety of management protocols o Various deployment options

It can be customized and extended to suit your needs. The extensibility makes the design of the application more organized. The customization addresses the specific needs of the application to manage your custom equipment. Eclipse, Integrated Development Environment is a widely used open source development environment. AdventNet now provides WebNMSEclipsePlugin which will seamlessly plug into the Eclipse IDE and provide you with a powerful suite of Wizards and Tools that help you to develop your management application very fast.

Page 6: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 5

This in turn brings host of benefits:

• The time taken to deploy the application is lesser compared to the conventional development and deployment techniques.

• It supports user from the level of novice to professional. The webnms plugin has wizards that auto generate the required stub code as well as place entries in respective configuration files making the development easier.

• It liberates the user to concentrate on the business logic or the domain specific requirements rather than learning the configurations for the WebNMS framework.

All these benefits put together will make AdventNet Web NMS a wise choice for your network management solution. Application Life Cycle AdventNet Web NMS offers a comprehensive development environment for building your management solution. This section explains how the complete product life cycle needs of your management solution are realizable using AdventNet Web NMS. They are captured in five easy steps that you can follow to build your management solution, as below: Step 1: Modeling the managed elements Step 2: Customizing managed object services Step 3: Packaging Step 4: Deploying Step 5: Rebranding the management solution Step 6: Testing The following diagram gives an overview of the experience of building management solutions with the AdventNet Web NMS.

Page 7: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 6

Step 1: Modeling the Managed Elements

Each managed system comprises many inter-related elements that need to be individually managed. You start with modeling your elements, so that you can capture the data, operations and state of the elements and the relationships between the elements. The Web NMS provides a comprehensive, simple, and easy to learn information model, using which the various elements and hence the managed system can be modeled. The basic element of the Web NMS information model is the ManagedObject. The Web NMS also has models for various common IP network components such as Network, Node, SNMP Node, TL1 Node, etc. These form the core objects of the Web NMS information model. You have to extend any of the core objects of Web NMS to model your managed element. The core objects can be extended, by adding attributes, operations and state to those objects (modeling the data, operations and state of your element in addition to capturing the relationship). This task can be easily accomplished by using the Model Managed Object Wizard of AdventNet WebNMS EclipsePlugin. It helps you walk through the steps in terms of the object that needs to be extended, the new attributes of your network element, adding properties for the MO and it also configures hibernate mapping properties for the MO. The Generate Java Source Wizard, will take the mapping file generated earlier as input and auto-generate the Bean/POJO code for the Modeled ManagedObject.

Step 2: Customizing Managed Object Services

AdventNet Web NMS offers a number of management services to the managed objects. The southbound services that populate the database with information from the elements such as data collection, status polling, etc., are classified as the mediation services. The services that enable the user to perform network planning, error management, and service deployment tasks are classified as the management services. Management services include event correlation, element configuration, service provisioning, access control, etc. Using the module management services available as part of the Web NMS framework, you could also build other management application modules.

Step 3: Packaging

You can package your application resources alone as a NAR (NMS Archive file) that can be installed over the AdventNet Web NMS. Step 4: Deploying

The nar for Project created using the Package Properties Wizard in the Eclipse Plugin has to be installed over Web NMS. This task can be performed using the Nar Installer present in the Deployment Wizard. The Installer wizard with an easy- to- use interface helps you walk through the process of installing the nar. You can invoke the Deployment Wizard by using the WebNMS > Tools > Deployment Wizard menu. Step 5: Rebranding the Management Solution

You can rebrand the application to display the name of your company, the name of your product, and your logos. Rebranding cannot be done within the EMS project created in Eclipse. It has to be done directly in the Web NMS Installation. To do Rebranding, invoke <Web NMS Home>\bin\developertools>startRebrandingTool.bat.

Page 8: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 7

Step 6: Testing

Before testing your management solution, make sure all the third-party packages are installed correctly and you have the required privileges to use them for your testing. Once you start your application, look at the Web NMS server log files to make sure all the services are started successfully and are running. Having deployed your application at a customer's site, you will be required to support the product and provide upgrades as part of support. The EMS Project created using the WebNMS Eclipse Plugin makes it easy to handle upgrades.

Page 9: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 8

1.2 Introduction The purpose of this tutorial is to guide you through designing an EMS and provide working, illustrative examples to help you understand the choices to be made during development. This describes how AdventNet Web NMS EclipsePlugin can be used to simplify the development of an EMS. The Tutorial Consider a real life scenario wherein you need to manage five Switches, which support SNMP. This tutorial will help you achieve the same by using AdventNet Web NMS by building an EMS (Element Management System) to manage the Switches. The tutorial will walk through a series of steps, which will help you understand how a unique EMS solution can be built using AdventNet Web NMS EclipsePlugin to suit your needs. Using AdventNet Web NMS EclipsePlugin the EMS application is just a few clicks away requiring you to incorporate only your network specific business logic. This makes the development faster. This tutorial helps you to build only a sample application. In which, it adopts a generic network device (i.e., a Switch, which supports SNMP) as an example. This limited scope example will serve only to illustrate what can be built on AdventNet Web NMS and it is only a subset of the custom capabilities of AdventNet Web NMS. However, for many EMS applications of specific needs, this basic example can be extended. This topic covers the following details of the tutorial:

• The Intended User

• Prerequisites

• Related Information

• Printed Version

• Tutorial Conventions

• At the End of the Tutorial

The Intended User This tutorial is intended for those, who are interested in developing an Element Management System using the AdventNet Web NMS. Prerequisites To develop this tutorial application, you will need a good knowledge of Network Management System and basic Java Programming. Knowledge of SQL, and relational database concepts will be an added advantage, but it is not essential. Related Information This tutorial provides concise information about AdventNet Web NMS EclipsePlugin and AdventNet Web NMS. For detailed information, refer to the Web sites listed below:

Page 10: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 9

1. AdventNet WebNMS Eclipse Plugin Guide - from the following URL: <Web NMS Home>\StudioTools\Studio\help\index.html

2. AdventNet Web NMS documentation - from the following URL:

http://www.adventnet.com/products/webnms/help.html Printed version To print this tutorial, follow these steps:

1. Ensure that Adobe Acrobat Reader is installed in your system. 2. Download the PDF version of this document from the following

URL:http://www.adventnet.com/products/webnms/tutorials/ems_tutorial.pdf

3. Click the printer icon in Adobe Acrobat Reader. Tutorial Conventions The following table lists the typographic conventions followed in this tutorial:

Font style Uses Arial Bold File name Arial Italic Directory Arial Bold Italic Methods / Interfaces / Classes Courier New Code snippet Courier New Bold Italic Highlighting important code snippets

At the end of the tutorial You will learn how to

• Build an EMS by customizing AdventNet Web NMS with the help of AdventNet Web NMS EclipsePlugin.

• Model Objects.

• Achieve Fault, Configuration, Performance and Security managements, and Discovery of network elements.

Page 11: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 10

1.3 EMS Tutorial Tour

Welcome to the EMS Tutorial Tour This tutorial is in three stages.

1. In Stage One, you are provided with the ready built application. For a quick look at what the application is all about, you can straight away deploy the application in AdventNet Web NMS and experience the outcome of the application before getting into building the application on your own. Refer the Try it yourself topic for Stage One of this tour.

2. In Stage Two, you are guided to build the application yourself. You are provided with elaborate details about building the Application using the AdventNet Web NMS EclipsePlugin. Refer the Detailed Implementation section in full for Stage Two of this tour.

3. In Stage Three, you are provided with the ready built project. Refer the Fast Track Implementation section in full for Stage Three of this tour. You can also experiment with the Project. Open the Project in AdventNet Web NMS Eclipse Plugin and make the changes, customize, add new features etc., as per your requirement, compile and package it. Deploy it in AdventNet Web NMS. You can see the effect of changes you done in the application.

Hope you will enjoy this tour and experience easy and quick Application development. The following flow-line diagram has image mapping to the corresponding topics.

Fig: Tutorial Tour

Page 12: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 11

1.4 Application Overview

In this section, an overview of the Tutorial Application is provided. Normally, while building an EMS you would require external Switches simulator or real Switches (which in any case is not advisable) to run and view the result of the example application. However in this tutorial to avoid external dependencies the tutorial has been modeled/designed to convert the first five network elements discovered which support SNMP, as SNMP Switches. The discovered elements will be modeled as customized Switch objects and predefined slots, cards, etc. are also added. The tutorial application provides information on how to develop an EMS to manage the five Switches. The tutorial application is built exploring the various modules of AdventNet Web NMS.

• Application Specification

• Description of System Used in the Application

• Implementation in a Nutshell

Application Specification

Name of the Application : Element Management System

Version of Web NMS used

: Web NMS Release 5

Compatibility with other Versions

: Not compatible with previous versions of Web NMS

Tools used and their Versions

: Eclipse 3.3 along with the AdventNet WebNMSEclipse Plugin

Platform-specific requirements

: No special requirements

Description of system used in the Application The example element used in the application is a generic switch. The switch is assumed to have two types of cards. One is Trunk card and there are four such cards. It has a single Trunk port. The Trunk port connects this switch to another switch. Other is Access card and there are four such cards. It has four Access ports. The Access port connects network devices to this switch, which offer connection services. The switch is assumed to have 16 slots. Alternate eight slots, from the first slot hold the cards. The remaining eight slots are vacant. The cards are arranged alternately, starting with Trunk card.

Page 13: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 12

Implementation in a nutshell The tutorial application covers various aspects of network management. Various modules of AdventNet Web NMS are used to achieve the network management objectives as listed below:

• Modeling the Switch and component Objects • Discovering Switch devices • Customizing Maps to display the Switches • Managing Alerts of Switch and its components • Configuring the Switch • Making the Switch configuration secured • Rebranding AdventNet Web NMS as your EMS

Modeling the Switch and component Objects

In AdventNet Web NMS, the managed device data is stored in the database for persistency. For storing the managed devices' data into a database, you need to model the managed device and it's components. The tutorial explains how the first five SNMP Nodes discovered are modeled as switches. In order to simulate a real time switch, the related components objects like shelves, slots, cards, and ports are modeled. The Object Modeling topic illustrates how the existing AdventNet Web NMS Managed Object model is extended to emulate a real SNMP Switch device and it's sub components.

Discovering Switch devices The Discovery process of AdventNet Web NMS, discovers all the elements available in the managed network. The tutorial explains how the Discovery process is customized to filter out the first five SNMP Nodes. The discovered nodes are modeled as explained above and stored in the topology database for effective management. The Discovery topic illustrates how to customize discovery and store the discovered information in the Topology database.

Customizing Maps to display the Switches AdventNet Web NMS provides default maps with default layouts and symbols to display of various networks and element groups. The tutorial explains how the custom maps are created from the elements of the topology database and how to customize the display and configuration of network maps. The discovered switches are drawn on the map using a custom map layout. The various components of the switch are shown in the Chassis view. Managing Alerts of Switch and its components AdventNet Web NMS implements Fault Management to identify failures in the managed network elements. The tutorial explains how to customize the Fault management features.

• The Trap handling topic explains how to process traps effectively. • The Status polling topic deals in a detailed manner on how to carryout

surveillance of Switch and components periodically.

Page 14: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 13

Configuring the Switch AdventNet Web NMS enables you to configure the network devices, where you can also schedule a task to get executed at any convenient time. If the configuration of the device does not succeed then the previous settings of the device can be restored. All the configuration information (tasks) are cached in a XML file which can be reused. The tutorial illustrates how Configuration Management can be implemented to configure the modeled Switch components.

Making the Switch configuration secured AdventNet Web NMS implements Security management using the Authorization Service. The tutorial implements Security management using the Authorization Service of Web NMS.

Rebranding AdventNet Web NMS as your EMS The tutorial re-brands AdventNet Web NMS into Acme EMS. The logo, images etc., can be replaced with your own. You have the i18N tool for internationalisation of various UI reference of AdventNet and Web NMS. With these the EMS developed can be easily re-branded.

Page 15: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 14

2. Try It Yourself In this section, the steps to deploy the ready built application are provided. This would help you run the application by yourself and view the results. The steps involved are

• Before You Begin

• Get the Application's NAR File

• Deploy the NAR in AdventNet Web NMS

• Start NMS

• View the Result

Before You Begin

• Download an evaluation copy of AdventNet Web NMS 5.

• Get it installed in your machine. For pertinent information, refer to the following document resources in the Installation Guide of AdventNet Web NMS 5

• System Requirements

• Startup Options Get the Ready Built application The working example comes bundled with AdventNet Web NMS, as a NAR file. The NAR is actually the ready-built application. Another alternative is to download the latest version of the tutorial from the AdventNet Web site and use the NAR in it.

a. Use the bundled application The working example comes bundled along with AdventNet Web NMS, as a NAR file.

OR

b. Download the latest version You can download the latest version from the Web site at the following URL:

http://www.adventnet.com/products/webnms/tutorials/ems_tutorial.zip

Unzip the zip file in the <Web NMS HOME> directory.

Select the NAR file mentioned below from the <Web NMS HOME>/tutorials/ems_tutorial directory.

EMS_Tutorial1.0.nar Deploy the Application in AdventNet Web NMS Carry out the instructions given in the Installing the application section to deploy the NAR file.

Page 16: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 15

Start NMS Prior to installing the NAR, if the server was running, Stop the server then Reinitialize the WebNMS server and Now start the server. To Reinitialize WebNMS Server, Run reinitialize_nms.bat under <WebNMS Home>/bin directory. (or) To reinitialize the Server from the launcher, it is essential to add EMS_Tutorial_Server.jar in the classpath. Follow the below steps to add EMS_Tutorial_Server.jar in the classpath.

• Start the Web NMS Launcher, by invoking WebNMSLauncher.bat/sh file in the <Web NMSHOME> directory. In the WebNMS Launcher, Select Options->Settings menu. Settings dialog screen is opened. In this dialog, select "Reinitialize Web NMS" in the left side tree. "ClassPath" details will be seen in the Right-side panel.

• Click on the Add button, a line will be added in the ClassPath text area, Now click on the button "...", this will allow you to browse and select the EMS_Tutorial_Server.jar from the <WebNMS Home>/NetMonitor/build directory. Now, This jar will get added in the classpath.

• Next click OK to Save the settings.

• Now, Invoke the "Reinitialize Web NMS" icon in the Web NMS Launcher to reinitialize the server.

Start the WebNMS Server by running startnms.sh/bat under <WebNMS Home>/bin directory. Alternatively you can also start the server from Web NMS Launcher. To start the Web NMS Server from the launcher, it is essential to add EMS_Tutorial_Server.jar in the classpath. Follow the below steps to add EMS_Tutorial_Server.jar in the classpath.

• Start the Web NMS Launcher, by invoking WebNMSLauncher.bat/sh file in the <Web NMSHOME> directory. In the WebNMS Launcher, Select Options->Settings menu. Settings dialog screen is opened. In this dialog, select "Start Web NMS Server" in the left side tree. "ClassPath" details will be seen in the Right-side panel.

• Click on the Add button, a line will be added in the ClassPath text area, Now click on the button "...", this will allow you to browse and select the EMS_Tutorial_Server.jar from the <WebNMS Home>/NetMonitor/build directory. Now, This jar will get added in the classpath.

• Next click OK to Save the settings.

• Now, Invoke the "Start Web NMS Server" icon in the Web NMS Launcher to Start the server.

View the Result Connect a Browser or Application client to the Web NMS Server in port 9090 as follows: Browser Client : Enter http://<host-name or IP>:9090 in the address bar Application Client : Double-click Application Client icon from the Web NMS Launcher. Alternatively you can also start the client by running startApplicationClient.bat under <WebNMS Home>/bin directory. Log in as user root and password public. In the left side frame, you will see the map tree. In that you can see the Applications > Network Maps > Switches node. Under this node you can see the five switches discovered.

Displaying Switches in a Map The Switches map will be the default map when you open the client. The following image is a snapshot taken from the application, which shows the switches map, where all the switches are laid out in the map with their interconnections. The interconnections are done between the Trunk Ports of each switch. The bandwidth of the trunk is also shown in the link. In the image you can see an individual map view for each discovered switch in the left-hand side tree under the switches map.

Page 17: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 16

On double-clicking the individual Switch nodes, you can see the Chassis view of the individual switches. The Switch elements have right-click menu with four menu items, viz., Alerts, Events, Configuration, Chassis View. Select Chassis View menu item will display the Chassis view of the Switch element.

Page 18: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 17

Chassis View of the Switch Device The Chassis view of Switch device shows the various components of an individual switch. The diagram is given below. If there is any problem in viewing the Chassis View, kindly refer the section TroubleShooting Tips The map shows a shelf with 16 slots numbered (0-15). Each slot has a card associated with it. The alternate cards are modeled as empty. The cards, which contain only one port are called Trunk Ports and four such Trunk Ports are added to the switch. The remaining cards contain four Access Ports. You can view the Alerts, Events, and Properties of the individual sub-components of the Switch (i.e., Card and Port).

Alerts from the Switch Device and Sub-components and Its Propagation Right-click a device and select Alerts from the pop-up menu to see its alerts. The following diagram depicts how events are propagated from a child node (Port) to the parent container (Card) and how they are correlated to generate more meaningful alarms.

Page 19: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 18

Configuring the Switch and Sub-components parameters In this application, the configuration management has been used to configure the modeled switches. The following GUI pops up on clicking configure switches option after selecting the switches you wish to configure from the switches map. If there is any problem in viewing the Configuration View, kindly refer the section TroubleShooting Tips

Secured Configuration of the Switch Right-click the device and select Configuration from the pop-up menu to see the Switch Configuration screen. The Configuration Management screen is used to demonstrate the security feature based on the operation assigned to the user. The image below has two of the tabs removed, which indicates that the user is a normal user and has no permission to change the Spanning tree and Port parameters of the switch. If you log in as an administrator, the STP and PortParameters tab will be available.

Page 20: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 19

3. Application Design Aim To come up with the design on customizing the AdventNet Web NMS platform features in order to provide various functions to the EMS, as specified in the requirements. EMS Management Requirements

• Modeling the Switch device as Managed Resource

• Discovering the Switch devices in the network

• Representing the Switch components in the Map

• Managing the Events and Alerts of Switch and its components

• Configuring the Switch Device

• Rebranding AdventNet Web NMS as your EMS Managed Resource Modeling

Objective Modeling a device enables you to represent the various attributes and the behavior of the corresponding physical device and its components in a convenient way so as to reflect their current state at any time. The EMS stores these persistent data in the database. Modeling the Switch and its components topic elaborately deals with various aspects to be considered for designing the Managed object. Tasks Define the resources to be managed by the EMS. The properties of the Device and its Components that will be used for modeling the resources are given below: Switch serialno, location Shelf serialno Slot slotno, state Card serialno, cardType Port portno, speed, snmpInterface, switchnode Access Port remoteID, remoteStatus, portType Trunk Port trunk, remotePortID, portType Trunk source, destination, srcPort, destPort, bandwidth The Role of Eclipse Plugin Using the Model Managed Object Wizard, all the above resources can be modeled easily.

Discovering Switch Devices

Objective To automatically discover and add the Switch devices and their components into the topology database of Web NMS. This will necessitate identifying the component hierarchy of the Switch devices.

Page 21: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 20

Tasks

• Create a Discovery Filter defining the containment hierarchy of the device and its components.

The Role of Eclipse Plugin The DiscoveryFilter Creation Wizard will help you to define the discovery filter. During discovery, Web NMS will discover the device and its components and store them in the database according to the containment hierarchy that has been defined in the discovery filter.

Representing the Switch Device and Its Components in the Map

Objective To graphically represent the Switch Devices and its components, illustrating the Containment hierarchy, in the map view of Web NMS Client. Tasks

• Create a criteria map to filter out all the Switches and display in a separate map

• Create a MapFilter class that will create links to visually represent the Trunk objects connecting the switches on the criteria map

The Role of Eclipse Plugin Using the MapFilter Creation Wizard, all the above tasks can be completed.

Managing the Events and Alerts of Switch and Its Components

Objective To monitor and manage the failures in the system effectively including, polling the Switch Device and its components periodically for their status and thereby take preventive action where necessary. Tasks

• Convert the failure notifications (Traps) into meaningful Events.

• Check the Device Status by polling the devices.

The Role of Eclipse Plugin Using the TrapFilter Creation Wizard, it is easy to create a Trap Filter that filters the traps and converts them into meaningful Events which can be managed. The Managed Object is modeled to check the status of the device.

Configuring the Switch Device

Objective The EMS Application should be capable of controlling and configuring the device. It should be able to switch the status of the card from active state to inactive state. Tasks

• Identify the Configuration commands to activate and deactivate the Switch Card.

Page 22: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 21

The Role of Eclipse Plugin The Configuration Wizard of Client Builder is used to configure tasks and set Device lists where the tasks have to be executed.

Rebranding AdventNet Web NMS as your EMS

Objective The EMS has to be renamed according to your requirements. All the relevant images and icons will have be changed to reflect its new name (For example, Acme EMS). Tasks

• Replace the existing AdventNet & Web NMS images and logo with Acme. Internationalize the text and buttons that appear in the Client of the EMS.

The Role of Eclipse Plugin Rebranding cannot be done within the EMS project created in Eclipse. It has to be done directly in the Web NMS Installation. To do Rebranding, invoke <Web NMS Home>\bin\developertools>startRebrandingTool.bat

Page 23: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 22

4. Modeling the Managed Resources This topic concentrates on various aspects involved in the design of Managed Object. The various aspects covered are listed below:

• What Are the Different Methods Available to Design Managed Resources? • How is the Web NMS Core Object Resource Modeled? • An Example Modeling of Object Resources for This Application • Class Diagram of Managed Resources of EMS Application • Naming Convention Used in Modeling the Managed Resources

What Are the Different Methods Available to Design Managed Resources? We have two choices for our design of managed elements.

1. Using the dynamic properties of Web NMS Managed Objects. 2. Extending the existing Managed Objects.

The former is a quick solution requiring minimal design effort but a cumbersome design. The later is a cleaner design. The second choice will serve our application needs better, because it provides a neat design. This approach also results in a better table structure for storing our objects in an RDBMS. Hence, the second approach is adopted in this tutorial. How is the Web NMS Core Object Resource Modeled? The core Object model of AdventNet Web NMS is simple and is easy to learn and extend for each application. The elements of the core model are designed for IP networks and are sufficient to represent common IP networks. However, for most specific applications, e.g., the management of a cable modem system, the model will be extended. The topology database has the following base elements:

ManagedObject : The base class of all objects in the Topology database.

TopoObject : The base class of all IP objects in the Topology database.

Network : This object represents an IP network.

Node : This object represents an IP network node.

SNMP Node : This object represents an IP network node with an SNMP Agent.

IP Address : This object represents an IP interface.

SNMP Interface : This object represents an IP interface with an SNMP Agent in its parent node.

Page 24: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 23

An Example Modeling of Object Resources for This Application Let us look at an example of modeling a complex network device, consisting of shelves, slots, cards, and ports. This generic example will illustrate the modeling procedure. The EMS tutorial application models a switch with associated shelves, slots, cards, and ports. The following relationships are assumed between the Managed Objects:

Switch : This represents a manageable switch that is initially discovered via SNMP, i.e., Web NMS finds it as an SNMP Node in the network or is manually added by an operator.

Shelf : The switch consists of one or more shelves. For this example, we will work with only one shelf, though the example can be extended to multiple shelves.

Slot : Each shelf consists of 16 slots, which are numbered 0-15. Card : Each slot consists of a card, which can be of different types. In this

example, we will work with only one card type. The card object has a field called Card type to specify the card type.

Port : Each card can have multiple ports. A port can be an access port or a trunk port.

AccessPort : The AccessPort class is a subclass of port and models a port on an access card.

TrunkPort : The TrunkPort class is a subclass of port and models a port on a trunk card.

Trunk : This models a link between switches, i.e., a trunk connecting two switches.

These components are modeled in the Web NMS topology database and these definitions are used to build an EMS functionality into our application. Class Diagram of Managed Resources of EMS Application The following class diagram gives an overview of Managed Object subclasses in this application.

Page 25: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 24

Naming Convention Used in Modeling the Managed Resources Although a naming convention is not essential, it provides some benefits. It supports the requirement of providing unique keys for all managed objects. It also allows us to easily identify some useful object properties, without having to explicitly store these properties in the object. We will use a naming convention for these objects that will make it easy to tell which object we are dealing with. This will also help with filtering, etc. if we wish to use them. The naming convention will be of the form: <switchname>_Shelf<N1>_Slot<N2>_Card_Port<N3> where <switchname> will be the name of the switch and <N1>, <N2> and <N3> are numbers to identify the ManagedObject within a container.

Note: In this example, although we have used a detailed object naming convention, we have not made use of object names for accessing such properties for better design considerations. We will create a set of objects based on this model and start with the discovery or manual addition of the switch. In the example code provided, we assume the first five SNMP Nodes to be switches instead of looking for specific switches.

Managed Object Parent-Child Containment Relationship In our EMS example model, the many-to-one containment relationship needs to be modeled across the device components. That is, cards are contained within a slot, slots within a shelf, and shelves within a switch. For mapping this relationship, we use the parent-children modeling feature available in the ManagedObject class. The containment relationship can be captured in out component classes just by setting the isContainer property of the parent component to true and setting/storing the parent object's name/key in the child component object using the setParentKey() method. This enables us to fetch all the children of a parent component by using the getChildrenKeys() method of the ManagedObject class, once the parent component and its children, with its parentKey property set appropriately, are added to the database. In the discovery filter while adding the following parent components, the isContainer property has been set to true:

• Switch

• Shelf

• Slot

• Card

Note: Another benefit of this ManagedObject property, namely ParentKey is, it allows for quick look up of the component object hierarchy as required when propagating alarms.

Page 26: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 25

4.1 Detailed Resource Modeling For each of the components of the network device, we have created a ManagedObject subclass. The following list captures the properties we have provided in each component we modeled, i.e., the ManagedObject subclasses.

Switch serialno, location Shelf serialno Slot slotno, state Card serialno, cardType Port portno, speed, snmpInterface, switchnode AccessPort remoteID, remoteStatus, portType TrunkPort trunk, remotePortID, portType Trunk source, destination, srcPort, destPort, bandwidth

Switch

The Switch object will extend an SNMP Node object instead of ManagedObject directly. This is because our example assumes the switch supports SNMP and will be discovered as an SNMP Node. In your case, if the switch does not support SNMP you may extend node or ManagedObject directly as appropriate. We will provide the following additional properties in the switch, in addition to what is available in an SNMP Node class:

Location : The physical location of the switch. Serial number

: The serial number of the switch.

Shelf The Shelf object will extend ManagedObject. We will provide the following additional properties in the shelf, in addition to what is available in a ManagedObject class:

Serial number

: The serial number of the shelf.

Slot We will create a ManagedObject subclass to model the Slot. We will provide the following additional properties in the slot object, in addition to what is available in a ManagedObject class:

Slot number : The slot number is the identification of position on the shelf. State : An indication of the state of the slot, whether the slot is empty or it

contains card type.

Card The Card object is modeled using a ManagedObject subclass. We will provide the following additional properties in the card object, in addition to what is available in a ManagedObject class:

Serial number

: The serial number of the card.

Card Type : Whether an access or trunk card.

Page 27: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 26

Port

The Port object is also directly sub classed from ManagedObject. To capture the containment of ports in switches, we will add a property to capture this relationship. We do not keep a reference to the switch, but rather store the key that identifies the switch that we can query from the database. We will provide the following additional properties in the port object, in addition to what is available in a ManagedObject class.

SNMP Interface

: The network interface object (IP Address) associated with this port, if any.

Port number : The port number is the identification of position on the card.

Speed : The data transaction speed of the Port

Switch Node : The Switch Node to which the Port belongs.

Note: The Switch Node property will help us in querying for all ports of a particular type belonging to a switch, as we do in the discovery filter for linking switches using trunks. We add this property to this port object so that we can make the query quickly and easily. But this is not a must. We can also get the TrunkPorts of a given switch by traversing/scanning recursively across the containment hierarchy using the getChildrenKeys() method of the ManagedObject. Or we can also use SQL queries, fired from the discovery filter, under database mode. Only the query will be somewhat complicated.

AccessPort The AccessPort object is sub classed from Port. We will provide the following additional properties in the AccessPort object, in addition to what is available in the port class:

Remote ID : An identifier for what is connected to this AccessPort. Could be an equipment serial number or location of a customer site where the access device is.

Remote Status

: The status of the device connecting to this AccessPort.

portType : Denotes the type of port used (Here, it is Access Port)

TrunkPort

The TrunkPort object is sub classed from port. We will provide the following additional properties in TrunkPort object, in addition to what is available in the port class:

Trunk : The trunk that terminates on this port. This is a reference to the trunk object.

Remote Port ID

: The ID of the remote port at the other end of an attached trunk.

portType : Denotes the type of port used (Here, it is Trunk Port)

Page 28: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 27

Trunk

The Trunk object is sub classed from ManagedObject. We will provide the following additional properties in the trunk object, in addition to what is available in the ManagedObject class:

Source : The switch that one end of this trunk terminates. No fundamental

distinction is made between source and destination here. Destination : The switch that one end of this trunk terminates. Source Port : The port on which this trunk terminates. Destination Port

: The port on which this trunk terminates, i.e., the port on the destination switch.

Bandwidth : The bandwidth capacity of this trunk.

Page 29: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 28

5. Implementation This tutorial application has been created using AdventNet Web NMS Eclipse Plugin. This comes bundled with AdventNet Web NMS. Using AdventNet Web NMS Eclipse Plugin The AdventNet Web NMS Eclipse Plugin can be deployed in your Eclipse IDE installation, then a new type of project "EMS Development project" will be added to the Eclipse IDE. For this tutorial you can now create a new EMS Development project in Eclipse and customise the WebNMS services in this project. When the project is complete, compile it and package it into a NAR file. For deploying the application in the AdventNet Web NMS, you will have to deploy the NAR into the AdventNet Web NMS using the Deployment Wizard tool. Various features available in the Eclipse Plugin allow you in creating the Application. However, you need to write certain amount of custom code in order to suit the need of the tutorial application. Implementation overview

Model the Managed Resource Model your Switch devices and their components into Managed Resources of AdventNet Web NMS Topology database. You will be filling up the Managed Resource's Name, Parent Resource, and its attributes in the Model Managed Object Wizard. In the end, you will get the Managed Resource's class and the corresponding Hibernate mapping file. Build Discovery-related Files Using Discovery Service Create a Discovery filter to discover the Switch objects you have modeled in the previous task. Invoke the DiscoveryFilter Creation Wizard and enter the Package Name and Filter ClassName. In the end, you will get the discovery filter. Add the Custom code specific to this application. Build Maps, Layouts, and Other Related Files Using Maps Service and Chassis Wizard Modify maps.conf file to add Custom Map. Create a Map filter to display the discovered Switches. Add custom code in this filter to represent the Trunk object as a link between the switches in the map. Configure mapIcon.data file to specify map iconName, its corresponding device type and the menuName. Create a Chassis view and other related screens for the Switch using Chassis Wizard. Build Fault Management-related Files Using Fault Service Create a Trap filter to process the traps. Add Custom code to handle Addition of Card and Deletion of Card. Model the managed object to check the device status (a method in the Managed Object class to check the status; here, it is the checkStatus() method) . Build Configuration-related Screens Using Configuration Wizard Create Configuration-related screens for configuring the Switch using the Configuration Wizard.

Page 30: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 29

Configure Authorization to Various Users Using Security Administration Tool The Security Administration screen contains two nodes under Security - Groups and Users. Create groups and users for the respective nodes as shown below: Groups -> Users Admin Users -> guest root Configure authorization for the Users to carryout various operations using the Security Administrator Tool. Rebrand the Application Using the Rebranding Tool and i18N Editor Tools Change the splash image, logo, and frame icons etc. in the Rebranding tool and Company Name, Product, and Version in the i18N Editor tool.

Page 31: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 30

5.1 Creating EMS Project The first step toward any implementation using the AdventNet Web NMS Eclipse Plugin is to create a EMS Development Project. The project stores all the information that are essential for developing the application. Starting Eclipse IDE Install the Eclipse version 3.3 in your machine. Get the latest Web NMS - Eclipse plugin (WebNMSEclipsePlugin.jar file) from <Web NMS Home>/StudioTools/Studio/jars directory and unzip this jar file in the <Eclipse Installed directory.> and then Start Eclipse IDE. Please note that you will need to run eclipse using JDK 1.5 or above. You can use the command mentioned below to start eclipse after deploying the plugin: eclipse -vm <jdk1.5 home>\bin\java For details on Creating Project, refer to the Web NMS EclipsePlugin Guide. Instructions Follow the steps given below to create the project.

Step 1: Invoke the Project Wizard

Select File > New > Create EMS Project menu to invoke the EMS Development Project Wizard.

Step 2: Add Project Details

Provide the following details about the EMS Project. Enter the Project Name and Web NMS Home to create a new EMS Development Project. Here the "Enable Web-Client Support" can be left unchecked as in this tutorial, it is not necessary to incorporate any web-client related changes.

Project Name - EMS_Project Web NMS Home - C:\AdventNet\WebNMS Enable Web-Client Support Leave it unchecked

Click Finish.

You will find the created project under the Package Explorer tree Result The Workspace for the Project is now created. Using the Model Managed Object Wizard, we will see how to model the Switch Device and its components in the next section. You can proceed with modeling the device. You can also invoke the wizard by clicking WebNMS > Modeling > Model Managed Object menu.

Page 32: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 31

5.2 Modeling the Switch and Its Components To manage a physical device and its components, you need to model them as database objects. The status and behavior of the physical device and subcomponents are modeled as attributes of the objects. By controlling/monitoring the attributes of the objects, the physical device can be managed by the Element Management Application. By storing the details of the Modeled Resource in the database, the data is made persistent and this helps the Element Management. You are converting the real life device, its components, status, and behavior into a network management application manageable form. This is achieved by modeling them as Managed Resources. In this example application, we have taken a generic Switch. The Switch holds four Access card. Each Access card has four ports and these ports are used to connect the devices, which require the service of the switch. The Switch holds another four Trunk cards. Each Trunk card has one port and it is used for connecting this Switch to another Switch. The following table lists the Real life device/components, which are required to be modeled as Managed Resources, the core Web NMS Resources which are extended in order to represent these Resources, and the Properties which are mapped to the status/behaviour of the physical device/subcomponent.

Managed Resource

Core Web NMS Resource Properties to Be Managed

Switch com.adventnet.nms.topodb.SnmpNode serialno, location Shelf com.adventnet.nms.topodb.ManagedObject serialno Slot com.adventnet.nms.topodb.ManagedObject slotno, state Card com.adventnet.nms.topodb.ManagedObject serialno, cardType Port com.adventnet.nms.topodb.ManagedObject portno, speed,

snmpInterface, switchnode

Access Port com.adventnet.nms.tutorials.ems.Port remoteID, remoteStatus, portType

Trunk Port com.adventnet.nms.tutorials.ems.Port trunk, remotePortID, portType

Trunk com.adventnet.nms.topodb.ManagedObject source, destination, srcPort, destPort, bandwidth

Refer to the Detailed resource modeling topic in Appendix to this document, for more explanation about the Modeled Resources and their Properties. This chapter explains the procedure to model the Managed Resources of EMS, using AdventNet Web NMS EclipsePlugIn. The topics in this chapter cover the following procedures:

• Managed Resource Modeling for EMS.

• Writing convenience methods by adding Custom code to Managed Resource's source.

Page 33: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 32

5.2.1 Managed Resource Modeling

Aim The Switch Device and its components have to be represented as Managed Resources. During the discovery process, Web NMS discovers these managed resources and stores them in the database to manage them. For details on Creating Managed Resource , refer to the Web NMS EclipsePlugin Guide. Instructions The Switch system consists of seven major components. The components with a short description is given below. Switch : This represents a manageable switch that is initially discovered via SNMP, i.e., Web

NMS finds it as an SNMP Node in the network or is manually added by an operator. Shelf : The switch consists of one or more shelves. For this example we will work with only

one shelf, though the example can be extended to multiple shelves. Slot : Each shelf consists of 16 slots, which are numbered 0-15. Card : Each slot consists of a card, which can be of different types. In this example, we will

work with only one card type. The card object has a field called Card type to specify the card type.

Port : Each card can have multiple ports. AccessPort : A port can be an access port or a trunk port. The AccessPort class is a subclass of

port and models a port on an access card. TrunkPort : This is a subclass of port and models a port on a trunk card. Trunk : This models a link between switches, i.e., a trunk connecting two switches. Steps to Model Switch Step 1: Invoke Model Managed Object Wizard

You can invoke the Wizard by clicking the WebNMS > Modeling > Model Managed Object menu. Specify the Package Name and Extended Object Name details in Step1 of the Model Managed Object Wizard.

Package Name com.adventnet.nms.tutorials.ems Modeled Object Name Switch

Click Next to proceed.

Step 2 : Component MO Table Details

In the Component MO Table Details screen, select Topo for the Select Module option, select com.adventnet.nms.topodb.SnmpNode from the drop down list for the Parent MO/Extended Object Name option. Fill the Discriminator Value as Switch. For this project, leave the following entries "Is dynamic update required", "Is select before update required", "Enable lazy fetching", "Is dynamic insert required", "Mark superclass as abstract" unchecked. Click Next to proceed.

Page 34: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 33

Step 3: Managed Resource Attributes Preview

In the MO Property Details screen, click Add button to add properties for the MO. The columns PropertyName, Type, Column, Length will become editable. Enter the Location (String) and Serial Number (String). Select the row of the property and click Delete button to delete the property. Alternatively, the properties of the managed object can also be selected from a MIB file. Click Attribute Selection button, to select attributes for MO from a MIB.

In the Attribute Selection screen, to load the required MIB, click Load MIB button. Open the MIB tree and select the required MIB tree node. Once the required node is selected, Add button in the center of the screen will be enabled and the description about the selected node will be displayed in the Description text box. Now Click Add Button and then click on Save Button.The selected MIB node will appear in the Selected Attributes text box. To remove the attributes from the Selected Attributes list, select the attribute(s) in Selected Attributes list and click Delete button.

Step 4: Adding custom code

Click Finish to complete MO Modeling. You will find the Hibernate mapping file for this modeled MO under <Your Project>/Referenced Libraries/resources/classes/hbnlib/<Package of MO>/ <Modeled MO>.hbm.xml in the Project Explorer window. After this, the Java source (i.e. the Pojo class) can be auto-generated using this mapping file by the Generate Java Source Wizard. You can add the custom code or modify the auto-generated pojo code using the editor directly as per your requirement. Follow the above steps to model the Shelf, Slot, Card, Port, AccessPort, TrunkPort, and Trunk as per the table given below. The attribute types are specified against the properties.

Managed Resource Parent Resource Properties to Be Managed

Shelf com.adventnet.nms.topodb.ManagedObject serialno (String) Slot com.adventnet.nms.topodb.ManagedObject slotno (int), state (String)

Card com.adventnet.nms.topodb.ManagedObject serialno (String), cardType (String)

Port com.adventnet.nms.topodb.ManagedObjectportno (int), speed (int), snmpInterface (String), switchnode (String)

AccessPort com.adventnet.nms.tutorials.ems.Port remoteID (String), remoteStatus (String), portType (String)

TrunkPort com.adventnet.nms.tutorials.ems.Port trunk (String), remotePortID (String), portType (String)

Trunk com.adventnet.nms.topodb.ManagedObject

source (String), destination (String), srcPort (String), destPort (String), bandwidth (String)

Java Source Generator

Generate Java Source is to create the source code for the Modeled MO from the Xml file.

• Select the project or source folder in the Package Explorer, you can notice Generate Java Source menu. (or) Select WebNMS > Modeling > Generate Java Source menu. Java Source Generator screen pops up.

Page 35: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 34

• In Java Source Generator screen , select the Xml file (multiple Xml files can also be selected) for Generating Java Source and click >> button.

• Select the source folder to generate the Java source. • Click OK.

Compile the Shelf, Slot, Card, Port, AccessPort, TrunkPort, and Trunk nodes. The details of the custom code meant for TrunkPort object added to the Managed Resource class are discussed in the next topic.

Page 36: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 35

5.2.2 Customizing TrunkPort Object

Custom Code Specific to the Tutorial Application Requirements - TrunkPort In addition to the properties provided, you have to provide two convenience methods, getRemotePort() and getRemoteStatus(), which are useful for quickly getting a handle on the remote port at the other end of an attached trunk. Before you proceed to add the user code, specify the following imports for this class:

import java.sql.*; import com.adventnet.nms.severity.SeverityInfo; import com.adventnet.nms.topodb.TopoAPI; import com.adventnet.nms.util.NmsUtil;

For providing the above two convenience methods, you have to write the custom code in the TrunkPort source file directly. Add the User code as given below at the end before the last "}":

public TrunkPort getRemotePort() { if (trunk == null) return null;

try {

Trunk trunkObj = (Trunk)((TopoAPI) NmsUtil.getAPI("TopoAPI")).getByName(trunk); if (trunkObj == null) return null; if (getName().equals(trunkObj.getSrcPort())) return (TrunkPort) ( (TopoAPI)(NmsUtil.getAPI("TopoAPI"))).getByName(trunkObj. getDestPort()); if (getName().equals(trunkObj.getDestPort())) return (TrunkPort) ((TopoAPI)(NmsUtil.getAPI("TopoAPI"))).getByName(trunkObj.getSrcPort()); }

catch (Exception ex) { System.err.println("Exception getting remote port: "+ex); ex.printStackTrace(); }

return null; }

public int getRemoteStatus() {

TrunkPort remotePort = getRemotePort(); if (remotePort == null)

return SeverityInfo.getInstance().getSpecialPurposeSeverity();

return remotePort.getStatus(); }

Page 37: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 36

5.2.3 Customizing Port Object for Status Polling

Custom Code Specific to the Tutorial Application Requirements - Port For providing the status polling function, you have to write the custom code in the Port source file directly. Imports to the class are:

import java.sql.*; import com.adventnet.nms.severity.SeverityInfo; import com.adventnet.nms.severity.SeverityIterator; import com.adventnet.nms.topodb.TopoAPI; import com.adventnet.nms.util.NmsUtil; import com.adventnet.snmp.beans.SnmpTarget;

The default constructor will be auto-generated with only the setClassname("Port"); call inside it. Add the lines as below to set the Type property and the PollInterval property inside the constructor:

public Port() { setType("Port"); setClassname("Port"); setPollInterval(300); }

The method below in the managed object class is called whenever status polling of this object is scheduled. Using this method, you can directly control what happens when status polling is to be done for this object. Also each managed object can be configured to support failure counts, i.e., allowing multiple failures before a managed object failure is reported to the system. This is done by using the setFailureThreshold() method in the ManagedObject class. Here you have two methods for the status polling of Port object. The actual status polling is done by the second method checkObjStatus() below, which is invoked by the first checkStatus() which overrides the super class method. Add the User code as given below at the end before the last "}":

/** This does the real check to the managed object **/ int checkObjStatus() { // As an example, we'll use the interface status, ifOperStatus, // of the node as the status of the port. We'll use the // port number to check status of the port. // Alarm propagation will be used to notify containers if ((switchnode == null) || (switchnode.equals("unknown"))) { TopoAPI tapi = (TopoAPI)NmsUtil.getAPI("TopoAPI"); String temp = getParentKey(); for (int i = 0; i < 3; i++) { try { if (temp != null) temp = tapi.getByName(temp).getParentKey(); } catch (Exception ex) { System.err.println("Exception fetching the parent "+ "switch of the port: " +getName()+ex); return SeverityInfo.getInstance().getSpecialPurposeSeverity();

Page 38: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 37

} } switchnode = temp; } SnmpTarget target = new SnmpTarget(); target.setTargetHost(switchnode); int index = portno+1; target.setObjectID("ifOperStatus."+index); String status = target.snmpGet(); if (status == null) { SeverityIterator s_iter = SeverityInfo.getInstance().getIterator(); s_iter.moveToHighest(SeverityInfo.LEFT); // Default. So optional. return s_iter.getPreviousCriticality(); // MAJOR severity } if (status.equals("1") || status.startsWith("up")) { return SeverityInfo.getInstance().getClear(); // CLEAR severity } SeverityIterator s_iter = SeverityInfo.getInstance().getIterator(); s_iter.moveToHighest(SeverityInfo.LEFT); // Default. So optional. return s_iter.getPreviousCriticality(); // MAJOR severity } // end checkObjStatus() //End User Code

The check is done to see that the interface is operational for the given index corresponding to the port number on the card. Based on the return value, a status update message is generated by the server. The fields of the generated event are based on the values in the managed object.

Note: When the devices are status polled at periodic interval, the output may be either

• Status Up Events (in which case, the default severity will be Clear) • Status Down Events (in which case, the default severity will be Major)

Page 39: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 38

5.2.4 Customizing Other Objects

Custom Code Specific to the Tutorial Application Requirements Provide the following user code after the Variable Declarations for the corresponding objects to setup a unique map icon for the objects. Switch

public Switch() { setType("Switch"); setClassname("Switch"); }

Shelf

public Shelf() { setType("Shelf"); setClassname("Shelf"); }

Slot

public Slot() { setType("Slot"); setClassname("Slot"); }

Card

public Card() { setType("Card"); setClassname("Card"); }

Trunk

public Trunk() { setType("Trunk"); setClassname("Trunk"); }

Result All the Managed Resources were created and customizations were also done. The Next task is to define a Discovery Filter to discover the Switch components.

Page 40: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 39

5.3 Discovering Switch Devices After modeling the Managed Resource, you need to make the EMS to discover the Switch devices and add them to the Topology database. To achieve this, you need to customize the existing AdventNet Web NMS Discovery process. This is done by writing a Discovery filter. This filter will convert the first five SNMP Devices discovered into Switches. This filter retrieves the details of the (imaginary) Switches and stores in the Topology database. Discovery Filter Code Description in a Nutshell The Discovery filter gets called when any new object is discovered by Web NMS and decides whether the discovered object can be passed through. As stated earlier, the filter identifies the first five SNMP devices as Switches and adds components such as shelves, slots, cards, etc. The filter passes through only the SNMP objects. It will drop all non-SNMP objects. If this filter returns, the corresponding object will be dropped and not added to the database. You require to restrict the number of switches to a maximum of five. For this purpose, the filter will check the database. To ensure this, the filter needs to detect warm start and add switches, only if the database has less than five switches. For this, write the custom code. Also, the filter needs to collect this information before it checks the managed object for interface so that it filters out the interface objects that do not correspond to the Switches that are added. Refer to the Discovery Filter Flowchart for a pictorial representation of Discovery filter class code implementation. This chapter will explain the procedure to customize the discovery for the modeled Managed Resources and to populate the database with the network elements' details, using the AdventNet Web NMS Eclipse Plugin. The following topics explain the procedure using AdventNet Web NMS Eclipse Plugin in detail:

• Creating the Discovery Filter to discover the Switch devices

• Adding Custom code in the source of Discovery Filter, to the achieve the following tasks: o Customizing Discovery Filter Code to Carryout Warm Start check o Adding Device components into the database o Adding Trunk objects into the database o Making database transaction rollback compliant

Page 41: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 40

Discovery Filter Flowchart

Page 42: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 41

5.3.1 Creating Discovery Filter

Aim To create a discovery filter to discover the Switch Device and its components and to set the properties for the discovered Managed Resources. The components of the Switch device are discovered by querying the Agent. Instructions to Create a Discovery Filter The Discovery Filter adds the discovered device as Managed Resources. This simple discovery filter will generate only stub code for discovering a single device and adding to database. It aslo generates some utility methods for querying the SNMP device for properties of the ManagedObject. Use the Create Discovery Filter wizard to discover a single device, which is modelled as a managed object. With the filter created using this wizard, you can discover a device, which is not having any sub components. For details on Creating Discovery Filter , refer to the Web NMS EclipsePlugin Guide. Follow the steps given below to discover the Switch Device and its components.

Step 1: Invoke the DiscoveryFilter Creation Wizard Select WebNMS > Filters > Discovery > Create Basic Discovery Filter menu. Step 2: Enter the Discovery Filter Details

Provide the following details about the discovery filter.

Package Name - com.adventnet.nms.tutorials.ems Filter ClassName - SwitchDiscoveryFilter

Click Finish.

You will find the <Discovery Filter class> under <Your Project>/source folder in the Project Explorer window. You can add the custom code or modify the existing code of the source using the editor directly as per your requirement. The corresponding entry for this Discovery Filter implementation class will be inserted in the discovery.filters file present in <Your Project>/resources/conf directory. You can rearrange the order of the discover filter entry in this file as per your requirement as each Managed Object discovered in WebNMS will be passed through all the discovery filters listed in the discovery.filters conf file. The details of the custom code added to the Discovery filter class is discussed in four parts.

Page 43: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 42

5.3.2 Customizing Discovery Filter Code

Custom code specific to the tutorial application requirements - Part I The following part illustrates how to layer discovery over the Web NMS IP discovery. Variable Declaration: Add the following variable declaration above the filterObject method:

/** Counter for the number of switches added. **/ int switch_count = 0; /** Used in warm start for fetching the switches already added. **/ Vector switch_name_vect = null; /** Warm start indicator. **/ boolean warmstart = false;

Now we come to implementing the filterObject method. Step1: Defining the criteria for processing the object Add the code snippet given below to check if Switch objects are already present in the topology database when the WebNMS server undergoes a warmstart. As this example converts only the first 5 SNMPNodes to Switch objects we will check the number of switch objects in the database and device whenever we need to further process this MO as a Switch. Add the below code in the filterObject method before creating the instance of the modeled object.

try { if ((switch_count == 0) && (topoApi.getNumNodes() > 0)) { warmstart = true; //Only first five SNMP Nodes are added as switches, so we check if Switch objects are already present in the database Properties prop = new Properties(); prop.put("Type", "Switch"); switch_name_vect = topoApi.getObjectNamesWithProps(prop); switch_count = switch_name_vect.size(); NmsLogMgr.TOPOUSER.log("Discovery - Warm Start :: " + "Number of switches already in database: " + switch_count, Log.DEBUG); if ((switch_name_vect == null) || (switch_name_vect.size() == 0)) { System.err.println("Error in Warm Start check. " + "Vector of switch names is null or zero."); } } } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }

Page 44: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 43

if ((warmstart)) { // We will have the first 5 SnmpNodes as carrier class // switches for this example. if(((!(switch_name_vect.contains(mo.getName())))&&(switch_count >=5))) { return mo; } }

Next we handle the scenario when there is a Cold Start of the WebNMS server. Here when the filterObject method is called for the new MO, we need to check if 5 Switches are already present in the database, in which case the mo should be returned without processing it as a Switch. Add the below code to achieve this. This part of the code should follow the above code.

if (switch_count >= 5) return mo; //we are not going to convert this as a switch.

Step 2: Add the code to create a new instance of the Switch object fill its properties by quering the device This part of the code should follow the above code.

//Start the code to add the switch object. switch_count++; Switch theSwitch = new Switch(); theSwitch.setName(mo.getName()); theSwitch.setTester("max"); theSwitch.setIsContainer(true); // Get the properties of object. Properties p = mo.getProperties(); // Set the properties of switch. First remove some of the props // e.g. the class name does not apply p.remove("classname"); p.remove("type"); theSwitch.setProperties(p); // Set the switch specific properties. For these properties we'll // actually have to go to the switch.However in this example // we will use some arbitrary values. theSwitch.setSerialno("1234"+ theSwitch.getName()); theSwitch.setIsContainer(true);

In the above code we are replacing the SNMPNode object passed to this discovery filter with our custom object i.e. the Switch. You will set some properties of the switch as per our requirement. One such property which warants a mention here is the Tester property. The Status of any Parent has to reflect the maximum severity including the status of its children. Hence, the "Tester" property of the

Page 45: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 44

switch is set to "max". Also to assertain the containment relationship for this Switch to its sub-components, you first have to set the isContainer property for the switch to true, so that you can add this object as a parent for other sub-components to be added later to the topology database. Copy over the SNMP Node properties to the switch. But before applying all properties, you would eliminate the ones that are unique to the Switch and could be overwritten, e.g., classname. The properties classname and type are set to Switch in the Switch Class. So, remove the properties that are not to be updated. Then, set these properties to the new Switch object created. Next, set some of the switch's specific properties. In reality, you will have to actually discover details for these properties from the switch. However, you will use some arbitrary values and set the serial number property in this example. Add the Switch Object to the database. Next, you will discover and add all the switch's components such as slots, ports, etc. Details on this are provided below. // Discover switch components' details and populate the database getSwitchComponentsInfo(theSwitch, topoApi); You will add trunks between switches, as described later in this section, for illustration purposes. addTrunks(theSwitch, topoApi); Finally, the class should return null as the switch and all its components have already been added to the topology database. Please note that the switch object was added instead of the SNMP Node object. return null; The next section covers how to add the details on each discovered device component.

Page 46: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 45

5.3.3 Adding Device Components in Database In this topic, the second part of the discovery filter class, adding Device components is dealt elaborately. Custom Code Specific to the Tutorial Application Requirements - Part II Since this application does not use any real switches, you will not actually fetch the device details by communicating with the switch. Simply add a number of components to the switch to illustrate how to add managed objects to the system once they are discovered. Add the following code after the end of the filterObject method.

void getSwitchComponentsInfo(Switch theSwitch, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException,UserTransactionException { // In this example we will not actually go to the switch. // We'll just add shelves, etc. arbitrarily. // Add one or more shelves. Here we'll add one. addShelf(theSwitch, api); }

Add a shelf as shown below and set some properties for the shelf. While adding switch components, follow the naming convention mentioned earlier. Also, set the parentKey of the component to its container, which is already added to the topology database. Here, the Switch object is parent to the Shelf object. You need to explicitly add the shelf to the database using the TopoAPI as shown below. Once the shelf is added to the database, add 16 slots. This part of the code should follow the above code.

void addShelf(Switch s, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException { Shelf shelf = new Shelf(); shelf.setName(s.getName() + "_Shelf1"); shelf.setParentKey(s.getName()); shelf.setSerialno("S1234" + s.getName()); shelf.setTester("max"); shelf.setIsContainer(true); beginTransaction(); try { api.addObject(shelf); commitTransaction(); } catch (Exception ex) {

System.err.println("Exception adding shelf: " + shelf.getName() + ex); rollbackTransaction(ex); return;

Page 47: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 46

} for (int i = 0; i < 16; i++) addSlot(i, shelf, s, api); }

Next, add slots as given below. Again, you need to explicitly add the slot to the database. For Slot, Shelf is the parent Object and set the state of the slot based on the card type you are adding into the slot. Odd-numbered slots are kept empty and even-numbered slots are plugged with Trunk and Access Cards. Add after the code given in the above table.

void addSlot(int slotno, Shelf s, Switch theSwitch, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException { Slot slot = new Slot(); slot.setName(s.getName() + "_Slot" + slotno); slot.setParentKey(s.getName()); slot.setSlotno(slotno); slot.setTester("max"); slot.setIsContainer(true); // We'll leave odd numbered slots empty and have even numbered // slots plugged in with Trunk Cards and Access Cards alternatively if ((slotno % 2) != 0) slot.setState("empty"); else if ((slotno % 4) != 0) slot.setState("Access"); else slot.setState("Trunk"); beginTransaction(); try { api.addObject(slot); commitTransaction(); } catch (Exception ex) { System.err.println("Exception adding slot: " + slot.getName() + ex); rollbackTransaction(ex); return; } // We'll check the slot number and add a card. // For this case we'll add a card in even numbered slots. if ((slotno % 2) == 0) addCard(slot, theSwitch, api); }

The card objects are added in a similar fashion. For cards, alternate between trunk cards and access cards. So you will end up with four trunk cards and four access cards.

Page 48: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 47

This should follow the above code.

static void addCard(Slot s, Switch theSwitch, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException { Card card = new Card(); card.setName(s.getName() + "_Card"); card.setParentKey(s.getName()); card.setSerialno("C1234"); card.setTester("max"); card.setIsContainer(true); if (s.getSlotNo() % 4 == 0) { // make every 4th slot a trunk card card.setCardType("Trunk"); } else { card.setCardType("Access"); } beginTransaction(); try { api.addObject(card); commitTransaction(); } catch (Exception ex) { System.err.println("Exception :adding card: " + card.getName() + ex); rollbackTransaction(ex); return; } if (s.getSlotno() % 4 == 0) { addPort(0, card, theSwitch, api); // only one port for Trunk cards } else { // Add four ports for Access cards as an example for (int i = 0; i < 4; i++){ addPort(i, card, theSwitch, api); } } }

Finally, add the port objects. Instantiate different subclasses of Port depending on the card that this port is attached to. To illustrate getting data from the device to drive the setup of the configuration, use the SNMPNode interfaces to determine the configuration of the ports. Check the operational status of the interfaces and based on the status for each port index, set whether the port is managed or not. This is done for each card.

Page 49: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 48

Add this code after you add Port.

static void addPort(int portno, Card s, Switch theSwitch, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException { Port port = null; if (s.getCardType().equals("Trunk")) port = new TrunkPort(); else port = new AccessPort(); port.setName(s.getName() + "_Port" + portno); port.setPortno(portno); port.setParentKey(s.getName()); port.setSwitchnode(theSwitch.getName()); System.out.println("Processing port........: " + port.getName()); // for access ports, tie it to the interface ifIndex if (port instanceof AccessPort) { port.setManaged(false); Vector interfaces = theSwitch.getIpaddrs(); System.out.println("The interfaces from getIpaddrs() are: " + interfaces.size()); for (Enumeration en = interfaces.elements(); en.hasMoreElements();) { try { IpAddress intf = api.getInterface((String) en.nextElement()); System.out.println("The interface object is : " + intf.getName()); if (intf instanceof SnmpInterface) { if (((SnmpInterface) intf).getIfIndex() == portno + 1) { port.setSnmpInterface(intf.getName()); port.setManaged(true); break; } } } catch (Exception ex) { System.err.println("Error getting interface : " + ex); } } if (!port.getManaged()) { // No IP address for this ifIndex // but we could still have this ifIndex operations if (port.checkObjStatus() == SeverityInfo.getInstance() .getClear()) port.setManaged(true); // ifIndex operational } } beginTransaction(); try { api.addObject(port);

Page 50: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 49

commitTransaction(); } catch (Exception ex) { System.err.println("Exception adding port: " + port.getName() + ex); rollbackTransaction(ex); } }

Thus, for an SNMP Node with three active interfaces and index numbers 1-3, each access card will have the first three AccessPorts as managed as well as active and the last AccessPort as unmanaged. The trunk card will have one managed and active TrunkPort. If the interface with an index of 1 is not active or goes down, none of the TrunkPorts will be active ports, but they are managed. The above discovery filter will add five switches and their related components into the topology database.

Page 51: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 50

5.3.4 Adding Trunk Objects in Database In the previous topic, we discussed how the discovery filter is used for discovering the switches and their components. In this topic, the third part of the discovery filter class, how Trunks (or Links) are added between the switches is dealt elaborately. Custom Code Specific to the Tutorial Application Requirements - Part III Trunks are physical connections between switches. Unlike a real-world EMS, which will use network information to add trunks, you will add trunks between switches based on some simple rules. Add one trunk to every TrunkPort and connect one link to every other switch with a free TrunkPort. In this EMS switch model, each switch has a shelf component with four TrunkPorts. Therefore, you can have a maximum of four trunks per switch. Use the getTrunkPort method, described below, for checking the availability of a free TrunkPort and fetching the same, from the topology database for the given switch. As part of adding the trunks, update the termination ports with information on the trunk terminating on the particular TrunkPorts. Add the following code after the addPort() method.

private static Vector srcDestVect = new Vector(); synchronized void addTrunks(Switch s, TopoAPI api) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException { String source = s.getName(); int numTrunks = 0; try { Vector nodes = api.getObjects("Switch", new Properties()); for (Enumeration en = nodes.elements(); en.hasMoreElements();) { String destination = (String)((Switch)en.nextElement()).getName(); if (destination.equals(source)) continue; if (srcDestVect.contains(source + "-" + destination) || srcDestVect.contains(destination + "-" + source)) { continue; } srcDestVect.add(source + "-" + destination); // We need to check if the remote switch // has room for more trunk connections. TrunkPort destport = getTrunkPort(destination, api); if (destport == null) { continue; } // Let's not add more than 4 trunks per switch. // We've only added 4 trunk ports above if (++numTrunks > 4) return; // Create the trunk object. Trunk trunk = new Trunk(); trunk.setName("Trunk_" + source + "-" + destination);

Page 52: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 51

trunk.setSource(source); trunk.setDestination(destination); trunk.setBandwidth("20MB"); // Get the next available source port TrunkPort srcport = getTrunkPort(source, api); if (srcport == null) { System.err.println("No trunk port found for source: "+ source); continue; } srcport.setTrunk(trunk.getName()); destport.setTrunk(trunk.getName()); trunk.setSrcPort(srcport.getName()); trunk.setDestPort(destport.getName()); srcport.setRemotePortID(destport.getName()); destport.setRemotePortID(srcport.getName()); beginTransaction(); api.addObject(trunk); api.updateObject(srcport, false, false); api.updateObject(destport, false, false); commitTransaction(); } } catch (Exception ex)

{ System.err.println("Error in adding trunk: " + ex); ex.printStackTrace(); rollbackTransaction(ex); } }

Use this method to fetch the next available free trunk port in a given switch. If the switch does not have a free TrunkPort, the method returns null. Use the switchnode property of Port object to query the database for ports belonging to a particular switch. You further narrow down our search by using the property trunk with value unknown, applicable only for free TrunkPorts. Once the Trunk object is added to the topology database, the source ports and destination ports are also updated with the trunk name for associativity. Add the following code after the addTrunks() method.

private com.adventnet.nms.tutorials.ems.TrunkPort getTrunkPort(String switchnamapi) throws com.adventnet.nms.store.NmsStorageException, com.adventnet.management.transaction.UserTransactionException,java.rmtion { if (switchname == null) { System.err.println("Fetching available trunk port, switch nnull"); return null; } Properties poppy = new Properties(); poppy.put("switchnode", switchname); poppy.put("trunk", "unknown");

Page 53: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 52

Vector tportvect = api.getObjectNamesWithProps(poppy); if ((tportvect == null) || (tportvect.size() == 0)) { System.err.println("Error. No trunk ports found for switch switchname); return null; } TrunkPort tport = null; String temp = null; for (int i = 0; i < tportvect.size(); i++) { temp = tportvect.elementAt(i).toString(); tport = (TrunkPort) api.getByName(temp); if (tport == null) { System.err.println("Error. TrunkPort: " + temp + " :not found in the continue; } return tport; } return null; // no free trunk ports }

The trunks will be represented as map links, which will be described in the Maps section.

Page 54: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 53

5.3.5 Making Database Transaction Rollback Compliant In this topic, the last part of the discovery filter class (i.e., use of transaction) is dealt elaborately. To use transactions, the following points are to be considered.

• All the object addition and updating has to be done within transaction blocks

• It is necessary to go through the document on transaction to know how to implement the Nested Transaction and what will be the commit and rollback behaviour within nested trasaction blocks.

Description of Custom Code Specific to the Tutorial Application Requirements

Note: The custom codes given in the following tables should not be added to the SwitchDiscoveryFilter as the codes are already added and are embedded in various methods of this filter class.

Allow the transaction to begin and throw NotSupportedException. Catch the exception and do nothing. The commit and rollback methods have no effect in case database does not support transactions. To use transactions, first get the TransactionAPI reference using RelationalAPI. Note that this is already included in the code and hence you need not add it again.

private void initTransactionAPI() { try { transactionAPI = NmsUtil.relapi.getTransactionAPI(); } catch (Exception ex) { NmsLogMgr.TOPOERR.fail("Exception in getting the handle of TransactionAPI ", ex);//No I18N } }

Next, define method to begin transactions as this code snippet may be used very frequently.

private static void beginTransaction() { try { transactionAPI.begin(); } catch (javax.transaction.NotSupportedException nse) { } catch (Exception ex) { NmsLogMgr.TOPOERR.fail("Exception in beginning the transaction ",ex);//No I18N } }

Similarly, define method to commit the transaction.

private static void commitTransaction() { try { transactionAPI.commit(); } catch (Exception ex) { NmsLogMgr.TOPOERR.fail("Exception in committing the

Page 55: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 54

transaction ", ex);//No I18N } }

Finally, define a method to rollback the transaction.

private static void rollbackTransaction(Exception exception) { try { transactionAPI.rollback(exception.getMessage()); } catch (Exception ex) { NmsLogMgr.TOPOERR.fail("Exception in rolling back the transaction ", ex);//No I18N } }

Call the beginTrans() method before a group of addObject(obj) / updateObject(obj) statements. Call the commitTrans() method after the above group of addObject(obj) / updateObject(obj) statements. In case the above transaction throws exception, catch the exception and call the rollbackTransaction(ex) method from inside. The following code snippet shows how to add the Switch object using transactions. Similarly all other objects are added/updated using transactions.

beginTransaction(); try { ............... if (!checkMO) //This implies an object with this name is not already present in DB hence we can add this object { topoApi.addObject(theSwitch); //NOTE: as we have added the object to database we must return null } else { topoApi.updateObject(theSwitch, false, true); //Here we are updating the object as it is already present in the database. } commitTransaction(); ............... } catch (Exception e) { NmsLogMgr.TOPOERR.fail( " Exception while adding/updating the object ", e);//No I18N rollbackTransaction(e); }

Page 56: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 55

Note: If the necessary import statements have not imported then Eclipse prompt for the error message. so it is necessary to import the statements such as import java.rmi.RemoteException, import java.util.Enumeration, import java.util.Properties, import java.util.Vector. Include the corresponding import statements for all the java files in this project.

Page 57: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 56

5.4 Creating Maps The Switch devices discovered need to be represented by images/icons. These representations need to be laid out and displayed in a map. The map also displays the links, representing the physical connections between the Switches as well as other devices. Apart from this, individual Switch device is represented as an actual model of the physical equipment. This is called Chassis view. In this view, the Switch device with Shelves, Slots, Cards, and Ports are displayed in a NMS Frame. This chapter explains the procedure to achieve the following tasks using AdventNet Web NMS Eclipse Plugin:

• Adding Custom map and configuring the custom map in maps.conf file

• Creating Map Filter for the Switch devices

• Customizing Map filter code to change the symbol of the Link and configuring the filter in mapIcon.data file

• Creating Chassis view using Chassis wizard

Page 58: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 57

5.4.1 Adding Custom Map - Switch Map If we want to display a map of all the switches and the trunks connecting the switches, creating a custom map showing all the switches and trunks in one map is straightforward solution. This topic deals with adding custom Maps in this application. Using Eclipse Plugin to Add Custom Maps For adding the Switch Map for this application you need to import the maps.conf configuration file into the EMS Development project created earlier for this tutorial. In the project, steps to edit the maps.conf file were followed and the nodes and their details were added. You can add or edit the node or modify the existing node directly as per your requirement using the UI. Modifying maps.conf File for Adding Switch Map Use the Import WebNMS Conf files wizard to import the maps.conf configuration file into the EMS Development project from the WebNMS installation that is used for developing this project. Refer the section Working with Files in Eclipse Guide for more details on how to import maps.conf to Eclipse. Open the conf file in the editor to define the new entry for this custom map. For displaying a map of all the switches and the trunks connecting the switches, simply add the following code to the maps.conf file.

<MAP_CONFIG> <map label="Switches" index="0" treeIconFileName="images/maps.png" helpDoc="help/userguide/use_map_client.html" autoPlacement="true" anchored="false" imageName="ems_tut_white.png" mapSymbolRenderer="com.adventnet.nms.mapui.MapSymbolRendererImpl_3 topology="$ring" currentTopology="ring" mapname="Switches.netmap"> <criteria type="Switch,Trunk" /> </map> </MAP_CONFIG>

The last line specifies the ManagedObject types that should be added in this map. Any property of the ManagedObjects can be chosen to specify which objects should be in the map. The first set of properties pertain to the new map you wish to create. i.e. The properties of the treenode that will invoke this map and properties for rendering the map are defined. With this configuration, all switches and trunks will be added to the new map.

Page 59: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 58

5.4.2 Creating Map Filter

Aim To create link symbols automatically for each trunk in the Switches map. Creating a Map Filter Follow the steps given below to define a Map filter. For details on Creating Map Filter, refer to the Web NMS EclipsePlugin Guide.

Step 1 : Invoking the MapFilter Creation Wizard Select WebNMS > Filters > Map > Create Map Filter menu. Step 2 : Map Filter Details

Provide the following details about the Map Filter:

Package Name - com.adventnet.nms.tutorials.ems Filter ClassName - TrunkMapFilter

Click Finish..

You will find the <Map Filter class> under <Your Project>/source folder in the Project Explorer window. You can add the custom code or modify the existing code of the source using the editor directly as per your requirement. The entry for this MapFilter implementation class will be appended to the map.filters configuration file present in <Your Project>/resources/conf directory. You can rearrange the entries as per your requirement as the filters will be invoked based on the order in which they are listed in this file. The details of the custom code added to the Map filter class are discussed in the next topic.

Page 60: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 59

5.4.3 Customizing Map Filter Code This topic deals with the custom code added to the Map filter class (TrunkMapFilter). This custom code is meant for changing the symbol automatically generated for each trunk into a link on the map. Custom Code Specific to the Tutorial Application Requirements The following custom code has been added to map filter to change the symbol automatically generated for each trunk to a link on the map. Add the implementation code for the filterMapSymbols method of the MapFilter as shown below:

if((!(mo instanceof Trunk ))) { return symbolVec; } // We expect only one symbol, but just in case we have // multiple maps with the same trunk in it Vector temp=new Vector(); for (int i=0;i<symbolVec.size();i++) { // for each trunk symbol MapSymbol mobj = (MapSymbol) symbolVec.elementAt(i); MapLink trunk = new MapLink(); Properties p = mobj.getProperties(); p.put("source",((Trunk)mo).getSource());//No I18N p.put("dest",((Trunk)mo).getDestination());//No I18N trunk.setProperties(p); trunk.setLabel(((Trunk)mo).getBandwidth()); temp.addElement(trunk); } symbolVec=temp;

Configuring Map Filters Eclipse Plugin will automatically put entry in map.filters located in <Web NMS Home>/conf directory when a NAR is installed. The entry will be as shown below.

<FILTER_LIST> <FILTER className="com.adventnet.nms.tutorials.ems.TrunkMapFilter"/> </FILTER_LIST>

Page 61: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 60

5.4.4 Creating Chassis View In this section, we will discuss how the discovered Switch along with its sub-components such as Shelf, Slot, etc. is represented. The Switch with its sub-components will be represented as a Chassis. The Chassis can be built as a UI in two ways:

1. Using Map APIs of AdventNet Web NMS 2. Using Chassis Wizard of AdventNet Client Builder

For details on How to build the Chassis using Chassis Wizard of AdventNet Client Builder, refer to Building the Chassis section of this tutorial documentation. In this tutorial, the Switch is being represented as a Chassis with the help of Chassis Wizard of AdventNet Client Builder. Creating Chassis View Using the AdventNet Client Builder

• The Chassis is built as a separate project using the Chassis Wizard of the AdventNet Client Builder.

• The project is compiled and packaged as a NAR.

• This NAR is then imported into the EMS Project.

• Now, the Chassis view of the Switch will become part of the EMS application.

Importing the Chassis NAR in the EMS Application

• Select the project in the Package Explorer.

• Select WebNMS > Import Client Nar menu. Client Application Import Wizard" screen pops up.

• In the Client Application Import Wizard screen, Select the ChassisScreen.nar from <Web NMS Home>/StudioTools/ClientBuilder directory using the Browse button.

• Click Next button to view the Users Information page.

• In the " Users Information" page , select the users for whom the Nar has to be installed.

• Click Next button to view the Menu Details page.

• In the "Menu Details" screen configure the Map Menu details. Enter Map Menu File , Menu Item name and the name of the Map Icon File. Enter Menu Name as SwitchMenu (this is the new SwitchMenu.xml menu file that we will create as part of this application. This menu should be placed in the <EMS Project>/resources/mapdata/menus directory) and Menu Item Name as ChassisView

• Click Finish button. The NAR is imported in the EMS Application. The Final Output The Chassis is represented as a dynamic view, i.e., the view will be automatically updated based on the status of the components. The Chassis is built based on the corresponding Switch ManagedObject added to the Web NMS database.

Page 62: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 61

This application can be invoked from the device node in the Switch -> Chassis View.

Page 63: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 62

5.5 Fault Management of Switch Devices To receive, process the failures in the managed network elements (i.e., Switches) and present it in a meaningful form, you have to implement Fault management service of AdventNet Web NMS. The Switch notifies any abnormality in the operations, parameters and failures to the EMS application in the form of traps Processing Alerts and Events of Switch device You have to process the events of the Switch received through the traps to convert it into a meaningful alert. Create a Trap filter to process the traps. In the application you will be creating a filter called TrapHandling. Add Custom code to handle Addition of Card and Deletion of Card. Model the managed object to check the device status (a method in the Managed Object class to check the status; here, it is the checkStatus() method). Status polling of Switch device You have to ensure that EMS gets the status of the Switch and its components periodically. This will be updated in the database and displayed in the Client. The tutorial explains how to customize the Fault management features.

• The Trap handling topic explains how to process traps effectively.

• The Status polling topic deals in a detailed manner on how to carryout surveillance of Switch and components periodically.

Page 64: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 63

5.5.1 Creating Trap Filter

Aim To provide a complete Switch management capability to the EMS with effective Trap handling and periodic status polling. Tasks

• Convert the failure notifications (Traps) into meaningful Event Objects using the Trap Filter Wizard

• Status Poll the Switch Device and its components using the Status Poller Wizard. Instructions Follow the steps given below to define a Trap Filter and after completion proceed to the Status Poller Wizard. For details on Creating Trap Filter, refer to the Web NMS EclipsePlugin Guide.

Step 1: Invoking the TrapFilter Creation Wizard

Select WebNMS > Filters > Fault > Create Trap Filter menu

Step 2 : Trap Filter Details Provide the following details about the Trap Filter

Package Name - com.adventnet.nms.tutorials.ems Filter ClassName - TrapHandling

Enter the Match Criteria for filtering the trap. It includes V1 Trap, V2 Trap. For V1 Trap , enter the Enterprise OID , Generic Trap Type and Specific Trap Type. For V2 Trap , enter the Trap OID.

Enterprise OID * Generic Trap Type 6 Specific Trap Type 100

Click Finish. You will find the <Trap Filter class> under <Your Project>/ source folder in the Project Explorer window. You can add the custom code or modify the existing code of the source using the editor directly as per your requirement. In order to capture handle the V1 Traps for the card addtion also you need to edit the trap.filters file to provide a similar entry as the one auto-generated using the above input for card deletion. Copy and paste the entry as below in the trap.filter file:

<FILTER name="Switch_CardAddition" classname="com.adventnet.nms.tutorials.ems.TrapHandling" enable="true" GT="6" ST="200" enterprise="*" />

Page 65: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 64

The appropriate entry for this trap filter will be appended in the trap.filters file in the <Your Project>/resources/conf folder. You can rearrange the entries in this file as per your requirement to change the order in which the trap.filters are invoked. The details of the custom code added to the Trap filter class is discussed in the next topic.

Page 66: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 65

5.5.2 Customizing Trap handling filter's code In this application, we have tried to simulate a real time situation in which cards are removed or added physically from a Switch. Whenever a card is removed or added, the agent in the device sends a trap to the manager and notifies the problem. To simulate this condition, we will send separate SNMP V1 traps for adding and removing the cards. To process the trap, we need to associate a trap filter. This topic deals with creating a trap filter called TrapHandling. Custom code specific to the tutorial application requirements TrapHandling is the trap filter, which does the addition and removal of cards based on the trap received. Incorporate the implementation code for the TrapFilter as shown below. The trap filter is designed to perform three separate tasks:

1. It will parse the incoming trap and convert it to an Event and add it to the WebNMS system assigning the appropriate severity.

2. Check if it is a trap denoting the Card deletion. Then it will delete the corresponding card in the topology database.

3. Check if it is a trap denoting the card addition. Then it will add the corresponding card into the topology database.

For parsing the snmp trap and converting it into an event the following custom code is added to the TrapHandling class inside the auto-generated stub for applyTrapFilter method:

//creating the new event object Event event = new Event( ); if(pdu.getVersion() == SnmpAPI.SNMP_VERSION_1) { NmsLogMgr.EVENTUSER.log("Trap version is V1 ",Log.DEBUG);//No I18N NmsLogMgr.EVENTUSER.log("Trap EnterpriseOID is :"+pdu.getEnterprise().toString() ,Log.DEBUG);//No I18N NmsLogMgr.EVENTUSER.log("Trap Generic type is :"+pdu.getTrapType(),Log.DEBUG);//No I18N NmsLogMgr.EVENTUSER.log("Trap Specific type is :"+pdu.getSpecificType(),Log.DEBUG);//No I18N } else { if(pdu.getVersion() == SnmpAPI.SNMP_VERSION_3 ) { NmsLogMgr.EVENTUSER.log("Trap version is V3 ",Log.DEBUG);//No I18N } else { NmsLogMgr.EVENTUSER.log("Trap version is V2C ",Log.DEBUG);//No I18N } NmsLogMgr.EVENTUSER.log("Trap TrapOID is : "+ pdu.getVariable(1),Log.DEBUG );//No I18N } Vector varbinds = pdu.getVariableBindings(); SnmpVarBind varbind = (SnmpVarBind)varbinds.elementAt(0); String stringVarbind = varbind.getObjectID().toString(); String slotName = varbind.getVariable().toString(); TopoAPI api = (TopoAPI)NmsUtil.getAPI("TopoAPI");//No I18N

Page 67: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 66

//Handling the trap of type Card Deleted. if((pdu.getTrapType() == 6 ) && ( pdu.getSpecificType() == 100)) { // INSERT THE CODE FOR DELETION OF CARD HERE. //Setting the properties of the Event object from the received Trap PDU. event.setText(pdu.getAgentAddress().getHostName()+"_Shelf1_"+slotName+"_Card isdeleted");//No I18N event.setEntity(pdu.getAgentAddress().getHostName()+"_Shelf1_"+slotName+"_Card" //No I18N event.setSource(pdu.getAgentAddress().getHostName()); event.setSeverity(1); NmsLogMgr.EVENTUSER.log("Returned Event properties in TrapHandling are : "+event.getProperties().toString(),Log.DEBUG);//No I18N return event; } //Handling the trap of type Card Added. if((pdu.getTrapType() == 6 ) && ( pdu.getSpecificType() == 200)) { //INSERT THE CODE FOR ADDITION OF CARD HERE //Setting the event properties from the received Trap PDU. event.setText(pdu.getAgentAddress().getHostName()+"_Shelf1_"+slotName+"_Card isadded");//No I18N event.setEntity(pdu.getAgentAddress().getHostName()+"_Shelf1_"+slotName+"_Card"); //No I18N event.setSource(pdu.getAgentAddress().getHostName()); NmsLogMgr.EVENTUSER.log("Returned Event properties in TrapHandling are : "+event.getProperties().toString(),Log.DEBUG);//No I18N return event; }

For Deletion of Card the following custom code is added to the TrapHandling class inside the if loop which checks for the Trap with Generic Type as 6 and Specific Type as 100

//Retrieving the card object from the database and deleting it. try { Card card=(Card)api.getByName(pdu.getAgentAddress().getHostName()+"_Shelf1_"+slotNam//No I18N Properties p=new Properties(); p.put("parentKey",card.getName());//No I18N Vector v=api.getObjectNamesWithProps(p); boolean b=api.deleteObject(card,false,false); if(b) { for (Enumeration e = v.elements() ; e.hasMoreElements() ;) { boolean bool=api.deleteObject(api.getByName((String)e.nextElement()),false,false); } } } catch(Exception e) { System.err.println(" Error while deleting card");//No I18N return pdu; //log the trap message }

Page 68: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 67

Since the card and its children need to be deleted, we need to get the corresponding Card object. Using the Topo API handle, the api.getByName() method returns the Managed Object corresponding to the card. The TopoAPI method deleteObjectAndSubElements() deletes the ManagedObject specified (Card) and its children (Ports). Once the object is deleted from the database, the map module is notified and it in turn deletes these Objects from the Map database. If a new card is inserted then in the received trap we will get the slot number where the card needs to be added and accordingly add the card and ports. The code snippet for Addition of Card is as given below. Add the code inside the if loop which checks for the Trap with Generic Type as 6 and Specific Type as 200

//Retrieving the Slot object from the database to which a card has been added. try{ String ifObjectName= pdu.getAgentAddress().getHostName(); Switch sw=(Switch)api.getByName(ifObjectName); Slot slot=(Slot)api.getByName(ifObjectName+"_Shelf1_"+slotName);//No I18N //Invoking the addCard method that will take care of adding the card object to the database. SwitchDiscoveryFilter.addCard(slot,sw,api); } catch(RemoteException e) { System.err.println("Unable to get the managed object"); //No I18N return pdu; //log the trap message } catch(Exception e) { System.err.println(" Error while adding card");//No I18N return pdu; //log the trap message }

The name of the agent (Device) from which the trap was received can be obtained from the pdu.getAgentAddress().getHostName() method. Using the Topo API handle we will get the Managed Object of the device as done before. As we need to add the cards and its children in the specified slot we need to get the Slot Object of the corresponding slot. This can be obtained by the following method.

Slot slot=(Slot)api.getByName(ifObjectName+"_Shelf1_"+slotName); After getting the slot object we will invoke the addCard() method of the SwitchDiscoveryFilter which will add the card and its corresponding ports. Once the managed objects are added the map module is notified which in turn adds the objects to its database and updates the UI.

Page 69: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 68

5.5.3 Status Polling You need to ensure the status of the Managed Objects are monitored and displayed in the Client UI. For each type of device, Web NMS performs status polling of these devices based on the configuration. For each managed object, it invokes the status polling specified by the configuration, which may be a standard operation like pinging the device already supported by Web NMS or a custom polling that is needed for a specific device or component. You can override the status polling code for your managed object. You will see how the Port object is used, for which you will poll the operational status of an interface corresponding to the port number on a card. The custom code for achieving the above task is added to the Port object as explained in the Implementation > Modeling the Switch and its components > Customizing Port object topic of this tutorial document.

Page 70: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 69

5.6 Configuring the Switch In this section, how to configure the Switch is discussed. In order to optimize the functioning of the Switch, you have to configure certain parameters of the Switch online. This is achieved with the help of Configuration Wizard screens. You have to build these screens separately using Configuration Wizard of ClientBuilder. You must import the compiled screens as a NAR file into the EMS project. At runtime, the screens to configure the Switches will be invoked through a menu item. Overview of Switch configuration process An overview of the Configuration process is presented in the diagram below:

When the Configure Switches option in the object menu (appears when switches are selected in the Switches map) is selected the screen for the parameters that need to be configured appears. The information regarding the parameters that can be configured has already been discussed above. After all the changes to the parameters are made, you can get back to the original settings of the device by selecting the refresh option. This option will also be useful to know whether a device has been configured successfully. On clicking the refresh option all the modifications that has been done previously for the device are deleted and a fresh query is made to the device to get the values. In this application you will explore some of the features of the Configuration Management. The functionality described here is only a small subset of what can be done with AdventNet Web NMS Configuration Management.

Page 71: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 70

5.6.1 Switch Configuration In this application, you will be building the Switch configuration screens with the help of Configuration Wizard of AdventNet ClientBuilder. The parameters that are chosen in this application are more generic and will be present in any Network Management device (e.g., switch, router) regardless of the type or make of the device. The various parameters that can be configured can be broadly classified into three categories.

• Basic Information about the Switch.

• Basic Spanning Tree Configuration Details.

• Spanning Tree Parameters of the Ports.

Basic Information about the switch

This view brings the various parameters like the Name of the switch, Location of the switch and the Name of the User/Contact person who is responsible for managing the switch.

Basic Spanning Tree Configuration Details

This view shows some of the spanning tree parameters that can be configured for a given switch. They are: • Bridge Priority : This value is used to elect the root switch.

• Bridge Max Age : The value that all bridges use for MaxAge when this bridge is acting as the root.

• Hello Time : This value determines how often the switch broadcasts its hello message to other switches.

• Forward Delay : This value determines the amount of time a port will remain in the listening and learning states before entering the forwarding state.

Spanning-Tree Parameters for the Ports

This view shows the following parameters: • Port Number : The Port Number of the switch

• State : Displays the spanning-tree state of the port. This can take any one of these values Blocking, Listening, Learning, Forwarding or Disabled.

• Forward Transitions

: Number of times Spanning-Tree Protocol changed forwarding states.

• Path Cost : The path cost of the port.

• Priority : Priority of each port relative to the other.

• Port Enabled : The enabled or disabled state of the port.

Note: If Spanning Tree Protocol is not enabled in the switch you cannot view the Spanning Tree Protocol values.

Page 72: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 71

Creating Configuration management application using the AdventNet Management Builder For the details of How to build the Configuration management screens using Configuration Wizard of AdventNet Management Builder, refer Building Configuration Screens section in the Appendix of this tutorial documentation.

• The Configuration screens of the Switch has been built using the Configuration Wizard of the AdventNet Management Builder.

• The Configuration management application will be built as a separate project.

• The project will be compiled and packaged as a NAR.

• This NAR has to be imported into the EMS project created using the WebNMS Eclipse Plugin.

• The NAR has to be imported using the Client Application Import Wizard invoked through the Import Client Nar menu of the Eclipse Plugin.

Importing the Configuration Screen NAR in the EMS Application

• Select the project in the Package Explorer.

• Select WebNMS > Import Client Nar menu. Client Application Import Wizard" screen pops up.

• In the Client Application Import Wizard screen, Select the SwitchConfiguration.nar from <Web NMS Home>/StudioTools/ClientBuilder/projects/EMS_Configuration directory using the Browse button

• Click Next button to view the Users Information page.

• In the " Users Information" page , select the users for whom the Nar has to be installed.

• Click Next button to view the Menu Details page.

• In the "Menu Details" screen configure the Map Menu details. Enter Map Menu File , Menu Item name and the name of the Map Icon File. Enter Menu Name as SwitchMenu (this is the new SwitchMenu.xml menu file that we will create as part of this application. This menu should be placed in the <EMS Project>/resources/mapdata/menus directory) and Menu Item Name as Configuration.

• Similarly configure the List Menu Informations.

• Click Finish button. Now the Configuration screens of the Switch will become part of the EMS application.

Caution: It is not advisable to change the values of Spanning Tree Configurations in a real switch which is a part of an active network, as it may inadvertently affect the operation of the switch. The AdventNet Agent Simulator can be used to simulate the switch by recording the values from a real switch.

Page 73: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 72

5.7 Client-side Implementation In the Client-side Implementation, we will be building two applications.

1. Switch Chassis 2. Configuration Screen

Switch Chassis In this section, you will learn to build chassis application to represent Switch device along with its sub-components such as Shelf, Slot, etc. This representation is known as Chassis View. Building chassis application using Chassis Wizard is explained in the Building Chassis section. The Output The Chassis View is dynamic, i.e., the application updates based on the status of the components in Web NMS Database. Once EMS is deployed in Web NMS, this application can be invoked from the device node by right-clicking the node and selecting View Chassis. Configuration Screen In this section, you will be building the configuration screens with the help of Configuration Wizard to configure Switch device parameters. Building Configuration Management Application using Configuration Wizard of AdventNet Management Builder is explained in the Building Configuration Application section. The Output The Configuration Management application configures, saves the Configuration data to Cache and loads the Configuration data from Cache for Scalar properties updates based on the status of the components in Web NMS Database. Once EMS is deployed in Web NMS, this application can be invoked from the device node by right-clicking the node and select Configure Device.

Page 74: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 73

5.7.1 Building Chassis This chapter explains the step by step procedure for building the chassis using AdventNet Management Builder's chassis wizard. Refer the Working with Client Builder topic to learn working with various options in Client Builder.

• Building Chassis Management Applications

• Working with Chassis Wizard o Working with Chassis Project

• Getting Chassis Data from Web NMS Database o Building Chassis with Slot & Shelf Modeled Parameters

Managed Object Description The application is built for a device, which has been populated as a Managed Object in Web NMS Database with the following Properties.

Managed Object Name : Switch1 No of Shelves : 1 where the shelf name is Switch_Shelf1 No of Slots in the Shelf

: 16 where the names of the Slots are Switch1_Slot<n> where n takes the value 0 to 15

No of Card Types in the Shelf1

: 2 where card types are Trunk and Access

Before creating the chassis application, you must know how the MOs are populated in the Web NMS Database. Hence make a SQL query from the Web NMS Database using the mysql commands given below mysql>select name,parentkey, type from ManagedObject where name like "%Switch1%"; where the Switch1 is the MO name of the chassis device you have populated. You shall get the query result similar to the table given below

name parentkey name Switch1 Switch1_Shelf1 Switch1_Shelf1_Slot0 Switch1_Shelf1_Slot0_Card Switch1_Shelf1_Slot0_Card_Port0 Switch1_Shelf1_Slot1 Switch1_Shelf1_Slot10 Switch1_Shelf1_Slot10_Card Switch1_Shelf1_Slot10_Card_Port0 Switch1_Shelf1_Slot10_Card_Port1 Switch1_Shelf1_Slot10_Card_Port2 Switch1_Shelf1_Slot10_Card_Port3 Switch1_Shelf1_Slot11 Switch1_Shelf1_Slot12 Switch1_Shelf1_Slot12_Card Switch1_Shelf1_Slot12_Card_Port0 Switch1_Shelf1_Slot13 Switch1_Shelf1_Slot14

NULL Switch1 Switch1_Shelf1 Switch1_Shelf1_Slot0 Switch1_Shelf1_Slot0_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot10 Switch1_Shelf1_Slot10_Card Switch1_Shelf1_Slot10_Card Switch1_Shelf1_Slot10_Card Switch1_Shelf1_Slot10_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot12 Switch1_Shelf1_Slot12_Card Switch1_Shelf1 Switch1_Shelf1

Switch Shelf Slot Card Port Slot Slot Card Port Port Port Port Slot Slot Card Port Slot Slot

Page 75: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 74

name parentkey name Switch1_Shelf1_Slot14_Card Switch1_Shelf1_Slot14_Card_Port0 Switch1_Shelf1_Slot14_Card_Port1 Switch1_Shelf1_Slot14_Card_Port2 Switch1_Shelf1_Slot14_Card_Port3 Switch1_Shelf1_Slot15 Switch1_Shelf1_Slot2 Switch1_Shelf1_Slot2_Card Switch1_Shelf1_Slot2_Card_Port0 Switch1_Shelf1_Slot2_Card_Port1 Switch1_Shelf1_Slot2_Card_Port2 Switch1_Shelf1_Slot2_Card_Port3 Switch1_Shelf1_Slot3 Switch1_Shelf1_Slot4 Switch1_Shelf1_Slot4_Card Switch1_Shelf1_Slot4_Card_Port0 Switch1_Shelf1_Slot5 Switch1_Shelf1_Slot6 Switch1_Shelf1_Slot6_Card Switch1_Shelf1_Slot6_Card_Port0 Switch1_Shelf1_Slot6_Card_Port1 Switch1_Shelf1_Slot6_Card_Port2 Switch1_Shelf1_Slot6_Card_Port3 Switch1_Shelf1_Slot7 Switch1_Shelf1_Slot8 Switch1_Shelf1_Slot8_Card Switch1_Shelf1_Slot8_Card_Port0 Switch1_Shelf1_Slot9

Switch1_Shelf1_Slot14 Switch1_Shelf1_Slot14_Card Switch1_Shelf1_Slot14_Card Switch1_Shelf1_Slot14_Card Switch1_Shelf1_Slot14_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot2 Switch1_Shelf1_Slot2_Card Switch1_Shelf1_Slot2_Card Switch1_Shelf1_Slot2_Card Switch1_Shelf1_Slot2_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot4 Switch1_Shelf1_Slot4_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot6 Switch1_Shelf1_Slot6_Card Switch1_Shelf1_Slot6_Card Switch1_Shelf1_Slot6_Card Switch1_Shelf1_Slot6_Card Switch1_Shelf1 Switch1_Shelf1 Switch1_Shelf1_Slot8 Switch1_Shelf1_Slot8_Card Switch1_Shelf1

Card Port Port Port Port Slot Slot Card Port Port Port Port Slot Slot Card Port Slot Slot Card Port Port Port Port Slot Slot Card Port Slot

On querying the Card MO table using the SQL query given below mysql>select name,cardType from Card where name like "Switch1%"; You shall get the query result similar to the table given below

name cardtype Switch1_Shelf1_Slot0_Card Switch1_Shelf1_Slot10_Card Switch1_Shelf1_Slot12_Card Switch1_Shelf1_Slot14_Card Switch1_Shelf1_Slot2_Card Switch1_Shelf1_Slot4_Card Switch1_Shelf1_Slot6_Card Switch1_Shelf1_Slot8_Card

Trunk Access Trunk Access Access Trunk Access Trunk

Using the cardType property, you can provide the type property in Chassis Wizard. Device Description To built the dynamic chassis application for the above device Switch1, you have to build the chassis project with the following parameters

Number of Shelves : One Number of Slots : 16 Number of Card Types : Three

Page 76: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 75

Since the position of Cards in the Slots is subject to change, the Project is built with Dynamic Chassis.

Note: The Managed Objects in Web NMS Database are populated by discovery of the devices based on the criterion in Discovery Filter. The Chassis Application created for these Managed Objects is Dynamic Chassis because the card screen panels are fitted in slot holder panels based on the Managed Objects in the Web NMS Database.

Device Information The following classes and XML are required to build the chassis project

• Card.class under com.adventnet.nms.tutorials.ems

• AccessPort.class under com.adventnet.nms.tutorials.ems

• TrunkPort.class under com.adventnet.nms.tutorials.ems

• ManagedObject.xml

Getting Started With Development The images from the <Web NMS Home>/StudioTools/ClientBuilder/projects/EMS_Chassis/images directory must be copied to <Web NMS Home>/StudioTools/ClientBuilder/images directory. The files from the <Web NMS Home>/StudioTools/ClientBuilder/projects/EMS_Chassis/mibs have to be copied to <Web NMS Home>/StudioTools/ClientBuilder/mibs directory. Follow the steps given below to create a chassis project in AdventNet Management Builder - Chassis Wizard Opening the Chassis Wizard To invoke Chassis Wizard from Web NMS Launcher, double-click Web NMS IDE icon in the Web NMS Launcher. From here, double-click the Chassis Wizard icon. Alternatively, you can use startChassisWizard.bat/.sh present in <Web NMS Home>/StudioTools/ClientBuilder/bin. Creating the Chassis Project

1. Select File -> New -> Project to invoke the New Project Details dialog to create a new chassis project.

2. Provide the Project Name field with the value EMS_Chassis if it does not exists. 3. Provide the Package Name field with the value com.adventnet.nms.tutorials.ems. 4. Ensure the Dynamic radio button is selected for the Chassis Type, since you are

constructing chassis project for Managed Objects in Web NMS Database. 5. Select the MO radio button for the Chassis Construct From field. 6. Click OK button to create the project in the projects folder under the <Client Builder Home>

directory. You can find a project named EMS_Chassis in the chassis project tree.

Configuring the Web NMS Host in Servers UI

1. Invoke the Server Tool with the Tools -> Servers or using the Web NMS Launch Pad. 2. Select the Management Server from the list and click Properties button on the right hand side

to invoke the Servers Properties List Dialog. 3. Select the first option WebNMS_Server_HOST and assign it with the host name in which the

Web NMS is running. By default it is None and so the entry is WebNMS_Server_HOST =

Page 77: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 76

None. For Example, WebNMS_Server_HOST = test2 means the Web NMS is running in host machine test2.

4. Click OK button to close the Servers Properties list dialog. 5. Restart the Management Server using the Stop and Start buttons.

Get back to Chassis Wizard and follow the steps given below. Steps Involved in Building the Chassis Project The following steps are involved in building the chassis project, packaging the chassis project as NAR and installing the NAR in Web NMS Client.

1. Designing Main Screen 2. Designing Shelf Screen

o Designing Access Card Screen o Designing Trunk Screen o Building Port Property Screen

3. Chassis Configuration 4. Compiling and Packaging the Application

Page 78: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 77

5.7.1.1 Designing Main Screen The main screen of the chassis application holds the shelf panels, the shelf panels contains the slot holder panels and each slot holder panel holds a card screen panel. The designing of main screen is done in the chassis main screen of the chassis project tree, which is invoked on the right side on clicking the "Main Screen" node in chassis project tree. In this screen you should provide the information whether the Shelf and Slot are modeled in the Web NMS Database. You should also provide the "Card Type Property Name" with which the chassis application recognize the card types for each card populated in Web NMS Database. Follow the steps given below to design the main screen. Initial Settings

• Click the Main Screen Node of the "EMS_Chassis" Project Tree. Change the build type of the Main Screen to "NMS Frame" using the menu command Built >Type > NMS Frame

Providing Shelf Parameters

1. In the right side you can find the Main Screen Parameter Panel, Provide the values "Number of Shelves"=1 and "Number of Distinct Shelf Types"=1 respectively in the Main Screen Parameter Panel.

2. Configure the Screen Size with Width=910 and Height=470 using the respective fields under "Screen Size". Follow the link Main Screen Parameter Panel for detailed explanation and usage.

Providing Managed Object Details 1. Invoke the "Managed Object Properties" dialog using the 'Settings' button next to the Protocol

Properties field which invokes the Managed Object Properties Wizard.(as given in the figure below)

Page 79: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 78

2. Check the "Is Slot Modeled" and "Is Shelf Modeled" check boxes in the first screen of MO Properties Wizard. Since these are the known parameters. Click "Next" button to proceed to the next screen as given below.

3. Click on the browse button and load the "com.adventnet.nms.tutorials.ems.Card.xml" using the "Load XML" button. Select the "cardType" from the XML and click on "OK" button.

4. Click "Next" button to proceed to the final screen of the MO Wizard. Here you can select extra properties if required.

5. Click "Finish" button to close the MO Properties Wizard.

Designing and Laying out the Components

1. Provide the background image by double-clicking the "Main Screen" draw area to invoke the Property Form. In the "backgroundImage" property, select the "Chassis_Shelf.png" in the images folder under the <Management Builder Home>.

2. Change the layout of the Main Screen to "Null Layout" by right clicking the draw area to invoke the screen popup menu, select Layouts-->Null Layout , so that you can size the "Shelf1" panel in which the slot holders are present. You can find that the "Set all Shelves to Same Size" field is enabled, so that you can provide the shelf size and padding.

3. Resize the "Shelf1" panel so that the background image appear using the "Shelf Size and Padding Parameters for Shelves" dialog. Invoke this dialog using the "Settings" next to the "Set all Shelves to Same Size" field. Provide the values "Width"=610 and "Height"=410 (in pixels).

4. Place the "Shelf1" panel to the Center of the draw area so that the background image appear at run time.

Page 80: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 79

Registering for Notifications The Chassis and it's components have to be updated on any status change of the underlying Managed Object, they represent. To achieve this Right-click on the screen and select the option "Configure Notifications > New Notification". Using the "Load XML" button load the "ManagedObjectUpdates.xml" and then select the "ManagedObjectName" property of "allUpdates". Click >> Button. Then select the "User Code" option of the "Result Settings" and insert the following user code there.

if(ManagedObjectName.startsWith(currentManagedObjectName)) { propertyHandler.refresh(resultRetriever); }

Then click OK to save the changes. Providing Source Code

1. Switch to Source view tab and scroll to the init method and add the following code under the //End_init tag.

setTitle("Chassis View of "+currentManagedObjectName); setResizable(false);

2. Switch back to the Screen view tab. 3. Save the Project using the menu command File > Save > Project.

The design of Main Screen for the "EMS_Chassis" project is complete.

Page 81: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 80

5.7.1.2 Designing Shelf Screen The Shelf Screen in Chassis Wizard is to design and arrange the slot holder panels as required, the slot holder panels holds the card screens at run time. In the Main Screen, you have created a shelf type (ShelfType_1) and a shelf ("Shelf1" panel in the Main Screen). So the Shelf1 is of the type ShelfType_1 . In this topic you shall design the shelf screen "ShelfType_1" that contains 16 slots arranged Vertically in "Grid Layout" and the three card type screens. Follow the steps given below to design the Shelf Screen.

1. Switch to Shelf Screen Parameter Panel by clicking the "ShelfType_1" node in the chassis tree.

2. Change the layout of the draw area to "Grid Layout" by right clicking the draw area to invoke the screen popup menu, select Layouts > Grid Layout. This is to arrange the slot holder panels in uniform width with appropriate spacing.

3. Provide No. of Slots=16 and No. of Distinct Cards=3 respectively in the Shelf Screen Parameter panel.

4. You can find the slots holder panels numbered from 1 to 16 are placed in the Shelf Screen, Ensure that they are in the ascending order by drag and dropping the cards in respective positions.

5. Thus you have designed the "ShelfType_1" Screen for the "EMS_Chassis" project. 6. Save the Project using the menu command File > Save > Project.

Designing Card Screens You can find the three card type screens under the Shelf_Type1 screen namely Card_0, Card_1 and Card_2. Rename these cards as Access_Card, Trunk_Card and Blank_Card respectively. To rename a card screen, double-click the screen node so that the node will be editable, Provide the new name and press "Enter" key. The description for each card type screens is given below Access_Card Screen: The "Access_Card" screen is to represent the Access Card present in the Switch device, This card contains port components and a LED bean component. Follow the link Designing Access Card for steps to design the "Access" Card for detailed explanation. Trunk_Card Screen: The "Trunk_Card" screen is to represent the Trunk Card present in the Switch device, This card contains port components and a LED bean component similar to the "Access_Card" screen. Follow the link Designing Trunk Card for steps to design the "Trunk" Card for detailed explanation. Blank_Card Screen: As the name indicates this is to represent the empty slots present in the Switch device. You have to provide the background image for this screen by double-clicking the "Main Screen" draw area to invoke the Property Form. In the "backgroundImage" property, select the "Chassis_blankcard.png" in the images folder under the <Client Builder Home>. The design of "ShelfType_1" screen of the "EMS_Chassis" project is complete.

Page 82: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 81

5.7.1.2 .1 Designing Access Card The "Access_Card" will be held by the Slot Holder panels present in the Shelf Screen at run time if the Web NMS Database has the card MO of the cardType property "Access". In this topic you will learn to design the "Access_Card" screen with port components and a LED bean components. Follow the steps given below to design the "Access_Card" screen. Providing Port and Card Parameters

1. Switch to Card Screen Parameter Panel of the "Access_Card" card type screen (as given in figure below) by clicking the "Access_Card" node in the chassis tree.

2. In the Card Screen Parameter of the "Access_Card" screen provide the "Number of Distinct Port Types"=1 and "Number. of Ports"=4. For detailed explanation for usage follow the topic Card Screen Parameter Panel.

3. Configure the screen size with the value "Width"=54 and "Height"=430 (in pixels). Setting Image for the Port

• Expand the "Access_Card" node to can find a port node named "Port_0".

• Right-click the Port_0 node to get the Port Popup menu, Select the 'Modify' menu item from the Popup to invoke Port Configuration dialog.

• In the "Component Properties", browse and select the "networkport1.png" for the property "Image File".

Providing Protocol Intelligence for Port Type

• Expand the "Access_Card" node to can find a port node named "Port_0". • Right-click the Port_0 node to get the Port Popup menu, Select the 'Modify' menu item from

the Popup to invoke Port Configuration dialog.

• Switch to "Protocol Properties" tab, change the "Polling Type" to Periodic.

• Load the com.adventnet.nms.tutorials.ems.AccessPort.xml device information file available in the mibs directory using the Load XML/MIB icon .

• Select "status" node of the com.adventnet.nms.tutorials.ems.AccessPort.xml under the "properties" node.

• Click "OK" button to close the Port Configuration dialog. 1. In the Card Screen's Draw Area, you can find the Port components "Port1".

,Port2,Port3 and Port4. 2. Right-click the "Port1" port component to get the Bean Popup menu, Select the

Protocol Property Form > Client_Port11 (the client property instance) from the Popup to invoke Client Property dialog. In the Client Property dialog all the field are inaccessible except the Index/Key field.

Page 83: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 82

3. Provide the value currentManagedObjectName + "_Port0" in the Index/Key field, Since the Port's MO name is suffixed with the Card name. Click 'OK' to close the Client Property dialog.

• Repeat the a, b, and c steps for the ports Port2, Port3 and Port4 also.

Port Instance Name Port Index in Client Property dialog Port2 currentManagedObjectName + "_Port1" Port3 currentManagedObjectName + "_Port2" Port4 currentManagedObjectName + "_Port3"

Dropping LED Bean and Configuring Protocol Intelligence

1. Drop a LED bean from AdventNetUI.jar in the Beans Palette adjacent to the ActiveIcon1 bean.

2. Right-click the LED bean to get the Bean Popup menu, Select the Protocol Property Form > New Client Property from the Popup to invoke Client Property dialog.

3. Load the com.adventnet.nms.tutotials.ems.Card.xml using the load device information button.

4. Expand the tree and move the "status" node of the com.acme.ems.Card.xml under the "properties" node to Selected nodes list. This is to display the status of the Card.

5. Select the "setResult" method with the Prototype "string" from the Result method list. 6. Click 'OK' to close the Client Property dialog.

Setting severity color to the LED Double click on the LED to bring up the property form. Change the Threshold Color and Threshold value as mentioned in the table below.

Property Value Threshold Color 1 Red Threshold Color 2 Orange Threshold Color 3 Yellow Threshold Color 4 Cyan Threshold Color 5 Green Threshold Color 6 Magenta Red Threshold Color 7 Grey Threshold Value 1 1 Threshold Value 2 2 Threshold Value 3 3 Threshold Value 4 4 Threshold Value 5 5 Threshold Value 6 6 Threshold Value 7 7

Then Click on "Close" to save the changes.

Page 84: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 83

Registering for Notifications The Card and it's ports have to be updated on any status change of the underlying Managed Object, they represent. To achieve this for a Card "RIGHT" click on the LED component and select the option "Configure Notifications > New Notification". Using the "Load XML" button load the "ManagedObjectUpdates.xml" and then select the "ManagedObjectName" property of "status". Then select the "User Code" option of the "Result Settings" and insert the following user code there.

if(ManagedObjectName.startsWith(currentManagedObjectName)) { if(ManagedObjectName.indexOf("Card") != -1) { Led1.setResult(status); } }

Then press "OK" to save the changes. For Notifying the Ports, Right-click on any of the Port component present in the Card draw area and select the option "Configure Notifications > New Notification". Using the "Load XML" button load the "ManagedObjectUpdates.xml" and then select the "ManagedObjectName" property of "status". Then select the "User Code" option of the "Result Settings" and insert the following user code there.

String status=event.getUserProperty("Status"); if(ManagedObjectName.startsWith(currentManagedObjectName)) { if(ManagedObjectName.indexOf("Port0") != -1) { Port1.setIconResult(status); } else if(ManagedObjectName.indexOf("Port1") != -1) { Port2.setIconResult(status); } else if(ManagedObjectName.indexOf("Port2") != -1) { Port3.setIconResult(status); } else if(ManagedObjectName.indexOf("Port3") != -1) { Port4.setIconResult(status); } }

Page 85: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 84

Arranging the Components 1. Arrange the components as given in the figure below

2. Double-click the draw area to invoke the Property From for the card screen. Configure the background image property with the "fourport.png" present in <Client_Builder_Home>images folder.

Creating and Configuring the AccessCard Menu

1. Right-click the Draw Area to invoke the Card Screen Popup Menu, select Menus >Create Menu to invoke the Screen Menu Configuration UI.

2. Select the "PopUpMenu" node from the tree (in left side pane) and click "Add" button (at the bottom of the UI) to invoke a dialog asking for Pop up menu name, provide the value "AccessCard" and click "OK" button. You can find a node with the name "AccessCard" is added under the "PopUpMenu" node.

3. Select the "AccessCard" node and click "Add" button to invoke the "Choose Menu" dialog.

4. Select "JMenuItem" radio button and provide the value "Alerts" in the text field labeled "Enter Menu Item Name". You can find the "Alerts" is added under the "AccessCard" node.

5. Select the "Alerts" node to invoke the respective panel in the right side of the split pane.

Page 86: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 85

6. Remove the existing code (if any) in the text area (under the "Hide Menu Item Details" button) and enter the following code as in the above figure

Properties prop = new Properties (); prop.put ("PANEL_NAME", "AlertApplet"); String portName=currentManagedObjectName; if(! name.equals("Card")) { portName=currentManagedObjectName+"_"+name; } prop.put ("entity", "<" + portName + ">"); prop.put ("tobeselected", "Alerts"); java.awt.Event event = new java.awt.Event (this, NmsPanel.CHANGE_PANEL_EVENT, prop); NmsPanelEvent nmsevt = new NmsPanelEvent (event); NmsClientUtil.getMainPanel().handleNmsPanelEvent (nmsevt);

7. Repeat the above steps (Steps: 3,4,5, and 6) to add the following JMenuItems with there

respective user codes as in the table below

JMenuItem Name Code to be provided in Text Area

Events

Properties prop = new Properties (); prop.put ("PANEL_NAME", "EventBrowser"); String portName=currentManagedObjectName; if(! name.equals("Card")) { portName=currentManagedObjectName+"_"+name;

Page 87: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 86

JMenuItem Name Code to be provided in Text Area

} prop.put ("entity", "<" + portName + ">"); prop.put ("tobeselected", "Events"); java.awt.Event event = new java.awt.Event (this, NmsPanel.CHANGE_PANEL_EVENT, prop); NmsPanelEvent nmsevt = new NmsPanelEvent (event); NmsClientUtil.getMainPanel().handleNmsPanelEvent (nmsevt);

Property

Property_Screen pp=new Property_Screen() pp.setVisible(true); String portName=currentManagedObjectName; String type="Card"; if(! name.equals("Card")) { portName=currentManagedObjectName+"_"+name; type="Access" ; } pp.setValue(portName,type);

8. Click "Close" button to close the "Screen Menu Configuration UI". 9. Right-click the "Access_Card" Screen's Draw Area to invoke the pop-up menu. Select

Menus > Pop-up Menus > AccessCard (radio button) as given in the figure below. This done to invoke the "AccessCard" pop-up designed in "Screen Menu Configuration UI" on right-clicking the "Access_Card" screen at run time

10. Right-click the port component with the instance name "Port1" to invoke the pop-up menu.

Select Popup Menus > AccessCard (radio button) as given in the figure below. This done to invoke the "AccessCard" pop-up designed in "Screen Menu Configuration UI" on right-clicking the port component in the card screen at run time.

Page 88: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 87

11. Follow the above step (Step-10) to configure the "AccessCard" pop-up menu for other port components (with the instance name) "Port2", "Port3", and "Port4".

Providing User Code in Source View Tab

Specifying NMS Packages Imported

Switch to Source view tab and add the following code (in black colored font) under the package import declarations as given below

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import com.adventnet.beans.chassis.*; import java.util.*; import com.adventnet.nms.startclient.*; import com.adventnet.nms.util.*;

Also implement the interface "MouseListener" ie add the MouseListener as follows

public class Access_Card extends JPanel implements com.adventnet.beans.chassis.ChassisCard,com.adventnet.management.ProtocolListener,com.adventnet.beans.management.MSBeansInterface,com.adventnet.management.ExceptionListener,com.adventnet.management.MSEventListener,MouseListener

Providing Source Code to invoke the Property Dialog 1. Scroll down to the init method and insert the following code below the //End_init tag.

Top.addMouseListener(this); Port4.addMouseListener(this); Port3.addMouseListener(this);

Page 89: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 88

Port2.addMouseListener(this); Port1.addMouseListener(this); Port1.setName("Port0"); Port2.setName("Port1"); Port3.setName("Port2"); Port4.setName("Port3"); Top.setName("Card");

2. Scroll down to end of the class and write the following code before the end of class (closing

brace "}").

public String name=null; public void mouseClicked(MouseEvent me) { if(((Component)me.getSource()).getName().equals("Card")) { name=((Component)me.getSource()).getName(); } else { Component comp=componentAt((JComponent)me.getSource(),me.getX(),me.getY()); name=comp.getName(); } } public void mouseReleased(MouseEvent me) { } public void mousePressed(MouseEvent me) { } public void mouseEntered(MouseEvent me) { } public void mouseExited(MouseEvent me) { } public Component componentAt(Container parent,int x,int y) { if (!parent.contains(x, y)) { return null; } int ncomponents = parent.getComponentCount(); Component component[] = parent.getComponents(); for (int i = 0 ; i < ncomponents ; i++) { Component comp = component[i]; if (comp != null) { Rectangle rect = comp.getBounds(); int compx = rect.x; int compy = rect.y; if (comp instanceof Container) { if(comp instanceof com.adventnet.beans.images.StatusIcon) {

Page 90: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 89

return comp; } else { comp = componentAt(((Container)comp),x - compx, y - compy); } } else { comp = parent.getComponentAt(x - compx, y - compy); } if (comp != null && comp.isVisible()) { return comp; } } } return parent; }

3. Switch back to Screen view tab 4. Save the Project using the menu command File > Save > Project.

The design of "Access_Card" screen is complete.

Page 91: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 90

5.7.1.2 .2 Designing Trunk Card The "Trunk_Card" will be held by the Slot Holder panels present in the Shelf Screen at run time if the Web NMS Database has the card MO of the cardType property "Trunk". In this topic you will learn to design the "Trunk_Card" screen with port components and a LED bean components. Follow the steps given below to design the "Trunk_Card" screen. The steps involved in designing the "Trunk_Card" is similar to the "Access_Card". Providing Port and Card Parameters

1. Switch to Card Screen Parameter Panel of the "Trunk_Card" card type screen (as given in figure below) by clicking the "Trunk_Card" node in the chassis tree.

2. In the Card Screen Parameter of the "Trunk_Card" screen provide the "Number of Distinct

Port Types"=1 and "Number. of Ports"=1. For detailed explanation for usage follow the topic Card Screen Parameter Panel.

3. Configure the screen size with the value "Width"=54 and "Height"=430.

Setting Image for the Port • Expand the "Trunk_Card" node to can find a port node named "Port_0".

• Right-click the Port_0 node to get the Port Popup menu, Select the 'Modify' menu item from the Popup to invoke Port Configuration dialog.

• In the "Component Properties", browse and select the "networkport1.png" for the property "Image File".

Providing Protocol Intelligence for Port Type • Expand the "Trunk_Card" node to can find a port node named "Port_0".

• Right-click the Port_0 node to get the Port Popup menu, Select the 'Modify' menu item from the Popup to invoke Port Configuration dialog.

• Switch to "Protocol Properties" tab, change the "Polling Type" to Periodic.

• Load the com.adventnet.nms.tutorials.ems.TrunkPort.xml device information file available in the mibs directory using the Load XML/MIB icon .

• Select "status" node of the com.adventnet.nms.tutorials.ems.TrunkPort.xml under the "properties" node.

• Click "OK" button to close the Port Configuration dialog. o In the Card Screen's Draw Area, you can find the Port component "Port1". o Right-click the "Port1" port component to get the Bean Popup menu, Select the

Protocol Property Form-->Client_Port (the client property instance) from the Popup to invoke Client Property dialog. In the Client Property dialog all the field are inaccessible except the Index/Key field.

o Provide the value currentManagedObjectName + "_Port0" in the Index/Key field, Since the Port's MO name is suffixed with the Card name.

o Click 'OK' to close the Client Property dialog.

Page 92: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 91

Dropping LED Bean and Configuring Protocol Intelligence 1. Drop a LED bean from AdventNetUI.jar in the Beans Palette adjacent to the ActiveIcon1

bean. 2. Right-click the LED bean to get the Bean Popup menu, Select the Protocol Property Form >

New Client Property from the Popup to invoke Client Property dialog. 3. Load the com.adventnet.nms.tutorials..ems.Card.xml using the load device information button 4. Expand the tree and move the "status" node of the

com.adventnet.nms.tutorials..ems.Card.xml under the "properties" node to Selected nodes list. This is to display the status of the Card.

5. Select the "setResult" method with the Prototype "string" from the Result method list. 6. Click OK to close the Client Property dialog.

Setting severity color to the LED Double click on the LED to bring up the property form. Change the Threshold Color and Threshold value as mentioned in the table below.

Property Value Threshold Color 1 Red Threshold Color 2 Orange Threshold Color 3 Yellow Threshold Color 4 Cyan Threshold Color 5 Green Threshold Color 6 Magenta Red Threshold Color 7 Grey Threshold Value 1 1 Threshold Value 2 2 Threshold Value 3 3 Threshold Value 4 4 Threshold Value 5 5 Threshold Value 6 6 Threshold Value 7 7

Then Click on "Close" to save the changes. Registering for Notifications The Card and it's ports have to be updated on any status change of the underlying Managed Object, they represent. To achieve this for a Card "RIGHT" click on the LED component and select the option "Configure Notifications --> New Notification". Using the "Load XML" button load the "ManagedObjectUpdates.xml" and then select the "ManagedObjectName" property of "status". Then select the "User Code" option of the "Result Settings" and insert the following user code there.

if(ManagedObjectName.startsWith(currentManagedObjectName)) { if(ManagedObjectName.indexOf("Card") != -1) { Led1.setResult(status); } }

Page 93: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 92

Then click OK to save the changes. For Notifying the Ports, Right-click on the Port component present in the Card draw area and select the option "Configure Notifications > New Notification". Using the "Load XML" button load the "ManagedObjectUpdates.xml" and then select the "ManagedObjectName" property of "status". Then select the "User Code" option of the "Result Settings" and insert the following user code there.

String status=event.getUserProperty("Status"); if(ManagedObjectName.startsWith(currentManagedObjectName)) { if(ManagedObjectName.indexOf("Port0") != -1) { Port1.setIconResult(status); } }

Arranging the Components

1. Arrange the components as given in the figure below

2. Double-click the draw area to invoke the Property From for the card screen. Configure the background image property with the "singleport.png" present in the images folder under the <Client Builder Home> folder.

Page 94: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 93

Creating and Configuring the Card Pop-up Menu (Similar to the steps involved in creating Pop-up menu in Access Card Screen)

• Right-click the Draw Area to invoke the Card Screen Popup Menu, select Menus >Create Menu to invoke the Screen Menu Configuration UI.

• Select the "PopUpMenu" node from the tree (in left side pane) and click "Add" button (at the bottom of the UI) to invoke a dialog asking for Pop up menu name, provide the value "TrunkCard" and click "OK" button. You can find a node with the name "TrunkCard" is added under the "PopUpMenu" node.

• Select the "TrunkCard" node and click "Add" button to invoke the "Choose Menu" dialog.

• Select "JMenuItem" radio button and provide the value "Alerts" in the text field labeled "Enter Menu Item Name". You can find the "Alerts" is added under the "TrunkCard" node.

• Select the "Alerts" node to invoke the respective panel in the right side of the split pane.

• Remove the existing code (if any) in the text area (under the "Hide Menu Item Details" button) and enter the following code

Properties prop = new Properties (); prop.put ("PANEL_NAME", "AlertApplet"); String portName=currentManagedObjectName; if(! name.equals("Card")) { System.out.println(" name is "+name); portName=currentManagedObjectName+"_"+name; } prop.put ("entity", "<" + portName + ">"); prop.put ("tobeselected", "Alerts"); java.awt.Event event = new java.awt.Event (this, NmsPanel.CHANGE_PANEL_EVENT, prop); NmsPanelEvent nmsevt = new NmsPanelEvent (event); NmsClientUtil.getMainPanel().handleNmsPanelEvent (nmsevt);

7. Repeat the above steps (Steps: 3,4,5, and 6) to add the following JMenuItems with there

respective user codes as in the table below

JMenuItem Name Code to be Provided in Text Area

Events

Properties prop = new Properties (); prop.put ("PANEL_NAME", "EventBrowser"); String portName=currentManagedObjectName; if(! name.equals("Card")) { portName=currentManagedObjectName+"_"+name; } prop.put ("entity", "<" + portName + ">"); prop.put ("tobeselected", "Events"); java.awt.Event event = new java.awt.Event (this, NmsPanel.CHANGE_PANEL_EVENT, prop); NmsPanelEvent nmsevt = new NmsPanelEvent (event); NmsClientUtil.getMainPanel().handleNmsPanelEvent (nmsevt);

Property

Property_Screen pp=new Property_Screen(); pp.setVisible(true); String portName=currentManagedObjectName; String type="Card";

Page 95: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 94

JMenuItem Name Code to be Provided in Text Area

if(! name.equals("Card")) { portName=currentManagedObjectName+"_"+name; type="Trunk" ; } pp.setValue(portName,type);

8. Click Close button to close the "Screen Menu Configuration UI". 9. Right click the "Trunk_Card" screen's Draw Area to invoke the pop-up menu. Select Menus >

Pop-up Menus > TrunkCard (radio button). This done to invoke the "TrunkCard" pop-up designed in "Screen Menu Configuration UI" on right-clicking the "Trunk_Card" screen at run time.

10. Right click the port component with the instance name "Port0" to invoke the pop-up menu. Select Popup Menus > AccessCard (radio button). This done to invoke the "TrunkCard" pop-up designed in "Screen Menu Configuration UI" on right-clicking the port component in the card screen at run time.

11. Follow the above step (Step-10) to configure the "TrunkCard" pop-up menu for other port components (with the instance name) "Port1", "Port2", and "Port3".

Providing User Code in Source View Tab

Specifying NMS Packages Imported

Switch to Source view tab and add the following code (in black colored font) under the package import declarations as given below

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import com.adventnet.beans.chassis.*; import java.util.*; import com.adventnet.nms.startclient.*; import com.adventnet.nms.util.*;

Also implement the interface "MouseListener" i.e. add the MouseListener as follows public class Trunk_Card extends JPanel implements com.adventnet.beans.chassis.ChassisCard,com.adventnet.management.ProtocolListener,com.adventnet.beans.management.MSBeansInterface,com.adventnet.management.ExceptionListener,com.adventnet.management.MSEventListener,MouseListener

Providing Source Code to invoke the Property Dialog

1. Scroll down to the init method and insert the following code below the //End_init tag.

Port1.addMouseListener(this); Port1.setName("Port0"); Top.addMouseListener(this); Top.setName("Card");

Page 96: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 95

2. Scroll down to end of the class and write the following code before the end of class (closing brace "}").

public String name=null; public void mouseClicked(MouseEvent me) { if(((Component)me.getSource()).getName().equals("Card")) { name=((Component)me.getSource()).getName(); } else { Component comp=componentAt((JComponent)me.getSource(),me.getX(),me.getY()); name=comp.getName(); } } public void mouseReleased(MouseEvent me) { } public void mousePressed(MouseEvent me) { } public void mouseEntered(MouseEvent me) { } public void mouseExited(MouseEvent me) { } public Component componentAt(Container parent,int x,int y) { if (!parent.contains(x, y)) { return null; } int ncomponents = parent.getComponentCount(); Component component[] = parent.getComponents(); for (int i = 0 ; i < ncomponents ; i++) { Component comp = component[i]; if (comp != null) { Rectangle rect = comp.getBounds(); int compx = rect.x; int compy = rect.y; if (comp instanceof Container) { if(comp instanceof com.adventnet.beans.images.StatusIcon) { return comp; } else { comp = componentAt(((Container)comp),x - compx, y - compy); } } else {

Page 97: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 96

comp = parent.getComponentAt(x - compx, y - compy); } if (comp != null && comp.isVisible()) { return comp; } } } return parent; }

3. Switch back to Screen view tab. 4. Save the Project using the menu command File > Save > Project.

The design of "Trunk_Card" screen is complete.

Page 98: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 97

5.7.1.2.3 Building Property Screen Property screen is to display the properties for the Cards or Port at run time. This screen is of the built type dialog that is invoked from card or port (present in the card). At run time, right-click the card or port to invoke the pop-up menu and select "Property" menu item. This topic explains the steps involved in building this dialog screen. The JTextField bean components dropped in this screen are not provided with client property since the values are set for these JTextFields at run time depending on the how this dialog is invoked viz. card's pop-up menu or port's pop-up menu (port components are present in the cards). Initial Settings

1. Create a new screen under "Screens" node using the menu command File > New > Screen and rename the screen name as "Property_Screen".

2. Change the layout of the screen by right-clicking the Draw Area and select Layouts > Border Layout.

3. Click and drop a two JPanels from SwingBeans.list tab of the Beans Pallete.

4. Change the instance name of these JPanels as Details_Panel and Button_Panel.

Designing Details_Panel Panel

1. Set the position of "Details_Panel" JPanel to "Center" and "Button_Panel" to south using the "Layout Properties" dialog (invoked by right-clicking the Draw Area and select Layouts Properties ).

2. Drop a JLabel from SwingBeans.list tab of the Beans Palette in the "Details_Panel" JPanel. Invoke the Property Form, provide the following properties as given in the table below

Property Value InstanceName NameL horizontalTextPosition RIGHT horizontalAlignment RIGHT text Name foreground bottle green

3. Drop 11 JLabels from SwingBeans.list tab of the Beans Palette. Select "RIGHT" option for "horizontalTextPosition" and "horizontalAlignment" properties. Change the instance name and text properties for these JLabels as listed in the Instance Name in the table given below. Set the properties for each component as given in the table below (Similar to the above step-6)

Instance Name Property Value Text Property Value

DisplayNameL Display Name TypeL Type

Page 99: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 98

Instance Name Property Value Text Property Value ManagedL Managed StatusL Status ParentKeyL Parent Key SwitchL Switch PortTypeL Port Type SpeedL Speed PortNoL Port Number TrunkL Trunk RemotePortL Remote Port

8. Drop a JTextField from SwingBeans.list tab of the Beans Palette in the "Details_Panel" JPanel. Invoke the Property Form, provide the "Instance Name" property with the value "NameTF" and choose "False" option for the "editable " property.

9. Drop 11 JTextFields from SwingBeans.list tab of the Beans Palette. Change the instance name as listed below.

• DisplayNameTF

• TypeTF

• ManagedTF

• StatusTF

• ParentKeyTF

• SwitchTF

• PortTypeTF

• SpeedTF

• PortNoTF

• TrunkTF

• RemotePortTF

10. Choose "False" option for the "editable " property for all the above JTextField components.

11. Change the layout of the "Details_Panel" panel by right-clicking the Draw Area and select Layouts > GridBag Layout.

Page 100: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 99

12. Position the components in the Details_Panel JPanel GridBag Layout Customizer (invoked by right-clicking the Draw Area and select Layouts Properties ) as given in the table below (also refer the figure above).

13. In the GridBag Layout Customizer, set the following properties for all the components:

Property Value Grid Width 1 Grid Height 1 Fill Horizontal Anchor Center Insets 5,5,5,5

Page 101: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 100

Grid Component (Identified

with Instance Name) GridX GridY NameL 0 1 DisplayL 0 2 TypeL 0 3 ManagedL 0 4 StatusL 0 5 ParentKeyL 0 6 SwitchL 0 7 PortTypeL 0 8 SpeedL 0 9 PortNoL 0 10 TrunkL 0 11 RemortPortL 0 12 NameTF 1 1 DisplayNameTF 1 2 TypeTF 1 3 ManagedTF 1 4 ParentKeyTF 1 5 StatusTF 1 6 SwitchTF 1 7 PortTypeTF 1 8 SpeedTF 1 9 PortNOTF 1 10 TrunkTF 1 11 RemortPortTF 1 12

Designing Button_Panel Panel

1. Ensure that the layout of this panel is set as Flow Layout by right-clicking the Draw Area and select Layouts > Flow Layout.

2. Drop a JButton from SwingBeans.list tab of the Beans Palette in the "Button_Panel" JPanel. Invoke the Property Form, provide the "Instance Name" property with the value "Close" and choose "text" property and provide the value "Close". Close the Property Form using the "Close" button.

3. Right-click the "Close" button and select Interaction Wizard > action > actionPerformed to get a rubber-band line, drop the rubber-band line on to the "Close" button itself to invoke the Interaction Wizard.

4. Move to the last screen of the Interaction wizard using the "Next" button (by clicking the button twice).

5. Insert the following code in the actionPerformed method setVisible(false);

Page 102: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 101

6. Close the Interaction Wizard using the "Finish" button.

import java.io.*; import java.util.Properties; import com.adventnet.nms.mapui.MapClientAPI;

For the Property screen to show the properties of the Card and Port when the menu is invoked form Card and port respectively, insert the following user code just before the final "}" brace of the source in the source tab -

MapClientAPI api; public void setValue(String portname,String type) { String pn = null ; if( portname != null ) { pn = portname; } else{ System.out.println(" portname is null . Please input the portname"); return; } setTitle("Property - "+pn); try{ api=MapClientAPI.getInstance(); }catch(Exception e) { System.out.println("Error in getting Handle of MapClientAPI"+e); } try{ Properties prop=api.getManagedObjectProperties(pn); NameTF.setText(prop.getProperty("name")); SwitchTF.setText(prop.getProperty("switchnode")); SpeedTF.setText(prop.getProperty("speed")); PortTypeTF.setText(prop.getProperty("portType")); DisplayNameTF.setText(prop.getProperty("displayName")); ParentKeyTF.setText(prop.getProperty("parentKey")); TypeTF.setText(prop.getProperty("type")); ManagedTF.setText(prop.getProperty("managed")); StatusTF.setText(prop.getProperty("status")); PortNoTF.setText(prop.getProperty("portno")); if(type.equals("Trunk")) { TrunkTF.setText(prop.getProperty("trunk")); RemotePortTF.setText(prop.getProperty("remotePortID")); } if(type.equals("Access")) { TrunkL.setText("SNMP Interface"); TrunkTF.setText(prop.getProperty("snmpInterface")); RemotePortL.setVisible(false); RemotePortTF.setVisible(false); } if(type.equals("Card")) { SwitchL.setText("Card Type"); SwitchTF.setText(prop.getProperty("cardType")); PortTypeL.setText("Serial Number");

Page 103: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 102

PortTypeTF.setText(prop.getProperty("serialno")); SpeedTF.setVisible(false); StatusTF.setVisible(false); PortNoTF.setVisible(false); TrunkTF.setVisible(false); RemotePortTF.setVisible(false); SpeedL.setVisible(false); StatusL.setVisible(false); PortNoL.setVisible(false); TrunkL.setVisible(false); RemotePortL.setVisible(false); } }catch (Exception remoteException) { System.out.println ( "Error in getting api.getByName using portname " + portname); remoteException.printStackTrace(); return; } }

The design of "Property_Screen" screen dialog is complete.

Page 104: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 103

5.7.1.3 Chassis Configuration

In the Chassis Configuration Screen you have to provide the details for the 'Shelf_Type1' & 'Shelf Identification Name' in Chassis Configuration table, 'Slot Identification Name' in the Shelf Configuration table and 'Card Value' in the Card Configuration table. You can also configure the default card type for each slot using the "Default Type" column in Shelf Configuration table and set the default type as "Blank_Card".

Chassis Configuration Table Ensure cell under the Shelf Identification Name for "Shelf1" and the value is set to currentManagedObjectName + "_Shelf1"(by default as in the above figure). Since the shelf name in the Web NMS database is referred with its respective Parent MO. Shelf Configuration Table Ensure following parameters are set for the respective slots in the Shelf Configuration Table as listed in the table below (refer the above figure)

Page 105: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 104

Slot Default Type Slot Identification Name Slot1 currentManagedObjectName + "_Slot0" Slot2 currentManagedObjectName + "_Slot1" Slot3 currentManagedObjectName + "_Slot2" Slot4 currentManagedObjectName + "_Slot3" Slot5 currentManagedObjectName + "_Slot4" Slot6 currentManagedObjectName + "_Slot5" Slot7 currentManagedObjectName + "_Slot6" Slot8 currentManagedObjectName + "_Slot7" Slot9 currentManagedObjectName + "_Slot8" Slot10 currentManagedObjectName + "_Slot9" Slot11 currentManagedObjectName + "_Slot10" Slot12 currentManagedObjectName + "_Slot11" Slot13 currentManagedObjectName + "_Slot12" Slot14 currentManagedObjectName + "_Slot13" Slot15 currentManagedObjectName + "_Slot14" Slot16

Card_2

currentManagedObjectName + "_Slot15"

Card Configuration Table In Card Configuration Table, provide the values for each card type screens as given in the table below (also refer the above figure). This is done by double-clicking the editable combo box against each card and entering the respective card value.

Card Type Screen Name Card Value

Access_Card Access Trunk_Card Trunk Blank_Card Blank

Note: The correct card values should be provided as in the Web NMS Database because the incorrect card values will not poll the cards in slots.

Save the Project using the menu command File > Save > Project.

Page 106: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 105

5.7.1.4 Compiling and Packaging the Application The Packaging of applications built using Client Builder to NAR (NMS ARchive) is done using the Package Wizard. After NAR is created, NAR is installed in the Web NMS Client (using Deployment Wizard in Web NMS). Before the packaging the chassis application to NAR, you must compile the project Follow the steps given below to compile the project. Compiling the Project

1. Ensure that the "NmsClientClasses.jar" of Web NMS is in the CLASSPATH for proper compilation. You can verify this in the "Required Jars" combo box present in the Classpath Settings tab of Project Properties dialog (invoked using menu command Properties > Project Properties)

2. Ensure that the <Web NMS Home >/classes and <Web NMS Home>/tutorials/ems_tutorial/classes are in classpath. You can verify this in the "Classpath" combo box present in the Classpath Settings tab of Project Properties dialog (invoked using menu command Properties > Project Properties)

3. Regenerate the Project using the menu command Project > Regenerate Project.

4. Compile the Project using the menu command Project > Compile Project. You will get the message "Compilation succeeded for EMS_Chassis" in status bar.

Packaging the Classes using Package Wizard

1. Invoke the Package Wizard for creating the Device Specific NAR using the menu command Tools > Package for Web NMS > Device Specific. For detailed explanation on using the Package Wizard follow the topic Integration with Web NMS.

2. Select the value "com.adventnet.nms.tutorials.ems.ChassisScreen" from the Classes list and click "Next" to proceed to next screen.

3. Choose the required destination directory where the NAR has to be created using the browse

button. Click "Next" to proceed to next screen.

4. Provide the corresponding device type that of the device host such as "Switch" in the "Device Type" field. Click "Next" to proceed to next screen.

5. Ensure the required device information are listed in the "DESTINATION DIRECTORY" and click "Next" to proceed to final screen of the Package Wizard.

6. Select the "ManagingObjectName" value from the Parameter list and provide the value "${name}" in the "Value" text field. Click "Modify" button to change the values in the list as in the figure below. This is to provide the ManageObjectName that dynamically changes depending on the Map node (the application is invoked from the Map node) in Web NMS Client.

Page 107: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 106

7. Click "Finish" button to close the Package Wizard to get the confirmation dialog with the message "Chassis_Tree" created successfully at <specified location>.

8. Import the NAR in the EMS Project using the Client Application Import Wizard with the required menu name and menu item.

Note: The above project is also available in <Web NMS Home>/StudioTools/ClientBuilder/projects directory with the project name EMS_Chassis. You can also load and see this project for your reference.

Page 108: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 107

5.7.2 Building Configuration Screen The Configuration Management of the Network Elements is an integral part of the Element Management Application. In this section, you learn to build Configuration Application for configuring the Switch details using StudioTools > ClientBuilder > Configuration Wizard. The built Configuration Application is packaged as NAR (NMS ARchive) and imported into EMS project as a Client NAR. The imported NAR will be installed in Web NMS. The Installed Configuration Application is invoked from the Web NMS Client by invoking a menu on the Map node, where the Map nodes are representing the Switch Devices. The application invoked from a Map node is shown in the figure below. Final Output

Pre-requisites Copy the following images from the Web NMS to <Client Builder Home>/images directory.

Image Source Directory ems_tut_switch_tick.png <Web NMS

Home>/StudioTools/Studio/projects/EMS_Tutorial/resources/imagesproperties.png <Web NMS Home>/images

Device Information

• BRIDGE-MIB - It is used as Device Information for building Switch Configuration Application. Since you are building a Configuration Application for representing Map Nodes for Switch device, the BRIDGE-MIB is used as Device Information to build the Configuration Management Application.

Page 109: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 108

• RFC1213-MIB - The device details such as System Name, Description, Physical Location, User/Contact Name are configured or displayed in Switch Configuration Application using this MIB.

Getting Started With Development Follow the steps given below to create a configuration project in AdventNet Client Builder - Configuration Wizard

Opening Configuration Wizard

To invoke Chassis Wizard from Web NMS Launcher, double-click Web NMS IDE icon in the Web NMS Launcher. From here, double-click the Configuration Wizard icon. Alternatively, you can use startConfigurationWizard.bat/.sh present in <Web NMS Home>/StudioTools/ClientBuilder/bin.

Creating the Project and Loading Device Information

1. Select File > New > Project to invoke the "Project Details" dialog to create a new

configuration project. 2. Provide the "Project Name" field with the value "EMS_Configuration" if it does not

exists. 3. Provide the "Package Name" field with the value

"com.adventnet.nms.tutorials.ems". 4. Click OK button to create the project in the projects folder under the <Client Builder

Home>. You can find the project named "EMS_Confiugration" in the project tree. 5. Load the BRIDGE-MIB under the <Client Builder Home>/mibs directory using the

load XML/MIB button . Similarly load the RFC1213-MIB. 6. Invoke the "Screen Properties" dialog using Properties > Screen Properties.

Change the "Title" value to "Screen Configuration" and click OK.

Configuring the Required Classes and JARs

1. Invoke the "Project Properties" dialog using Properties > Project Properties.

2. In the "General" tab, click the browse button against the "Project Parameters" field to invoke the "Project Parameters List". Add the entry "COMMUNITY=public;to the existing list and click OK button.

3. Switch to "Classpath Settings" tab and click the browse button against the "Classpath" field to invoke the "Classpath List" dialog. Add the <Web NMS Home> /classes directory using the "Browse" button. Click "OK" button to close the dialog. Similarly, add the <WebNMSHome>/StudioTools/Studio/projects/EMS_Tutorial/classes. Click OK to close the dialog.

4. Click the browse button against the "Required Jars" field to invoke the "Containing Jars List" dialog. Add the "NMSClientClasses.jar" available under <Web NMS Home>/classes directory using the "Browse" button.

5. Click OK to close the 'Project Properties" dialog.

Page 110: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 109

Steps Involved in Building Project and Packaging the Application The steps involved in building the Configuration Management Application, Packaging the Application as NAR and installing the NAR in Web NMS Client are given below

1. Designing Main Screen - Switch Configuration Screen 2. Designing Panels for Main Screen

• System Configuration Panel

• Spanning Tree Details Panel

• Port Parameters Panel 3. Integrating Panels and Adding Actions for Buttons 4. Compiling and Packaging the Application

Page 111: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 110

5.7.2.1 Designing Main Screen - Switch Configuration Screen The main screen of the Configuration Management Application has a tree in the left side, tabbed pane in the right side and a panel with buttons at the bottom of the screen. The figure below shows the components in the main screen. Design Time View

Steps Involved Initial Settings

1. Create a new screen under the "EMS_Configuration" project and rename it as "SwitchConfiguration".

2. Change the build type of the Screen to "NMS Frame" using the menu command Build > Type > NMS Frame.

3. Change the layout of the Screen to "Border Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > Border Layout.

Page 112: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 111

Dropping and Laying out the Components 1. Drop the AdventNetTree bean and change its instance name by following the steps below

o Switch to the "Project Classes" tab of Beans Palette. o Provide the value "com.adventnet.beans.utilbeans.AdventNetTree" in the "Enter

the Class Name" text field.

o Click and drop the "bean" button in the "West" position of the Draw Area . o Change the instance name of the AdventNetTree bean instance as "Switch_Tree"

using the Property Form. 2. Drop the JTabbedPane bean and change its instance name by following the steps below

o Switch to the "SwingBeans.list" tab of Beans Palette. o Click and drop the JTabbedPane bean in the "Center" position of the Draw Area. o Change the instance name of the JTabbed bean instance as "Details_TabbedPane"

using the Property Form. 3. Drop the JPanel bean and change its instance name by following the steps below

o Switch to the "SwingBeans.list" tab of Beans Palette. o Click and drop the "JPanel" bean in the "South" position of the Draw Area. o Change the instance name of the JPanel bean instance as "Button_Panel" using the

Property Form. Invoke the "Border Layout" dialog to arrange the components by right-clicking the Draw Area and select "Layout Properties" menu item. Select each component in the "Component" combo box and ensure the parameters are as in the table given below, if not provide the values and click "OK" button to close the dialog.

Component Position HGap VGap Button_panel South Switch_Tree West Details_TappedPane Center

5 5

Designing Switch_Tree Bean

1. Double-click the "Switch_Tree" bean to invoke the Property Form. 2. Select the TreeValues and Click "Click to edit Titles and class or File names" button

against it to invoke the "Tree Values" dialog. 3. Add the "Configure Switches" node by following the steps below

o Provide the value "Configure Switches" in the "Node Name" text field. o Select the "logo.png" from the <Client Builder Home>/images using the "Browse"

button. o Click the "Add" button.

Similarly, add following nodes under the root node (Configure Switches) of the tree with the respective icons as given in the table below.

Node Name Icon Name

Switch Name ems_tut_switch_tick.jpg View Result properties.png

4. Click "Apply" button after adding the above nodes and Click "Close" to close the dialog.

Page 113: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 112

5. Close the Property Form using the "Close" button. 6. Right-click the "Switch_Tree" bean, select Interaction Wizard > treeSelection >

valueChanged to get a rubber band line. Bring the rubber band line into "Switch_Tree" bean itself to invoke the Interaction Wizard.

o Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

o Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

o Insert the following code in the valueChanged method

String name=null; TreePath tp=arg0.getNewLeadSelectionPath(); if(tp != null) { AdventNetTreeNode an=(AdventNetTreeNode)tp.getLastPathComponent(); name=an.getName(); if(name.equals("View Result")) { Details_TabbedPane.setEnabledAt(0,false); if (userOperations.toString().indexOf("Ems") != -1) { if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None"))) { Details_TabbedPane.setEnabledAt(1,false); Details_TabbedPane.setEnabledAt(2,false); } } if (userOperations.toString().indexOf("Ems") == -1) { Details_TabbedPane.setEnabledAt(1,false); Details_TabbedPane.setEnabledAt(2,false); } if(Details_TabbedPane.indexOfTab("Results") == -1) Details_TabbedPane.insertTab("Results",null,Results_Panel, null,Details_TabbedPane.getTabCount()); Details_TabbedPane.setSelectedIndex(Details_TabbedPane.getTabCount()-1); configure.setEnabled(false); refresh.setEnabled(false); } if(name.equals(getParameter("HOST"))) { if((Details_TabbedPane.indexOfTab("Results")) != -1) { Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("Results")); } Details_TabbedPane.setEnabledAt(0,true); if (userOperations.toString().indexOf("Ems") != -1) { if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None"))) { Details_TabbedPane.setEnabledAt(1,true); Details_TabbedPane.setEnabledAt(2,true); } } Details_TabbedPane.setSelectedIndex(0); refresh.setEnabled(true);

Page 114: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 113

if (userOperations.toString().indexOf("Ems") != -1) { if ( (userOperations.contains("Ems Configure Scalar") || userOperations.contains("Ems Configure All")) && ! userOperations.contains("Ems Configure None")) { configure.setEnabled(true); } } if (userOperations.toString().indexOf("Ems") == -1) { Details_TabbedPane.setEnabledAt(1,true); Details_TabbedPane.setEnabledAt(2,true); configure.setEnabled(true); } } }

o Click "Finish" to close the Interaction Wizard.

7. Switch to Source View tab and scroll to the setVisible method. Write the following code under the //<End_setVisible_boolean> tag.

if(bl) { String icon2="../images/ems_tut_switch_small.png"; AdventNetTreeNode node=Switch_Tree.getNode(getParameter("HOST"),icon2); Switch_Tree.setSelectionInterval(1,1); Switch_Tree.addNode(node); Switch_Tree.selectNode(node); if (userOperations.toString().indexOf("Ems") != -1) { if(userOperations.contains("Ems Configure Scalar") && ( ! userOperations.contains("Ems Configure All") && ! (userOperations.contains("Ems Configure None")) )) { Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("STP")); Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("PortParameters")); } if (userOperations.contains("Ems Configure None")) { configure.setEnabled(false); } } }

8. Add the following code under the package import declarations as given below :

import java.net.*; import javax.swing.tree.TreePath; import java.util.Vector; import java.rmi.Naming; import com.adventnet.beans.utilbeans.AdventNetTreeNode; import com.adventnet.nms.util.NmsClientUtil; import com.adventnet.nms.util.BrowserControl; import com.adventnet.security.authorization.AuthorizationEngine;

9. Add the following code under the package variable declarations as given below :

private Vector userOperations=new Vector();

Page 115: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 114

10. Add the following code in the init method before the closing braces ("}") of this method as given below :

checkUserOperations(); setResizable(false);

11. Add the following code in stop method before the closing braces ("}") of this method as given below :

PortDetails1.stop();

12. Add the following code in start method after the opening braces ("{") of this method as given below :

PortDetails1.start(); Custom code that need to be added in the Configuration management screen to cater for Security administration In the Configuration wizard, we have created the screens for configuring the Switches. In the SwitchConfiguration.java file of the EMS configuration project, the following code was accommodated in order to cater for Security administration. When the switch configuration screen is invoked from the client, the checkUserOperations() method makes a RMI lookup to the AuthorizationEngineAPI for retrieving the operations for the logged-in user.

private void checkUserOperations() { try{ URL BE_Url = NmsClientUtil.applet.getCodeBase(); String BEHostName = "localhost"; BEHostName = BE_Url.getHost(); if(BEHostName.trim().equalsIgnoreCase("localhost")) try { BEHostName = InetAddress.getLocalHost().getHostName(); } catch(UnknownHostException unknownhostexception1) { System.err.println("unknown host : " + unknownhostexception1); } if(BE_Url != null && BEHostName != null) { String name = "//" + BEHostName + "/NmsAuthEngineAPI"; AuthorizationEngine authEngine = (AuthorizationEngine) Naming.lookup(name); if(authEngine == null) { System.out.println("Could not get rmi handle to AuthAPI"); } else { String userName = NmsClientUtil.getUserName(); userOperations = authEngine.getOperationsForUser(userName);

Page 116: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 115

} } } catch(AuthorizationException ex) { System.out.println("Exception while getting RMI handle to Authorization Engine " + ex.getMessage()); } catch(Exception exp) { System.out.println("Exception while getting RMI handle to Authorization Engine " + exp.getMessage()); } }

Whenever a component in the UI is added, disabled or enabled, a check is made if the user logged in has the required permission to perform the operation. Based on the user operation, the component is enabled or disabled.

if(userOperations.toString().indexOf("Ems") != -1) { if (userOperations.contains("Ems Configure None")) { configure.setEnabled(false); } }

13. Switch back to Screen View tab.

Designing the Button_Panel Bean 1. Ensure that the layout of Button_Panel is flow layout. 2. Drop a JButton from the SwingBeans.list tab of BeansPalette and change its instance name

as "configure" and provide "text" property value "Configure" in the Property Form. Similarly drop three more JButtons and change their properties in Property Form as given in the table below:

Instance Name Text Property refresh Refresh help Help close Close

3. Resize the bean components to the required size (refer the Design Time View screen shot).

Note: The actions for each of the above buttons are provided after the panel screens are designed and integrated.

Page 117: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 116

5.7.2.2. Designing Panels for Main Screen The Main Screen - - Switch Configuration Screen contains a Tabbed Pane (Details_TabbedPane) in which four tabs are present, in which you have already designed the Results_Table Panel. This section explains the designing of other panels.

• Designing System Configuration Panel

• Designing Spanning Tree Details Panel

• Designing Port Parameters Panel

Page 118: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 117

5.7.2.2.1 Designing System Configuration Panel The System Configuration Panel is to show the Device Details such as Name, Description, Physical Location, and User/Contact Name and configure them at run time. This Panel is the default tab in the Switch Configuration Application at run time. This topic explains the step-by-step procedure to build this panel screen. Steps Involved Initial Settings

1. Create a new screen under the "EMS_Configuration" project and rename it as "SystemConfig".

2. Change the build type of the Screen to "Panel" using the menu command Build > Type > Panel.

3. Change the layout of the Screen to "Border Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > Border.

Dropping and Laying Out Components 1. Ensure that the "SwingBeans.list" tab of Beans Palette is selected.

2. Click and drop a JPanel bean in the "Center" position of the Draw Area and change its instance name as "Sys_Details_Panel".

3. Change the layout of the "Sys_Details_Panel" to "GridBag Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > GridBag Layout.

4. Drop a JLabel from the SwingBeans.list tab of BeansPalette and change its instance name as "nameL" and provide "text" property value "Name" in the Property Form. Similarly drop three more JLabel and change their properties in Property Form as given in the table below

Instance Name Text Property

descL Description

phys_locL Physical Location

cont_nameL User/Control Name

5. Expand the RFC1213-MIB node in the XML tree and scroll down to RFC1213-MIB > org > dod > internet > mgmt > mib-2 > system.

6. Click and drop the "sysName" representation (View1 node under this node) and change the instance name as nameTF. Similarly drop the representation for the nodes given in the table below and change the their respective instance name.

Representation for the Node Instance Name

sysDescr descTF

sysLocation phy_locTF

sysContact cont_nameTF

7. Invoke the "GridBag Layout Customizer" window for the "Sys_Details_Panel" by right-clicking the screen and select "Layout Properties". \

Page 119: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 118

8. In the GridBag Layout Customizer, set the following properties for all the components:

Property Value

Fill Horizontal

Anchor Center

Insets 5,5,5,5 9. Arrange the components in the "GridBag Layout Customizer" window as given below

Grid Component (Identified with Instance Name) GridX GridY

Anchor IPadX WeightX

nameL 0

descL 1

phys_locL 2

cont_nameL

0

3

EAST 4 0.0

nameTF 0

descTF 1

phy_locTF 2

cont_nameTF

1

3

WEST 0 0.1

This design of "System Configuration Panel" screen is complete. Save the "SystemConfig" screen using the menu command File > Save > Screen. Compile the "SystemConfig" screen using the menu command Build > Compile.

Page 120: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 119

5.7.2.2.2 Designing Spanning Tree Details Panel

The Spanning Tree Details Panel is to show the Spanning Tree Details such as Bridge Priority, Maximum Age, Hello Time, and Forward Delay and configure them at run time. This Panel is in the "STP" tab of the Switch Configuration Application at run time. This topic explains the step-by-step procedure to build this panel screen. Steps Involved Initial Settings

1. Create a new screen under the "EMS_Configuration" project and rename it as "STP".

2. Change the build type of the Screen to "Panel" using the menu command Build > Type > Panel.

3. Change the layout of the Screen to "Border Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > Border.

Dropping and Laying Out Components 1. Ensure that the "SwingBeans.list" tab of Beans Palette is selected.

2. Click and drop a JPanel bean in the "Center" position of the Draw Area and change its instance name as "ST_Details_Panel".

3. Change the layout of the "ST_Details_Panel" to "GridBag Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > GridBag Layout.

4. Drop a JLabel from the SwingBeans.list tab of BeansPalette and change its instance name as "bridge_priorityL" and provide "text" property value "Bridge Priority" in the Property Form. Similarly drop three more JLabel and change their properties in Property Form as given in the table below

Instance Name Text Property

max_ageL Max.Age

hello_timeL Hello Time

forw_delayL Forward Delay

5. Expand the BRIDGE-MIB node in the XML tree and scroll down to BRIDGE-MIB > mib-2 > dot1dBridge > dot1dStp.

6. Click and drop the "dot1dStpPriority" representation ("View1" node under this node) from the XML tree in the "ST_Details_Panel" bean. Change the instance name of the dropped bean "bridge_priorityTF".

7. Drop a JTextField from the SwingBeans.list tab of BeansPalette and change its instance name as "max_ageTF". Similarly, drop two more text fields and change their instance names as "hello_timeTF" and "forw_delay_TF" respectively.

8. Switch to the Config tab.

9. Select the "dot1dStpBridgeMaxAge" node from the XML Tree, and click the "Add

Attribute" button to add the attributes from the Xml Tree to the Config Tree.

Page 121: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 120

10. Edit the code in the "Code Area" and change the bolded code line as given below.

Properties valueProp = new Properties(); valueProp.setProperty(LABEL,"dot1dStpBridgeMaxAge"); valueProp.setProperty(TYPE,"2"); valueProp.setProperty(VALUE,String.valueOf(max_ageTF.getText())); return valueProp;

11. Similarly repeat the above steps for the nodes dot1dStpBridgeHelloTime, dot1dStpBridgeForwardDelay. The corresponding code lines to be modified are respectively.

valueProp.setProperty(VALUE,String.valueOf(hello_timeTF.getText()));

valueProp.setProperty(VALUE,String.valueOf(forw_delay_TF.getText()));

12. Click and drop the "dot1dStpBridgeMaxAge" node from the XML Tree on the "max_ageTF" bean to invoke the Client Property dialog. Select the "setText" method from the "Result Method" list and click OK button to close the Client Property dialog.

13. Follow the above step (Step-7) to drop the nodes and setting the "setText" method in Client Property dialog.

Bean Instance Name Node to be Dropped from XML Tree hello_timeTF dot1dStpBrideHelloTime forw_delay_TF dot1dStpBridgeForwardDelay

14. Invoke the "GridBag Layout Customizer" window for the "Sys_Details_Panel" by right-clicking the screen and select "Layout Properties".

15. Arrange the components in the "GridBag Layout Customizer" window as given below.

16. In the GridBag Layout Customizer, set the following properties for all the components:

Property Value

Fill Horizontal

Insets 5,5,5,5

Grid Component (Identified with Instance Name) GridX GridY

Anchor IPadX WeightX

bridge_priorityL 0 max_ageL 1 hello_timeL 2 forw_delayL

0

3

EAST 4 0.0

bridge_priorityTF 0 max_ageTF 1 hello_timeTF 2 forw_delay_TF

1

3

WEST 0 0.1

This design of "Spanning Tree Details" screen is complete. Save the "STP" screen using the menu command File > Save > Screen. Compile the "STP" screen using the menu command Build > Compile.

Page 122: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 121

5.7.2.2.3 Designing Port Parameters Panel The Port Parameters Panel displays the details of the Ports, The Port Parameters Panel is in the "PortParameter" tab of the "Details_TabbedPane" in the Main Screen. The designing Port Panel Details Panel is explained in this topic. Follow the steps given below to build the Port Parameters Panel. Steps Involved Initial Settings

1. Create a new screen under the "EMS_Configuration" project and rename it as "PortDetails".

2. Change the build type of the Screen to "Panel" using the menu command Build > Type > Panel.

3. Change the layout of the Screen to "Border Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > Border.

Dropping and Laying Out Components 1. Click and drop a JScrollPane bean from SwingBeans.list tab of Beans Palette in the

"Center" position of the Draw Area. Change its instance name as "Details_ScrollPane". 2. Drop a SortTable bean from AdventNetUtils.jar of the Beans Palette in the

"Details_ScrollPane" bean. Change the SortTable bean instance name as "Port_Details_Table".

Creating and Dropping the Virtual Table Model

1. Right-click the "Virtual Table Model" node in the XML Tree and select "Add" menu item to invoke the "Create New Virtual Table Model" Wizard.

2. Modify the "Virtual Table Model Name" as "PortParametersTable1". 3. Select the following columnar nodes from XML tree to "Selected Nodes" list using the

button. These nodes are present under the "dot1dStpPortTable" table node in the path BRIDGE-MIB > mib-2 > dot1dBridge > dot1dStp > dot1dStpPortTable of the XML tree

• dot1dStpPort

• dot1dStpPortPriority

• dot1dStpPortState

• dot1dStpPortEnable

• dot1dStpPortPathCost

• dot1dStpPortForwardTransitions 4. Click the "Advanced Properties" button and change the 'PollInterval' to "0". 5. Click "Next" button to proceed to final screen of the Wizard. 6. Scroll down to end of the Class and add the following methods namely "getColumnClass",

"getValueAt", and "setValueAt" before the closing brace ("}") of the class.

public Class getColumnClass(int c) { if(c == 3) { return Boolean.class; } else

Page 123: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 122

{ return super.getColumnClass(c); } } public Object getValueAt(int row, int col) { if(col == 3) { String portEnabled = super.getValueAt(row,col).toString(); if(portEnabled.indexOf("1") != -1) { return Boolean.TRUE; } else { return Boolean.FALSE; } } else { return super.getValueAt(row,col); } } public void setValueAt(Object value , int row , int col) { if(col == 3) { Boolean enabled = (Boolean)value; if(enabled.booleanValue()) { super.setValueAt("1",row,col); } else { super.setValueAt("2",row,col); } } else { super.setValueAt(value,row,col); } }

7. Click "Finish" button to close the Virtual Table Model Wizard. 8. Click and drop the "PortParametersTable1" node under the "Virtual Table Model" node of

the XML tree outside the Draw Area. You can find the name of dropped bean is "PortParmetersTable11" .

9. Double-click the "Port_Details_Table" to invoke the Property Form. Select the "model" and choose the "PortParmetersTable11" from the combo box.

Dropping and Configuring ConfigCache Bean 1. Click and drop the ConfigCache bean from AdventNetMSBeans.jar of Beans Palette

outside the Draw Area. 2. Switch to the Source View tab and scroll down of the screen's class. 3. Insert the following methods namely "saveTableValues", "getSavedTableValues" and

"getStringConfigValueFor" before the closing braces of the class ("}"). This code is to save the values from the table.

Page 124: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 123

public String getStringConfigValueFor(String gnameArg, String identifierNameArg, String identifierArg, String indexArg, Object[] userData) { if(gnameArg.equals("group1")) { if(identifierNameArg.equals("dot1dStpPortPriorityInstance")) { int index = Integer.parseInt((String)userData[0]); return (String)SortTable1.getValueAt(index, 1); } else if(identifierNameArg.equals("dot1dStpPortEnableInstance")) { int index = Integer.parseInt((String)userData[0]); String val=SortTable1.getValueAt(index,3).toString(); if(val.equals("true")) { return "1"; } else return "2"; } else if(identifierNameArg.equals("dot1dStpPortPathCostInstance")) { int index = Integer.parseInt((String)userData[0]); return (String)SortTable1.getValueAt(index, 4); } } return null; } public void saveTableValues() { ConfigCache1.resetAll(); for(int i=0;i<Port_Details_Table.getRowCount();i++) { try{ ConfigCache1.saveConfigInfo("this_group1"+i, "group1", PortDetails.this, new String[]{""+i}); }catch(Exception ex) { System.out.println("Error in Configuration "+ex); } } } public GroupInfoCache[] getSavedTableValues() { return ConfigCache1.getGroupInfoCaches(); }

4. Add the following code under the package import declarations as given below :

import com.adventnet.beans.configuration.GroupInfoCache;

5. Switch to the Config tab. 6. Select the "dot1dStpPortPriorityInstance" node from the XML Tree, and click the "Add

Attribute" button to add the attributes from the Xml Tree to the Config Tree. 7. Edit the code in the "Code Area" and the following code

Page 125: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 124

String valueStr = getStringConfigValueFor(gnameArg, identifierNameArg, identifierArg, indexArg, userData); if(valueStr == null) { return null; }

8. Change the bolded code line as given below.

Properties valueProp = new Properties(); valueProp.setProperty(LABEL,"dot1dStpPortPriorityInstance"); valueProp.setProperty(TYPE,"2"); valueProp.setProperty(VALUE,valueStr); return valueProp;

9. Similarly repeat the above steps for the nodes "dot1dStpPortEnableInstance","dot1dStpPortPathCostInstance". The corresponding code lines to be modified are given below :

valueProp.setProperty(VALUE,valueStr);

10. Add the following the code against the index attribute in the code area

int index = Integer.parseInt((String)userData[0]); return (String)Port_Details_Table.getValueAt(index, 0);

This design of "Port Details" panel screen is complete. Save the "PortDetails" screen using the menu command File > Save > Screen. Compile the "PortDetails" screen using the menu command Build > Compile.

Page 126: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 125

5.7.2.3 Integrating Panels and Adding Actions for Button The Main Screen has "Details_TabbedPane" (tabbed pane bean) containing four tabs, but the Main Screen currently has only tab named "Results_Panel" (The "Results" in figure below). This topic explains the integration of the three panel screens into to the Main Screen as tabs of the "Details_TabbedPane" bean and setting action for each button in the "Button_Panel". Follow the steps given below to achieve the same Design Time View

Steps Involved

1. Switch to "Project Classes" tab of the Beans Palette and select "com.adventnet.nms.tutorials.ems.SystemConfig" from the "Enter Class Name" combo box. Click and drop the button in the "Details_TabbedPane" bean. Thus you have dropped the "SystemConfig" class as bean. You can find tab with the name "SystemConfig1" in the "Details_TabbedPane" bean. Similarly drop the "com.adventnet.nms.tutorials.ems.STP" and "com.adventnet.nms.tutorials.ems.PortDetails" in the "Details_TabbedPane" bean. You can find the "STP1" and "PortDetails1" in the "Details_TabbedPane" bean.

Page 127: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 126

2. Designing the Details_TabbedPane Bean

• Drop a JPanel1 in "Details_TabbedPane" bean and change its instance name as "Results_Panel" using the Property Form.

• Change the layout of the "Results_Panel" bean to "Border" layout.

• Click and drop a "ConfigResultTableModel" bean from AdventNetMSBeans.jar tab of the Beans Palette outside the Draw Area. You can find the instance name of the dropped "ConfigResultTableModel" bean is "ConfigResultTableModel1".

• Switch to Component tab and edit the ConfigurationResultEventAction under the connections node. Remove the code in the configPerformed method and add the following code :

try { ConfigResultTableModel1.addConfigResult( arg0); } catch(java.lang.NullPointerException ex) { ex.printStackTrace(); }

• Drop a JTable bean from "SwingBeans.list" tab of Beans Palette in the "Results_Panel" bean and change its instance name as "Results_Table".

• Invoke the Property Form for the "Results_Table" bean and set the model property with "ConfigResultTableModel1" and close the Property Form.

3. Ensure that the order of screen instance and panel beans in the "Details_TabbedPane" is as in the above Design Time View screen shot.

4. Invoke the "Layout Properties" dialog for the "Details_TabbedPane" bean by right-clicking it and selecting "Layout Properties" menu item.

5. Provide the "Title" text field value for "SystemConfig1" bean as "System Configuration" (refer the above figure).

Page 128: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 127

Similarly, provide the "Title" text field value for the other beans in the "Details_TabbedPane" as given in the table below

Bean Title STP1 STP PortDetails1 PortParameters Results_Panel Results

Inserting Methods for Button Actions

1. Switch to Source View tab and scroll down to end of the screen's class. 2. Insert the following methods "checkUserOperations", "helpAction" and,

"screenConfiguration" before the closing braces ("}") for the screen's class. These methods are required for configuring button actions.

private void checkUserOperations() { try{ URL BE_Url = NmsClientUtil.applet.getCodeBase(); String BEHostName = "localhost"; BEHostName = BE_Url.getHost(); if(BEHostName.trim().equalsIgnoreCase("localhost")) try { BEHostName = InetAddress.getLocalHost().getHostName(); } catch(UnknownHostException unknownhostexception1) { System.err.println("unknown host : " + unknownhostexception1); } if(BE_Url != null && BEHostName != null) { String name = "//" + BEHostName + "/NmsAuthEngineAPI"; AuthorizationEngine authEngine = (AuthorizationEngine) Naming.lookup(name); if(authEngine == null) { } else { String userName = NmsClientUtil.getUserName(); userOperations = authEngine.getOperationsForUser(userName); } } }catch(Exception exp) { System.out.println("Exception while getting RMI handle to Authorization Engine " + exp.getMessage()); } } public void helpAction() { BrowserControl bc = new BrowserControl(); bc.displayURL(System.getProperty("user.dir")+File.separator+ "tutorials"+File.separator+"ems_tutorial"+File.separator+"help"+ File.separator+"ems_tutorial"+File.separator+"implementation"+ File.separator+"configtutdoc.html");

Page 129: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 128

} public void screenConfiguration() { try{ ConfigResultTableModel1.clearAllRows(); Configurator1.resetAll(); Configurator1.setTaskName("SwitchConfiguration_task"); Configurator1.addGroup("group1", SystemConfig1, null); if (userOperations.toString().indexOf("Ems") != -1) { if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None"))) { Configurator1.addGroup("group1", STP1, null); PortDetails1.saveTableValues(); Configurator1.addGroupInfoCaches( PortDetails1.getSavedTableValues()); } } else { Configurator1.addGroup("group1", STP1, null); PortDetails1.saveTableValues(); Configurator1.addGroupInfoCaches( PortDetails1.getSavedTableValues()); } Configurator1.doConfiguration(); Switch_Tree.setSelectionInterval((Switch_Tree.getRowCount())-1,(Switch_Tree.getRowCount())-1); } catch(java.lang.Exception ex) { ex.printStackTrace(); } }

Setting Action for Buttons

For "configure" button

1. Right-click the "configure" button, select Interaction Wizard > action > actionPerformed to get a rubber band line. Bring the rubber band line into "configure" button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Select the "Task based Configuration with Roll Back and Multiple Device Support " option as you need this option in this case.

4. Click "Next" button. Steps to be followed in Interaction Wizard

Specifying How to Apply the Configuration

The Configuration is performed by the Configurator Bean. The Configurator Bean does this task by task, each task containing one or more groups.

Page 130: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 129

5. Select the Configurator Bean to be used for applying the Configuration. This is applicable when there are some Configurator Beans already available in the Screen. Since you do not have a Configurator Bean till now, this Select Instance combo box is disabled. This means you need to instantiate a new one.

6. Specify the Instance Name in the New Instance Name text field (default is Configurator1).

Processing the Configuration Result

7. Ensure that the "Create Result Event Connection" is checked, since you need the

result of the Configuration in a dialog. The Result Event connection can be created with a name of your choice. This name can be specified in the text field corresponding to Connection Class Name. If you are not in need of the Result Processing Part, the Check Box can be unchecked. Click "Next" button.

Specifying the Device(s) to be Configured

This screen displays a list where you specify the Devices on which the Configuration need to be applied.

8. Click "Next" button.

Configuration Task Details

This screen asks for information on the configuration task like the Name, whether an option is needed to revert to the previous configuration on failure and if so based on which document that contains the configuration profile.

9. Ensure the name is "EditedValueChecker_task". If you require details on Roll Back

you follow the topic Rolling Back to previous Configuration. Click "Next" button.

Specifying the Group of Interest

This screen displays a group tree on the left, This Tree contains all the available groups in the Screen. Since you have defined only one group, this will be listed. The list on the right contains the different groups that are to be configured with the current operation. You can see that the group has already been added to the Selected Groups list.

10. Click "Next" button.

Generate the Code for Configuration with the Details Provided

This brings up the screen that has a list (on the left) that displays the components being used in the Screen and components for which references are needed can be added to the list on the right.

11. Click "Next" button.

In this screen, you can find the code is generated automatically within the actionPerformed method based on the information furnished through all the steps so far in Interaction Wizard. Remove the existing code and Insert the following code in this method

screenConfiguration();

Page 131: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 130

12. Click "Finish" to close the Interaction Wizard. If you now go to the Component Tree and click "Connections" you find two new connections created. This completes the construction of the application.

For "refresh" Button

1. Right-click the "refresh" button, select Interaction Wizard > action >

actionPerformed to get a rubber band line. Bring the rubber band line into "refresh" button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method

PortDetails1.PortParametersTable11.refresh(); SystemConfig1.refresh(); STP1.refresh();

5. Click "Finish" to close the Interaction Wizard.

For "close" Button

1. Right-click the "close" button, select Interaction Wizard > action > actionPerformed to get a rubber band line. Bring the rubber band line into "close" button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method

setVisible(false);

5. Click "Finish" to close the Interaction Wizard.

For "help" Button

1. Right-click the "help" button, select Interaction Wizard-->action-->actionPerformed to get a rubber band line. Bring the rubber band line into "help" button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method

helpAction();

5. Click "Finish" to close the Interaction Wizard.

This completes the building of Main Screen.

Page 132: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 131

5.7.2.4 Compiling and Packaging the Application The Packaging of applications built using Client Builder to NAR (NMS ARchive) is done using the Package Wizard. After NAR is created, NAR is installed in the Web NMS Client (using Deployment Wizard in Web NMS). Before the packaging the chassis application to NAR, you must compile the project Follow the steps given below to compile the project. Compiling the Project

1. Regenerate the Project using the menu command Project > Regenerate Project. 2. Compile the Project using the menu command Project > Compile Project. You will get the

message "Compilation succeeded for EMS_Configuration" in status bar.

Packaging the Classes using Package Wizard 1. Invoke the Package Wizard for creating the Device Specific NAR using the menu command

Tools > Package for Web NMS > Device Specific. For detailed explanation on using the Package Wizard follow the topic Integration with Web NMS.

2. Select the value "com.adventnet.nms.tutorials.ems.SwitchConfiguration" from the Classes list and click "Next" button to proceed to next screen.

3. Choose the required destination directory where the NAR has to be created using the browse button. Click "Next" button to proceed to next screen.

4. Provide the corresponding device type that of the device host such as "Windows NT", "Linux", or "Solaris" in the "Device Type" field. Click "Next" button to proceed to next screen.

5. Ensure the required device information are listed in the "DESTINATION DIRECTORY" and click "Next" button to proceed to final screen of the Package Wizard.

Page 133: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 132

Note: For security features, include four classes from the package com.adventnet.security.authorization located in <Web NMS Home>/classes directory into in <Client Builder Home>/projects/EMS_Configuration/classes directory. The required classes are AuthorizationException.class, AuthorizationEngine.class, AuthorizationEngineImpl.class, and AuthorizationEngineImpl_Stub.class.

6. Click Finish button to close the Package Wizard to get the confirmation dialog with the

message SwitchConfiguration.nar created successfully at <specified location>. 7. Import the NAR into the EMS Project, using the Client Application Import Wizard. 8. Deploy the NAR in Web NMS Client using the Deployment Wizard in Web NMS with the

required menu name and menu item

Note: The above project is also available in <Web NMS Home>/StudioTools/ClientBuilder/projects directory as EMS_Configuration that can be loaded for your reference.

Page 134: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 133

5.8 Packaging the Project This topic explains about compiling and packaging the EMS project.

• Compile the project

• Importing Client side classes as NAR

• Package the application

Compile the project After building the project, save and compile it using the Project -> Build Project menu. Now you can debug the application by running the WebNMS server and client within the Eclipse.

• Start the server using WebNMS > Launch > Start WebNMS Server menu.

• Start the client using WebNMS > Launch > Start WebNMS Client menu. For more details on Debugging Applications Built in Eclipse, refer to the Web NMS EclipsePlugin Guide. Importing Client NARs Import the Chassis and Configuration Screen Client NARs into the EMS Project. Package the application After compiling the project, package the application into a NAR file. For details on Packaging the Project, refer to the Web NMS EclipsePlugin Guide.

Step 1 : Invoking the Package Properties Wizard.

Select WebNMS > Package Project menu

Step 2 : Package Properties Details

Provide the following details for packaging:

NAR File Name - EMS_Tutorial

Output Directory - C:\AdventNet\WebNMS\projects

NAR File Version - 1.0

Readme Path C:\eclipse\workspace\EMS_Tutorial\README.html

Click Finish.

This will generate a NAR file called EMS_Tutorial1.0.nar.. You can deploy this NAR directly into Web NMS to install the application.

Page 135: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 134

5.9 Making the Switch configuration secured In this tutorial application, the security feature is implemented by using the Authorization service provided by Web NMS. This service supports authorization of application specific tasks, or operations. The architecture also supports user and group based authorization as well as view-based authorization. By using this authorization service, you can limit the users access to a specific area or subset of objects or instances. For instance, you can limit the access for a particular user to a certain kind of device. It also provides group based authorization, where users can be assigned to groups, which have configured levels of authorization, in addition to authorizing specific users. Based on the group the user belongs to, the components in the Configuration Screen is enabled or disabled. To use the security feature with this tutorial application, views and operations needs to be added to the database tables. Using Eclipse Plugin to Configure Security features Security configuration used in this application was achieved using Security Administration tool bundled in the AdventNet Web NMS. You can add or edit the operations node or modify the existing node as per your requirement using the Security Administration screen, which is invoked from the menu bar. Also you can assign permission to operations for various users. Compile the project successfully then it is necessary to bundle all the modified application and files of your project into a single file called a NAR. This can be done by Packing the Project. To Package the Project , refer to the section Packaging the Project in Eclipse Guide for more details. To view the changes in Web NMS, the NAR should be installed over Web NMS. This task can be performed using the Nar Installer present in the Deployment Wizard. You can invoke the Deployment Wizard by using the WebNMS > Tools > Deployment Wizard menu. For more details , refer to Installing Eclipse Project in Web NMS section in the Eclipse Guide. Before Deploying the NAR, Invoke the Security Administration Tool from Web NMS Installation. For details of working with Security Administration tool of AdventNet Web NMS, refer to the WebNMS Developer Guide. Using the Security Administration screen, operations nodes can be added to the Operations tree. For adding operations nodes to the Operations tree In the pop-up Operation Tree configuration screen

• Under the Operation Tree Root node the Ems Operations node was added and under the Ems Operations node the three nodes Ems Configure All, Ems Configure Scalar, and Ems Configure None were added.

Using the Security Administration screen, operations can be assigned to users. For assigning an Operation to a user at design time. In the Assign Permissions screen, you will see Permissions tree hierarchy.

• In the Ems Operations tree under the Operation Tree Root node, un-select the Ems Configure All operation and select the Ems Configure None.

Page 136: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 135

The operations assigned to various users are as follows:

User Operation root Ems Configure All guest Ems Configure Scalar

-- Ems Configure None

So far it has been explained how to carry out the security configuration through a tool in the AdventNet Web NMS. Basically, the two default users (root and guest) are used to demonstrate this feature. The first user root belonging to the Admin group to which the Ems Configure All operation is assigned, allows the user to configure all the parameters of the switch. The Configure button remains enabled for this user. The second user guest belonging to the Users group to which the Ems Configure Scalar operation is assigned, allows the user only to configure the scalar parameters of the switch. The Configure button remains enabled, but the second and the third tab is removed from the UI. The screen shot below show the configuration UI when the Ems Configure Scalar operation is assigned to a user. i.e., The user is authorized to configure only the scalar parameters of the switch.

Login to the Application Client with root or guest to see the difference in the Switch Configuration Screen.

Page 137: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 136

5.9.1 Using Authorization Service to implement Security

Aim Every EMS application should have Authorization Services enabled to distinguish among users. This section will guide you to create Groups and Users, to enable authorization and to authenticate permissions levels for the Users. Instructions Follow the steps given below to assign Groups and Permissions for effective security Administration

Step 1: Invoking the Security Administrator Tool

Security Administration features have to be configured using Security Administrator Tool bundled in WebNMS installation. Before deploying the application NAR file in the WebNMS installation, Start the server using WebNMS > Launch > Start WebNMS Server menu. and Start the client using WebNMS > Launch > Start WebNMS Client menu. In the Client Screen , Click Tools-> Security Administration. Security Administration Dialog Box is opened.

Step 2: Adding Groups and Permissions

• Expand the Groups node in the tree

• Select Users and click the Add Operation Icon from the toolbar

• In the Operations screen, select the Operation Tree Root.

• Enter the name of the operation in the text field provided at the bottom. Say for Example 'EMS Operations'.

• Click Add. Scroll down the Operations tree to see the operation added. Select the new operation that is added and add the Permitted EMS Operations ( say for example Ems Configure All, Ems Configure Scalar) Click Add. Now Click OK.

• Now, in the Security Administration screen, click Set Permissions to see 'Assign Permissions' screen pop-up

• Scroll down this screen and check the corresponding box against the new operation added.

• Click Done.

Group Name and permissions granted are given below.

Group Name Permitted EMS Operations

Users Ems Configure All

Admin Ems Configure Scalar

Page 138: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 137

Step 3: Adding Users to the Group

Right- click the Users node and click Add Users. Provide the following information.

Groups Users Users root, guest Admin root

Result The EMS users are grouped and different authorization levels are created. The Authorization for operations is achieved for all the groups. The task that follows next is Re-branding.

Page 139: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 138

5.9.2 Customizing Configuration screen code to implement Security You need to add custom code in the Configuration management screen to cater for Security administration In the Configuration wizard, you will be creating the screens for configuring the Switches. In the SwitchConfiguration.java file of the EMS configuration project, accommodate the custom code in order to cater for Security administration. Details of the custom code When the switch configuration screen is invoked from the client, the checkUserOperations() method makes a RMI lookup to the AuthorizationEngineAPI for retrieving the operations for the logged-in user. Whenever a component in the UI is added, disabled or enabled, a check is made if the user logged in has the required permission to perform the operation. Based on the user operation, the component is enabled or disabled. You have to do this task while creating the Configuration Management screen as explained in the Appendix > Building Configuration Screen > Designing Main Screen topic of this document.

Page 140: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 139

5.10 Re-branding In building your EMS, you may wish to customize the basic user interface functions. Web NMS supports such customization for creating new products in multiple ways. To illustrate how this can be done, you will make a few changes to the user interface to build an EMS that we will call as Acme EMS. These are only a subset of the many changes that can be made to the user interface for specific applications. Aim This section details on how to Rebrand the application built to suit the customers requirements. Rebranding includes changing the name of the product its version, splash images, logo images etc. Rebranding can be achieved using the Rebranding tool. For details on Rebranding the Project, refer to the Web NMS Developer Guide.. Instructions Follow the steps given below to Rebrand the EMS.

Step: Invoke the Rebranding tool

Changing the Company details, Product details, Icons, and Images. Package the application as a NAR file and deploy in WebNMS installation.

o To do Rebranding, invoke <Web NMS Home>\bin\developertools>startRebrandingTool.bat

o Change the values of the rebrandable entities as given in the table below:

Entity Name Values

Company Name Acme Product Name EMS Version 1.1 Company URL www.acme.com Motto Acme : Excellence Matters Copyright 2003 - 2004 Splash Image Select the image file of your choice Frame Icon Select the image file of your choice Product Logo Select the image file of your choice About Dialog Image Select the image file of your choice Contact Address Enter the contact address of your company Language en Country US

o Click on Rebrand button to carryout Rebranding and the Close button to close the screen.

Result The AdventNet Web NMS is rebranded as Acme EMS.

Page 141: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 140

6. Fast Track Implementation This topic will guide you, if you want to try quick modifications in the available project and check the results. It will also guide you through shortcut to the tutorial, if you are unable to complete the Tutorial Project. Successful completion of Project After the building of application is complete, compile the project and package it as a NAR file. If you are able to create the NAR successfully then skip this topic. Try your requirements quickly in the Project If you want to try your requirements in the EMS project on your own efforts, then you can use the project which is bundled in AdventNet Web NMS installation. The created EMS project is available in Web NMS Home in the following URL : <Web NMS Home>/StudioTools/Studio/projects/EMS_Tutorial

Note: It is mandatory to change the WebNMS Home with respect to your Web NMS Installation using the WebNMS ->Project Properties menu in Eclipse IDE before proceeding with development in this EMS_Tutorial project.

How to open EMS project in Eclipse and work with it ?

• Open Eclipse IDE, please use File->Import menu. In the wizard, select General->Existing Projects into Workspace and click Next.

• Click "Browse" button and Select root directory as <NMS Home>/StudioTools/Studio/projects/EMS_Tutorial. Now select the EMS project that is listed in the text area.

• Click Finish button. This opens the EMS project in the workspace. Next, Select WebNMS ->Project Properties menu item and Change the WebNMS Home with respect to your Web NMS Installation. Click OK. Now it is possible to work with the EMS project.

Page 142: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 141

7. Deployment and Testing

7.1 Installation Notes This application is bundled along with Web NMS 5. You can also download this tutorial from the AdventNet web site. Please use the following URL to download the tutorial:

http://www.adventnet.com/products/webnms/tutorials/ems_tutorial.zip If you are using the downloaded tutorial from the web site, then extract the tutorial under <Web NMS HOME> directory. Creating User and Group The Security related configurations have to be done before deploying the Nar. That is User/Group should be created before installing the NAR. Refer the section Using Authorization Service for more details. Installing the Application To install the tutorial application,

• Stop the Web NMS Server if it is running (double-click Shutdown NMS Server icon from the Web NMS Launcher or invoke ShutDown.bat/sh from <Web NMS Home>bin directory

• Run DeploymentWizard.bat/.sh file under <Web NMS HOME>/bin /developertools directory.

• Select the NarInstall/Uninstall tab.

• Select the Install button in the screen.

• Click the Browse button in the NAR INSTALLER pop-up screen.

• Select the tutorials/ems_tutorial/EMS_Tutorial1.0.nar from the File Chooser pop-up screen and click the Select button.

• Click the OK button in the NAR INSTALLER pop-up screen.

• On clicking OK button, NmsPwsNarInstaller screen will pop-up.

• Check the ReadMe for more details about the nar.

• Click the Next button.

• In the final screen , click Install button.

• This will install and show the status in the progress bar. See that the progress is 100%.

• Click the Close button.

• Now the installation is complete. Three entries will be listed in the Uninstall section of the Deployment Tool. The entries are EMS_Tutorial1.0.nar, ChassisScreen and SwitchConfiguration.

• Click the Exit button to quit the Deployment Wizard.

• Reinitialize Web NMS using reinitialize_nms.bat/.sh under <Web NMS Home>/bin directory. Both, the data and configuration are reinitialized.

Caution: This tutorial will function only if Web NMS is reinitialized. Hence, after installing the tutorial, reinitialize Web NMS. Ensure you use separate Web NMS installation for tutorial application development and installation. Do not experiment on Web NMS deployed in real world.

Page 143: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 142

When this tutorial application is installed, the existing files which require changes, from the installed Web NMS are backed up. However, when you un-install this tutorial application, the files modified will be restored from the backup. Uninstalling the Application To uninstall the tutorial application,

• Run the DeploymentWizard.bat/.sh file under <Web NMS HOME>/bin/developertools directory.

• Select the NarInstall/Uninstall tab.

• In the Uninstall section, select the EMS_Tutorial1.0.nar entry

• Click Uninstall button in the screen.

• On clicking Uninstall button, NmsPwsNarUninstaller screen will pop-up.

• In that, click Uninstall button.

• This will uninstall and show the status in the progress bar. See that the progress is 100%.

• Click Close button. All the three entries pertaining to the Nar will be removed. Now the uninstallation is complete.

• Click Exit button to quit the Deployment Wizard.

Note: To install the NAR created by you, select EMS_User1.0.nar

Modifying the Application If you want to modify the application and try out other features, you can edit the EMS project of this application bundled with this tutorial. To modify,

• Use File -> Import to invoke Import Wizard in Eclipse then select Import Existing Project option in the tree.

• Check the "Project from file system" option and browse and give the root directory of the project as <Web NMS HOME>/StudioTools/Studio/projects/EMS_Tutorial directory.

• Make the changes (supported by the AdventNet Web NMS EclipsePlugin) to the project as per your requirement.

• Save, compile, and package the project into NAR.

• Un-install the existing installed NAR and install the new NAR generated with your changes.

Caution: Un-installing the original NAR is mandatory as only one Eclipse NAR is permitted to be deployed in AdventNet Web NMS.

For complete details on Working with EclipsePlugin, refer to the Web NMS EclipsePlugin Guide.

Page 144: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 143

7.2 Testing the Application After installing the tutorial application reinitialize and start the Web NMS server. This tutorial application treats the first five SNMP nodes that are discovered as switches and for each switch the corresponding shelves, slots, cards and ports are added so as to bring out a real time scenario. Ensure you have at least one IP node supporting SNMP on your network or on a remote network that you can add to the Web NMS. Once the server is up and running, start the Java client by executing the startApplicationCliet.bat/.sh file. General testing

• In the client, In addition to the ipnet and all other nodes, Switches node also get appears in this tutorial application.

• Check whether switches map has been created and also see whether the first five switches are seen in the map with their interconnections.

• In the switch chassis view (i.e., the tree node name ending with _view), see whether all the components of the switch are seen. There should be empty cards in the alternate slots and in each active card there will be a trunk port or four access ports depending on the type of the card.

• Try to update the status of the ports and see whether corresponding events are generated in the events node.

• The splash screen that comes up with the progress bar at the bottom will now show Acme Element Manager instead of the default splash screen.

• Wherever the name AdventNet appears in the client, it will now be seen as Acme. ( Note: If Rebranding was done, the rebranded image will be displayed. Else the default WebNMS 5 Splash Image, Logo will be displayed. Refer the Rebranding section for more details.)

Testing Transaction control To test Transactions, use a database, which supports transactions like Oracle. Detailed instructions to set up the database can be found in the Installation Guide/ Installation and Setup Options/ Database Set Up page.

• Open the project's EMS_Tutorial from the <Web NMS HOME>/tutorials/ems_tutorial directory, in the AdventNet Web NMS Eclipse Plugin.

• Modify the tutorial application with below given changes. To test rollback insert the following code snippet if (switch_count > 3 ) {

System.out.println(" Throwing Exception for " + trunk.getName()); throw new Exception();

}

anywhere between the following lines in SwitchDiscoveryFilter.java to throw exception after three nodes get discovered, so that addition of trunks to database is rolled back for switch 4 and 5. api.addObject(trunk); api.updateObject(srcport,false,false); api.updateObject(destport,false,false);

Page 145: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 144

• Compile the project and package into a NAR.

• Stop the Web NMS server, if running.

• Uninstall the tutorial application NAR.

• Install the tutorial application NAR generated with the above changes.

• Reinitialize Web NMS and start the Web NMS server again. Once the server is up and running, start the Java client. Check for expected behaviour that is the trunks will not be present for switch 4 and 5 as they would be rolled back. The same can also be verified in the database. You can also use the HTML client for this application. Testing Security Administration Using the Security Administration screen, the users can be configured to belong to other groups and the effect can be seen in the Switch Configuration screen. Steps to be followed for unassigning an Operation to a user at runtime.

• Invoke the Security Administration screen from the tools menu of Web NMS client.

• Select the Users -> root node from the Security tree.

• Select the Permitted Operations for User tab.

• Click Set Permissions button.

• In the Assign Permissions screen, you will see Permissions tree hierarchy.

• In the Ems Operations tree under the Operation Tree Root node, un-select the Ems Configure All operation and select the Ems Configure None.

When the above operation is performed, the configuration UI appears with the Configure button disabled. i.e., not allowing the user to configure any of the switch parameters, but only viewing them.

Page 146: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 145

8. How does the application work? Interaction Diagram for EMS Tutorial This section outlines the various tasks development of an EMS. The focus is towards examining and understanding the roles of the main Web NMS components and the control/data flows among them. Discovery This diagram shows the interaction and message flow among Web NMS components while processing a newly discovered network element (device).

The Discovery engine of Web NMS does the following operations

1. On first run, it reads and creates default map(s) listed in maps.conf file.

2. It reads the discovery rules: e.g., Discover Local Network (at which Web NMS is attached), Enable SNMP Discovery, Enable ICMP Discovery, Inter-Discovery delay/gap (in Sec), Re-discovery Interval, List of Network, To Discover (including DHCP, IP address range), etc. From this, it identifies the Networks to be discovered. Active discovery is launched for the identified networks, as a parallel task. It then sweeps or enumerates each IP, for the networks identified. It also maintains a list of IP that are possibly active, obtained from seed.file and tl1seed.file entries, ARP table and SNMP/ICMP broadcast.

Page 147: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 146

3. To confirm the existence of the IP or nodes, performs test viz., user-defined test and SNMP/TL1/ICMP ping process. When the whole address range is swept for the networks identified, the discovery engine schedules the rediscovery process.

4. It locates the user-defined discovery filter class from oidtype.data or discovery.filters file. The custom filter is searched in oidtype.data followed by discovery.filters. The device(sysOID)-specific filters are contained in the oidtype.data file, whereas general filters are specified in the discovery.filters file.

5. It then creates a ManagedObject (via TopoAPI) which models the discovered device. It invokes filterObject() method of the custom discovery filter for the discovered device type. General filters are invoked (in sequence as listed in discovery.filters) for every device that has been discovered.

6. Using these filters, the Managed Object properties can be modified, new ones can be added, and existing ones can be deleted before adding the Object to the database.

7. The discovery engine then adds the nodes (objects) into the topology database after carrying out the above operations. The custom discovery filter calls TopoAPI.addObject() method for Topology Module to add the ManagedObject into TopoDB.

8. If a user tester class has been specified in oidtype.data for this device type, Topology Module registers the tester with Polling Engine so that it (tester) will be invoked in poll interval (also defined in oidtype.data) for status poll.

9. Map Server is registered as an observer of the Topology Module. The topology module notifies Map Server whenever a ManagedObject gets added for the newly discovered device.

10. Map Server locates the custom map filter for the device type from mapicon.data. General map filters from map.filters are invoked in sequence once the device-specific filter completes execution.

11. Map Server invokes filterMapSymbol() method of the map filter found at Step 10 and passes the ManagedObject.

12. The custom map filter creates map symbol(s) (and link(s) if necessary) for the discovered device. A new map can also be created by the filter.

13. Map Server receives the map symbol(s) (and possibly a new map) from the map filter and saves them into MapDB.

14. Map Server invokes the map renderer to display the symbols on the map panel of the Client.

Topology Update This diagram shows the interaction and message flow among Web NMS components when the topology database is updated for any changes in an existing ManagedObject. MO update/delete can be triggered from Client GUI (via Map menus), Trap/event filters and status polls (escalating severity), Policy Engine (deleting orphan objects), or configuration change (via Client).

Page 148: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 147

1. At periodic intervals based on the configured Status Poll interval, Polling Engine invokes test() method of the registered custom poll class (see Step 8 in the Discovery Process above).

2. The default / user defined Tester class performs status checks on the target device and returns an appropriate Severity level (defined in severityinfo.conf).

3. Polling Engine invokes TopoAPI.updateStatus() method if the severity level returned by test() method is different from the current level of the managed object. Topology Module, in turn, updates the managed object in the TopoDB and notifies Map Server for map update (Step 9).

4. User sets configuration parameter(s) for a selected device from Client GUI. Client sends the set request (in XML format) to Config Server.

5. Config Server parses the XML message and performs SNMP SET for requested config parameter(s). If one or more parameters correspond to property(ies) of the managed object in TopoDB, Config Server invokes TopoAPI.updateStatus() method. Topology Module, in turn, updates the managed object in the TopoDB and notifies Map Server for map update (Step 9).

6. For an incoming trap, Event Server searches (based on trapID) for the corresponding filter class in trap.filters and invokes applyTrapFilter() method for processing.

Page 149: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 148

7. The trap filter calls TopoAPI.updateStatus() if ManagedObject’s status (i.e., severity) needs to be escalated or downgraded, updateObject() if one or more properties are to be changed, or deleteObject() if one or more ManagedObjects are to be deleted (due to removed devices). Topology Module, in turn, updates the managed object in the TopoDB and notifies Map Server for map update (Step 9).

8. Policy Engine invokes a custom Policy Class, if provided, to delete orphan object(s) based on its rule (such as special severity level).

9. After updating the database, Topology Module notifies Map Server. The notification includes the type of change such as deleted (MO removal), manage (MO managed property), status (MO severity), property (other MO properties).

10. Map Server locates the custom map filter for the given device type from mapIcon.data. General map filters from map.filters are invoked in sequence once the device-specific filter completes execution.

11. Map Server invokes update() method and passes the ManagedObject along with update type (“update”/”delete”).

12. The Map Filter walks through all map symbols associated with the ManagedObject and changes the properties of each map symbol (if required). It calls MapAPI.updateSymbol() for Map Server to update MapDB.

13. Map Server invokes renderer to update the map display on Client.

Page 150: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 149

9. Known Issues • When this application is installed, it replaces some of the existing conf files with the new ones

needed for this tutorial. If the user has made any changes in the already existing filters, then the changes will not take effect during the tutorial session. Though all the original conf files will be restored once the tutorial is uninstalled.

Page 151: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 150

10. Trouble Shooting Tips

Problem Solution

Switch are not laid out properly in the Switches map.

The custom layout properties may not have been set. Check the layout of the switches map from the properties.

The device is not discovered as Switch.

Check if the EMS Tutorial NAR is installed.

Unable to configure the Switch. Getting message "There is no such variable name in the MIB" in the Logs Dialog.

Check if the SNMP Agent Simulator is running with the appropriate Configuration file.

Unable to configure the switch. Getting error message "Request Timed Out" in the Logs Dialog.

Check if the SNMP Agent Simulator is running.

In the "Switch Configuration", unable to configure Variables in Port Parameters Table.

Check if the SNMP Agent Simulator is running with the appropriate Configuration file. Ensure that the Enter key is pressed after entering values in the Port Parameters Table of Switch Configuration. Also ensure that the "Configure" button is pressed before the next polling as the polling is very fast.

The "java.lang.NoClassDefFoundError: org/apache/xalan/serialize/SerializerToXML" exception can occur when classes from the ManagementServer.jar and NmsServerClasses.jar were not present in the classpath while starting the server.

To overcome this exception, it is necessary to add the following jar files in startApplicationClient.sh/bat 1. ManagementServer.jar 2. NmsServerClasses.jar

The " java.lang.ClassNotFoundException" can occur while starting the client. This exception occurs when classes from the crimson.jar, jaxp.jar and xalan.jar were not present in the classpath.

To overcome this exception, please follow the endorsed mechanism as per steps given below: 1. Copy xalan.jar, crimson.jar, and jaxp.jar (from earlier version of JDK say 1.4) to a folder, for example \"endorsed_nms\" under <Web NMS Home>/classes folder. 2. In the <WebNMS Home>/setEnv.bat/sh file, add the below content. -Djava.endorsed.dirs=%WEBNMSHOME%\\classes\\endorsed_nms 3. Now in the server startup script (<WebNMSHome>/bin/startnms.bat/sh) use the following line for invoking the startup class. %JAVA_HOME%\\bin\\java -Xmx200M -Djava.endorsed.dirs=%WEBNMSHOME%\\classes\\endorsed_nms 4. Now start the client and try connecting to the server.

Page 152: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 151

Problem Solution

Scenario 1 : javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:\C:\Program%20Files\AdventNet\WebNMS\NetMonitor\build\uninstall.xml (The filename, directory name, or volume label syntax is incorrect) at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler (TransformerIdentityImpl.java:260) at org.apache.xalan.transformer.TransformerIdentityImpl.transform (TransformerIdentityImpl.java:291) Scenario 2 : java.net.MalformedURLException: unknown protocol: c These above two exceptions occurs when there is a space in the directory path where WebNMS is installed and trying to install a NAR file in WebNMS. This is a JDK bug which occurs in some scenarios where Xalan parsing of XML file is done.

Kindly install the WebNMS in a directory which does not have space characters in its path.

Page 153: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 152

11. Glossary This glossary list contains some of the definitions for the terms that are used in this tutorial. Click here to see the complete AdventNet Web NMS Glossary List. Switch In networks, a device that filters and forwards packets between LAN segments. Switches operate at the data link layer (layer 2) of the OSI Reference Model and therefore support any packet protocol.

Slot An opening in a switch where you can insert printed cards.

Card

A printed circuit board that you can insert into a slot to give it added capabilities.

Access Port This port is the physical gateway between a customer's local loop and the frame relay network.

Trunk Port An input on a PABX (Private Automatic Battery Exchange) or KSU (Key Service Unit) that is used to interface the system with C.O. (Central Office) lines.

Trunk A telephone communication path or channel between two points, one usually being a Central Office.

KSU A central control cabinet serving many multi-button key telephones. Contains equipment which enables the user to pick up and hold PABX or Central Office lines and provide flashing line, steady, busy and wink hold signals. Dial intercom service is also an option.

C.O./CO A main telephone office where switching equipment is housed and customer lines originate. Also contains trunk line connections to other Central Offices. FAQ The list of Frequently Asked Questions (FAQ) which serves as a guide to understand the AdventNet Web NMS. To see the Web NMS FAQ click the following link Web NMS FAQ - These contains questions that will arise in the minds of a Web NMS user.

Page 154: Ems Tutorial

AdventNet WebNMS 5 :: EMS Tutorial

AdventNet, Inc. 153

12. Other Tutorials AdventNet Web NMS is vast in its capability to serve its different class of users. It would be hard for anyone to understand all of its features at one time. We strongly recommend you to go through of our EBon tutorial to get of feel of what could be done on our Web NMS. EBon Tutorial This tutorial explains how developer can build Element Management Systems to manage DSLAM devices which support SNMP. The tutorial will walk through a series of steps, which will help you understand how a unique EMS solution can be built using AdventNet Web NMS EclipsePlugin to suit your needs.