|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.management.config.DataSourceGenerator
public class DataSourceGenerator
This class provides methods for generating DataSource in XML Format.
This DataSource XML provides various resources for gathering data
which is populated to the template for configuration. DataSource supports
data gathering from Inventory, NetworkElement and User.
By default, inventory maintained by the Web NMS will be used for providing
the inventory inputs. This can be overridden by specifying the class
implementing the com.adventnet.management.config.InventoryHandler
in NmsProcessesBE.conf file. Now this class becomes the
default class for handling InventoryInputs defined in various DataSources.
Also, InventoryHandler can be specified at the DataSource level.
If any handler class is specified at the level of DataSource,
all the InventoryInputs defined in the DataSource will be handled
by this class instead of the default handler specified in
NmsProcessesBE.conf. In addition to this,
handlers can also be specified for each InventoryInput in the DataSource.
A sample code that generates DataSource XML.
DataSourceGenerator dsg = new DataSourceGenerator();$DataSourceParam$<id> indicates input values for the DataSource. Placeholders $DataSourceParam$MOName, $DataSourceParam$MOField, $DataSourceParam$NEName, $UserInput$NEName, $InventoryInput$port, $NEInput$location will be searched in the template for data population.
// Setting the associated task(s) for which this DataSource can be associated.
dsg.setAssociatedTasks( new String[]{"sampleTask"});
dsg.setDataSourceName("sampleDataSource");
// Adding an InventoryInput.
dsg.addInventoryInput("port", "$DataSourceParam$MOName", "$DataSourceParam$MOField", "161");
// Adding a UserInput.
dsg.addUserInput("NEName", "Device", "$DataSourceParam$NEName");
//Generating a task
TaskGenerator tg = new TaskGenerator();
tg.setTaskName("task1");
tg.setProtocol("snmp");
SnmpDevice device = new SnmpDevice("$UserInput$NEName", "$InventoryInput$port");
tg.setDevices( new SnmpDevice[]{device});
SnmpAttribute attr = new SnmpAttribute("1.6.0", "sysLocation", (byte)4, "");
tg.addAttribute(attr);
String taskXML = tg.getTask();
//Adding an NEInput
dsg.addNEInput("1", taskXML);
String dataSourceXML = dsg.getDataSource();
DataSource,
TaskGenerator| Constructor Summary | |
|---|---|
DataSourceGenerator()
Initilizes a XML Document for generating DataSource in XML format. |
|
DataSourceGenerator(DataSource dataSource)
Initializes the XML Document from the DataSource root element. |
|
| Method Summary | |
|---|---|
void |
addInventoryInput(java.lang.String id,
java.util.Properties prop)
Adds an InventoryInput for the DataSource. |
void |
addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField)
Adds an InventoryInput for the DataSource. |
void |
addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField,
java.lang.String defaultVal)
Adds an InventoryInput for the DataSource. |
void |
addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField,
java.lang.String defaultVal,
java.lang.String inventoryHandler)
Adds an InventoryInput for the DataSource. |
void |
addNEInput(java.lang.String id,
ConfigTask configTask)
Adds an NEInput to the DataSource. |
void |
addNEInput(java.lang.String id,
java.lang.String taskXML)
Adds an NEInput to the DataSource. |
void |
addUserInput(java.lang.String id,
java.util.Properties prop)
Adds a UserInput with properties like id,name,value etc. |
void |
addUserInput(java.lang.String id,
java.lang.String name,
java.lang.String value)
Adds a UserInput for the DataSource. |
java.lang.String |
getDataSource()
Returns DataSource String in XML Format |
org.w3c.dom.Element |
getElement()
Returns the root element for DataSource XML. |
void |
saveDataSource(java.lang.String fileName)
Saves the DataSource XML in the specified file. |
void |
setAssociatedTasks(java.lang.String[] taskNames)
Specifies the tasks for which this DataSource can be associated for execution. |
void |
setDataSourceName(java.lang.String dataSourceName)
Assigns a name for this DataSource. |
void |
setDataSourceProperties(java.util.Properties prop)
Specifies the properties for the DataSource. |
void |
setDescription(java.lang.String description)
Sets the description for the DataSource |
void |
setInventoryHandler(java.lang.String inventoryHandler)
Sets the inventory handler class for handling the InventoryInputs defined in the DataSource. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DataSourceGenerator()
throws InvalidTemplateException
InvalidTemplateException - if it fails to create an empty element.
public DataSourceGenerator(DataSource dataSource)
throws InvalidTemplateException
dataSource - the base from which dataSource XML is constructed.
InvalidTemplateException - if it fails to get the element.| Method Detail |
|---|
public void setInventoryHandler(java.lang.String inventoryHandler)
inventoryHandler - class name that implements InventoryHandler class.InventoryHandlerpublic void setAssociatedTasks(java.lang.String[] taskNames)
taskNames - an array of template based tasks.public void setDataSourceName(java.lang.String dataSourceName)
dataSourceName - a name for the dataSourcepublic void setDescription(java.lang.String description)
description - specifies the description for this DataSource.public void setDataSourceProperties(java.util.Properties prop)
prop - Contains attributes for this DataSource.public java.lang.String getDataSource()
public void addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField,
java.lang.String defaultVal)
InventoryHandler fails to retrieve the value from
the specified inventory, default value will be populated to the Template. The argument id should be unique
among the InventoryInputs defined in the DataSource.
id - a unique value that will be appended with $InventoryInput$ for replacing the placeholders present
in TemplatesmoName - Specifies the ManagedObject for getting the inventory values.moField - Specifies the name of the property to be fetched in the ManagedObject.defaultVal - defaultValue for this inventory.
public void addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField,
java.lang.String defaultVal,
java.lang.String inventoryHandler)
InventoryHandler fails to retrieve
the value from inventory, default value will be populated to the Template. The argument id should be unique
among the InventoryInputs defined in the DataSource.
id - a unique value that will be appended with $InventoryInput$ for replacing the placeholders present
in TemplatesmoName - Specifies the ManagedObject for getting the inventory values.moField - Specifies the name of the property to be fetched in the ManagedObject.defaultVal - defaultValue for this inventory.inventoryHandler - class name that handles this Inventory
public void addInventoryInput(java.lang.String id,
java.lang.String moName,
java.lang.String moField)
id - a unique value that will be appended with $InventoryInput$ for replacing the placeholders present
in TemplatesmoName - Specifies the ManagedObject for getting the inventory values.moField - Specifies the name of the property to be fetched in the ManagedObject.
public void addInventoryInput(java.lang.String id,
java.util.Properties prop)
id - a unique value that will be appended with $InventoryInput$ for replacing the placeholders present
in Templatesprop - contains attributes for this inventory.
public void addUserInput(java.lang.String id,
java.lang.String name,
java.lang.String value)
id - a unique value that will be appended with $UserInput$ for replacing the placeholders defined in templates.name - name of the UserInput.value - the value that need to be substituted for this UserInput
public void addUserInput(java.lang.String id,
java.util.Properties prop)
id - a unique value that will be appended with $UserInput$ for replacing the placeholders defined in templates.prop - contains UserInput attributes.
public void addNEInput(java.lang.String id,
ConfigTask configTask)
id - a unique value among the NEInputs.configTask - contains attributes for uploading configuration from the specified device.
public void addNEInput(java.lang.String id,
java.lang.String taskXML)
throws InvalidTemplateException
TaskGenerator.
Attribute's label will be appended (instead of id's value) to $NEInput$ for replacing
the placeholders defined in Templates. So attribute's label should be unique
among the attributes defined in the task.
id - a unique value among the NEInputs.taskXML - contains attributes for uploading configuration from the specified device.
InvalidTemplateException - if the template being passed is an invalid XML.public org.w3c.dom.Element getElement()
public void saveDataSource(java.lang.String fileName)
fileName - name of the file for storing the DataSource.
|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||