|
The Provisioning API provides methods through which the clients can access the provisioning templates for performing specific provisioning operations.
Getting the Handle of Provisioning API
The Provisioning API handle can be accessed using either RMI/Session/JMS. Based on the access mode (RMI/Session/JMS), you need to configure the server-side/client-side parameters.
Accessing ProvisioningAPI Using RMI
To access the Provisioning API using RMI, just call the ProvClientUtils.getProvisioningAPI(Properties prop). The code snippet to get the handle of ProvisioningAPI using RMI is given below. Please refer to the javadocs of ProvClientUtils.getProvisioningAPI(Properties prop), for the method and property details.
Code Snippet to get the handle using RMI
|
import com.adventnet.nms.provisioning.ProvisioningAPI; import java.rmi.Naming;
public class gettinghandle { public static void main(String a[]) { gethandle(); } public static void gethandle() { Properties prop = new properties(); prop.put("MODE", "RMI"); prop.put("USERNAME", "root"); prop.put("PASSWORD", "public"); prop.put("SERVERNAME", "localhost"); prop.put("SERVERPORT", "1099"); try { ProvisioningAPI provapi = ProvClientUtils.getProvisioningAPI(prop); } catch (Exception e) { System.out.println("Exception got while accessing ProvisioningAPI"); e.printStackTrace(); } } } |
Accessing ProvisioningAPI Using Session
To access the Provisioning API using Session, just call the ProvClientUtils.getProvisioningAPI(Properties prop). The code snippet to get the handle of ProvisioningAPI using Session is given below. Please refer to the javadocs of ProvClientUtils.getProvisioningAPI(Properties prop), for the method and property details.
Code Snippet to get the handle using Session
|
import com.adventnet.nms.provisioning.ProvisioningAPI; import java.rmi.Naming;
public class gettinghandle { public static void main(String a[]) { gethandle(); } public static void gethandle() { Properties prop = new properties() ; prop.put("MODE", "SESSION"); prop.put("USERNAME", "root"); prop.put("PASSWORD", "public"); prop.put("SERVERNAME", "localhost"); prop.put("SERVERPORT", "9090"); try { ProvisioningAPI provapi = ProvClientUtils.getProvisioningAPI(prop); } catch (Exception e) { System.out.println("Exception got while accessing ProvisioningAPI"); e.printStackTrace(); } } } |
Accessing Provisioning API Using JMS
Any request made to access the Provisioning API using JMS is routed through the JMS server where the request is stored in the JMS Request Queue as JMS Request Message. The client connects to the JMS server by getting the handle of the Provisioning API using ProvClientUtils.getProvisioningAPI(Properties prop) which is explained below.
The FE server collects the JMS Request Message from the JMS server. It instantiates the proxy implementation instance corresponding to the requested ProvisioningAPI object. It calls the BE servers ProvisioningAPI object through the proxy implementation and sends the response to the client. The FE server connects to the JMS server by reading the JmsConfiguration.xml file in <Web NMS Home>/conf directory. The server-side and client-side settings to be done are as follows :
Server-side Parameter Settings
The server-side settings are done using the JmsConfiguration.xml file in <Web NMS Home>/conf directory. The parameters and their description are as follows :
| Parameter |
Description |
|---|---|
|
CONTEXT_FACTORY |
The class name with the complete package, specific to each JMS Provider. This is by default set to com.sun.enterprise.naming.SerialInitContextFactory. |
|
PROVIDER_URL |
The URL where the JMS Provider is located. This URL is specific to each Provider. |
|
requestQueue |
A unique location name, where the client request needs to be stored. If not specified, taken as "requestQueue". |
|
responseQueue |
A unique location name, where the response sent by the server needs to be stored. If not specified, taken as "responseQueue". |
|
QueueConnectionFactory |
The database name, which maps to the number of connections to be used. This name is also specific to the Provider used. The default value is "QueueConnectionFactory". |
Client-side Parameter Settings
The client-side settings are done by getting the handle of the ProvisioningAPI using ProvClientUtils.getProvisioningAPI(Properties prop), where the arguments are as follows :
| Argument |
Description |
|---|---|
|
MODE |
Specify the communication mode (RMI|JMS|SESSION). If the mode is other than the supported mode, it throws IllegalArgumentException. |
|
USERNAME |
The user name used to authenticate the user logging into the client. |
|
PASSWORD |
The password used to authorize the user logging into the client. |
|
SERVERNAME |
Host to which the Client is to be connected. Default value is "localhost" |
|
SERVERPORT |
Port number where the server is running. In RMI mode, the default value is "1099".In SESSION mode, the default value is "9090". |
Code Snippet to Get the Handle Using JMS
|
import com.adventnet.nms.provisioning.ProvisioningAPI; import java.rmi.Naming;
public class gettinghandle { public static void main(String a[]) { gethandle(); } public static void gethandle() { Properties prop = new properties() ; prop.put("MODE", "JMS"); prop.put("USERNAME", "root"); prop.put("PASSWORD", "public"); //Other JMS specific properites need to be given to connect to the JMS Server try { ProvisioningAPI provapi = ProvClientUtils.getProvisioningAPI(prop); } catch (Exception e) { System.out.println("Exception got while accessing ProvisioningAPI"); e.printStackTrace(); } } } |
Methods Available in ProvisioningAPI
The methods provided in the ProvisioningAPI are as follows :
|
Method |
Description |
|---|---|
|
public ProvisioningAPI getExtensionAPI(String apiName) |
To fetch an available Provisioning API extension by name. Please refer the topic "Writing Provisioning Extensions", for details. |
|
public java.lang.String getResult(String operationIdentifier) |
To get the result of an outstanding operation. |
|
public java.lang.String getStatus(String operationIdentifier) |
To get the status of an outstanding operation. |
|
public java.lang.String getTemplate(String templateName) |
To get a provisioning template from server by name. |
|
public java.lang.String getTemplate(String templateName, String templateParams) |
To get a provisioning template given the name and the template parameters |
|
public java.lang.String getTemplate(String path, String templateName, String templateParams) |
To get a provisioning template given the template path (relative to <Web NMS Home>/provisioningtemplates), name and the template parameters |
|
public java.lang.String[] getTemplateList() |
To get the list of provisioning templates configured on the server. |
|
public java.lang.String[] getTemplateList(String path) |
To get the list of provisioning templates present in the given path (relative to <Web NMS Home>/provisioningtemplates) |
|
public java.lang.String getTemplateParameters(String templateName) |
To get the provisioning template input parameters, which may be needed for initial population of the template. |
|
public java.lang.String getTemplateParameters(String path, String templateName) |
To get the template input parameters of the provisioning template present in the specified path (relative to <Web NMS Home>/provisioningtemplates) |
|
public java.lang.String provision(String template) |
To execute the specified template. |
|
public String getProvisionResultStatus(long prId) |
Returns the status of the given Provision Result ID |
|
public String getProvsionResultDetails(long prId) |
Returns the details of the given Provision Result ID |
|
public void updateStatus(long prId, String status) |
Updates the status of Provision Result |
|
public void updateDetails(long prId, String details) |
Updates the details of Provision Result |
|
public void updateStatusAndDetails(long prId, String status,String details) |
Updates the details and status of the Provision Result |
|
public void cancelExecution(long prId) |
Cancels the template execution given the ProvisionResult ID |
|
public void deleteProvisionResult(long prId) |
Deletes the Provision Result if the status of the specified prId is not INPROGRESS ,WAITING, or SCHEDULED |
|
public void deleteProvisionResult(long prId, boolean forcefulDelete) |
Deletes the Provision Result irrespective of the status of the specified prId |
|
public Properties getUserIputs(long prId) |
To get all the inputs provided to the template for execution (of the given ProvisionResult ID) |
|
public void setUserIputs(long prId, String templateName, Properties userInputs) |
To set the user input properties for the given ProvisionResult Id and template |
|
public boolean registerScheduledInfoListener(ScheduledInfoListener sil) |
To register a class (that implements the ScheduledInfoListener interface) as a ScheduledInfo listener |
|
public void enableScheduledInfo(long id) |
To enable a scheduled template, that has been disabled before, for future execution. The argument is the ScheduledInfo ID |
|
public Hashtable getAllScheduledInfo() |
To retrieve all the ScheduledInfo details. ScheduledInfo Id will be the key and the corresponding ScheduledInfo will be the value in the returned hash table |
|
public void modifyScheduledInfo(long id,String key,String value) |
To modify a single property of ScheduledInfo object |
|
public void modifyScheduledInfo(long id, Properties prop) |
To modify the properties of the ScheduledInfo object |
|
public void disableScheduledInfo(long id) |
To disable a scheduled template, given the ScheduledInfo ID |
|
public void deleteScheduledInfo(long id) |
To delete the ScheduledInfo object thereby canceling/terminating the execution of the template |
|
public boolean deRegisterScheduledInfoListener(ScheduledInfoListener sil) |
To de-register a ScheduledInfo listener |
Please refer to the Javadocs of ProvisioningAPI for detailed information on these methods.
Synchronized and Asynchronized Provisioning
The method provision(String) performs asynchronous provisioning, when the template executed contains "when" attribute. If the executed template does not contain the "when", then the method provision(String) performs synchronized provisioning. Asynchronous provisioning will free the thread and the process will be done at the background. A request ID is given to the client and the status, and the final result of the execution will be provided when requested for that particular ID. The status of the operation can be verified using the methods getStatus() and getResult() methods.
In synchronous provisioning, the thread waits till the provisioning operation is completed and returns the result.
|