Sample SMI-S Java Client

This chapter describes the Sample SMI-S java client developed using JSR 48 specifications. JSR 48 is a set of java WBEM Service APIs and reference implementation for WBEM. WBEM is an initiative from the DMTF that unifies systems management and instrumentation.

The SMI-S java client uses the client and listener packages provided by the JSR 48 specifications, which consists of classes and interfaces for developing WBEM Clients and WBEM Event Listeners. The WBEMClient interface in the client package is used to invoke WBEM operations against a WBEM Server. A WBEMClient implementation can be retrieved from the WBEMClientFactory by specifying the protocol to be used. IndicationListener is implemented by the code that wants to create a listener for indications. The WBEMListener interface is used to add or remove WBEM Indication Listeners.

The SMI-S java client uses the Cisco DCNM SMI-S external agent for managing and monitoring Cisco DCNM for SAN.

You can perform the following tasks from the services provided by the SMI-S client tool:

– Obtain VSANs using enumerateInstanceNames API in WBEMClient.

– Obtain Zonesets, Zones, and Zonemembers using associatorInstances API in WBEMClient on VSAN.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get zonesets in selected VSAN using associatorInstances.

– Get zones in selected zoneset.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get Zones in selected VSAN using associatorInstances.

– Get Zonemembers in selected zone.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get Zoneservice of the selected VSAN using associatorInstances.

– Invoke the method createzoneset in Zoneservice class with zoneset and zone name.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get Zoneservice of the selected VSAN using associatorInstances.

– Invoke the method addzone in Zoneservice class with existing zoneset and zone information.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get Zoneservice of the selected VSAN using associatorInstances.

– Invoke the method CreateZoneMembershipSettingData in Zoneservice class with existing zone and new zonemember information.

– Get VSANs using enumerateInstanceNames API in WBEMClient.

– Get Zoneservice of the selected VSAN using associatorInstances.

– Invoke the method ActivateZoneSet in Zoneservice class with existing zoneset for activation or deactivating the zoneset.

Installing Sample SMI-S Client


Note Cisco SMI-S Client is packaged with DCNM SMI-S Server.


When you choose Cisco DCNM with SMI-S Sever during installation, SMI-S Client is also available. For more information, see the “Installing Cisco DCNM SMI-S Server” section.

The following are the SMI-S Client installation locations:“Installing Cisco DCNM SMI-S Server” section

Services Provided by SMI-S Java Client

The following NMS services are supported:

Table 5-1 provides the details of the SMI-S java client services.

Table 5-1 Services Provided by SMI-S Java Client

Services Name
Description

List Switches

This service lists the VSANs present in the fabric. You need to select the VSAN to see the list of switches. The tool uses the enumerateInstances API in Interface WBEMClient.

List Hosts

This service lists the hosts present in the fabric and also lists the endports present in the host. The tool uses the enumerateInstances API in Interface WBEMClient and an associatorInstances to get the host associated to the end ports.

List Target

This service lists the targets present in the fabric and also lists the end ports present in the target. The tool uses the enumerateInstances API in Interface WBEMClient and an associatorInstances to get the target associated to the end ports.

List VSANs in Fabric

This service lists all of the VSANs present in the fabric and their properties. For example, the status, WWN, VSAN ID, and temporary name of the VSAN. The tool uses the enumerateInstances API in the Interface WBEMClient.

List Switches in the VSAN

This service lists all the VSANs that are up and active in the fabric. Once you select it, the logical computer systems (logical switches) present in that VSAN are displayed. It also gives information of the physical switch each logical switch is hosted on.

Enumerate the Names of any CIM Class

This option allows you to select a CIM class of your choice to view CIMObjectPath names for a specified CIM class.

Enumerate the Instance of any CIM Class

This option allows you to select a CIM class of your choice to view instances of a specified CIM class.

Execute Zone Operations

This option lists the bunch of zone services supported by the Cisco SMI-S client tool.

Subscription of the Event Listener

Examples of Developing SMI-S Client Using WBEM Solutions

// get wbem client obj with specified protocol
WBEMClient wbclient = WBEMClientFactory.getClient("CIM-XML");
CloseableIterator<CIMObjectPath> an =null;
try{
an = wbclient.associatorNames(cimop,null, resultClass, null, null);
} catch (WBEMException e) {
System.out.println(e);
}

 

//get the WBEMListener from the WBEMListenerFactory
WBEMListener listnr = WBEMListenerFactory.getListener("CIM-XML");
//add the listener to the port. use 0 to specify any available port
Int port = api.addListener(cl,0, "http");
// get wbem client obj with specified protocol
WBEMClient wbclient = WBEMClientFactory.getClient("CIM-XML");
//create the filter
String filter ="SELECT SELECT * from CIM_InstIndication WHERE sourceInstance ISA CISCO_PhysicalComputerSystem";
CIMObjectPath op = new CIMObjectPath("CIM_IndicationFilter", namespace);
CIMClass filterClass = client.getClass(op, false, true, false, null);
CIMInstance filterInstance = filterClass.newInstance();
CIMProperty<?>[] fcpArray = {
new CIMProperty<String>("Query", CIMDataType.STRING_T, filter, false, false, null),
new CIMProperty<String>("QueryLanguage", CIMDataType.STRING_T, "WQL", false, false, null) };
filterInstance = filterInstance.deriveInstance(fcpArray);
CIMObjectPath filterOP = client.createInstance(filterInstance);
 
//create the listener
CIMObjectPath op = new CIMObjectPath("CIM_ListenerDestinationCIMXML", namespace);
CIMProperty<?>[] cpa = { new CIMProperty<String>("Destination",
CIMDataType.STRING_T, "http://" + systemName + ":"+ port +"/", false, false, null) };
 
// create new instance of listener
CIMInstance listenerInstance = new CIMInstance(op, cpa);
CIMObjectPath listenerOP = client.createInstance(listenerInstance);
//create a subscription, an association between the filter and listener.
CIMProperty<?>[] sicpArray = {
new CIMProperty<CIMObjectPath>("Filter", new CIMDataType(
filterOP.getObjectName()), filterOP, true, false, null),
new CIMProperty<CIMObjectPath>("Handler", new CIMDataType(
listenerOP.getObjectName()), listenerOP, true, false, null) };
CIMInstance subscriptionInstance = new CIMInstance(
new CIMObjectPath("CIM_IndicationSubscription", namespace, sicpArray), sicpArray);
try {
CIMObjectPath subscriptionOP = client.createInstance(subscriptionInstance);
} catch (WBEMException e) {
throw e;
}