Software Defined Networking
1753826 Members
8585 Online
108805 Solutions
New Discussion

How to use HandlerFacet to get VLAN information

 
checho
Occasional Advisor

How to use HandlerFacet to get VLAN information

Hi community, 

While reading the programming guide (2.7) I found the example 12 (page 142) which show how to use handler facets to obtain information about VLAN. I have a couple of questions about that code:

 

	private Set<VlanInfo> getVlans(DeviceService ds, DeviceDriverService dds, DataPathId dpid) {
		Set<VlanInfo> vlans = new HashSet<VlanInfo>();
		try {
			// get the device object that has data path id (dpid)
			Device dev = ds.getDevice(dpid);
			// get the DeviceInfo object
			DeviceInfo di = dev.info();
			// create a Device Handler
			DeviceHandler dh = dds.create(di, getIp(di));
			// check if the Handler Facet is available for the device
			if (dh.isSupported(VlanHandler.class)) { 
				// use the Device Handler to get the Handler Facet
				VlanHandler hf = dh.getFacet(VlanHandler.class);  // the guide says VlanHanlderFacet.class
				// use the Handler Facet to get vlan information
				vlans = hf.getVlans();
			log.info("The VLANS: {} \n{} " + dpid + (vlans.toString()));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return vlans;
	}
	
		/**
		* Returns the IP address associated with the DeviceInfo object.
		*
		* @param di DeviceInfo object
		* @return IP address for the DeviceInfo object
		*/
		private IpAddress getIp(DeviceInfo di) { 
			DeviceIdentity facet = di.getFacet(com.hp.device.DeviceIdentity.class);
			return facet.getIpAddress();
		}

 

  1. The "VlanHandlerFacet.class" in the manual does not exist. I assume is a typo and it actually refers to VlanHandler.class (as I did above).
  2. After I added this code to my application I am no longer able to compile the module. In particular, here's the output after I run mvn clean install:
    .....
    [INFO] ------------------------------------------------------------------------
    [INFO] Building topo-bl 1.0.0
    [INFO] ------------------------------------------------------------------------
    [WARNING] The POM for org.eclipse.persistence:eclipselink:jar:2.3.2 is invalid, transitive dependencies 
    (if any) will not be available, enable debug logging for more details [WARNING] The POM for com.tailf:jnc:jar:1.0.3 is missing, no dependency information available [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] topo-root .......................................... SUCCESS [ 0.401 s] [INFO] topo-model ......................................... SUCCESS [ 1.670 s] [INFO] topo-api ........................................... SUCCESS [ 0.639 s] [INFO] topo-bl ............................................ FAILURE [ 0.036 s] [INFO] topo-rs ............................................ SKIPPED [INFO] topo-app ........................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.338 s [INFO] Finished at: 2017-10-18T20:08:08-04:00 [INFO] Final Memory: 27M/239M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project topo-bl: Could not resolve dependencies
    for project com.uky.topo:topo-bl:bundle:1.0.0: Failure to find
    com.tailf:jnc:jar:1.0.3 in https://repo.maven.apache.org/maven2 was cached in
    the local repository, resolution will not be reattempted until the update
    interval of central has elapsed or updates are forced -> [Help 1] [ERROR]
    The error is quite clear and basically tells that it cannot find the com.tailf:jnc:1.03 dependency. Well, it turns out that that particular version does not exist in the internet at all AFAIK. I looked online and found a lot of similar JNC (stands for Java NETCONF client) jars provided mainly by onlab but with different versions, there's no 1.0.3 and non with groupid com.tailf. Even if I specify the version in the pom.xml file it is still asking for 1.0.3. I wonder if I am missing something here. 
  3. Is this the way to obtain information about VLANs from the switches? I know our switches accept SNMP queries. But I want to make sure what's the right way to obtain this information. 

Any help will be greatly appreciated!

1 REPLY 1
ShaunWackerly
HPE Pro

Re: How to use HandlerFacet to get VLAN information

Hi checho,

On point #1, you're correct that it should be VlanHandler.class, and not VlanHandlerFacet.class. Specifically, the fully-qualified class should be:

com.hp.sdn.dvc.facet.VlanHandler.class

On point #2, I see that HPE Aruba implementations for com.hp.sdn.dvc.facet.impl.NetconfClient (a helper class) and com.hp.sdn.dvc.facet.impl.Vxlan5930 (a VxlanFacet implementation for 5930) both import com.tailf.jnc.* classes. I believe you're getting the error because your code imports the device driver code (sdn-ctl-dd), which pulls in all other drivers in the module (including NetconfClient,Vxlan5930) and their dependencies (com.tailf.jnc.*). Looking at the source for com.tailf.jnc on github (link here), I don't see it being modified in the past 2-3 years so I think any version would suffice. Unfortunately, I'm not skilled enough to figure out how to trick your maven repository into thinking whatever version you downloaded is the version 1.0.3 that it's looking for. Maybe someone else could help here?

You're using the correct method for getting VLAN information from the switches. Our design/architecture funnels all device-specific requests through 'facets' so that device queries can use drivers without the caller knowing specifically which driver is being used (a pluggable architecture).

Shaun

 

I am an HPE Employee