+ public static def toADNodeProperties(NodeUpdated nu) {
+ val props = new HashSet<org.opendaylight.controller.sal.core.Property>();
+ val fcnu = nu.getAugmentation(FlowCapableNodeUpdated)
+ if(fcnu != null) {
+ props.add(toADTimestamp)
+ // props.add(fcnu.supportedActions.toADActions) - TODO
+ if(nu.id != null) {
+ props.add(nu.id.toADMacAddress)
+ }
+ if(fcnu.switchFeatures != null) {
+ if(fcnu.switchFeatures.maxTables != null) {
+ props.add(fcnu.switchFeatures.maxTables.toADTables)
+ }
+ if(fcnu.switchFeatures.capabilities != null) {
+ props.add(fcnu.switchFeatures.capabilities.toADCapabiliities)
+ }
+ if(fcnu.switchFeatures.maxBuffers != null) {
+ props.add(fcnu.switchFeatures.maxBuffers.toADBuffers)
+ }
+ }
+ }
+ return props;
+
+ }
+
+ public static def toADTimestamp() {
+ val date = new Date();
+ val timestamp = new TimeStamp(date.time,"connectedSince")
+ return timestamp;
+ }
+
+ public static def toADMacAddress(NodeId id) {
+ return new MacAddress(Long.parseLong(id.value.replaceAll("openflow:","")).longValue.bytesFromDpid)
+ }
+
+ public static def toADTables(Short tables) {
+ return new Tables(tables.byteValue)
+ }
+
+ public static def toADCapabiliities(List<Class<? extends FeatureCapability>> capabilities) {
+ var int b
+ for(capability : capabilities) {
+ if(capability.equals(FlowFeatureCapabilityFlowStats)) {
+ b = Capabilities.CapabilitiesType.FLOW_STATS_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityTableStats)) {
+ b = Capabilities.CapabilitiesType.TABLE_STATS_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityPortStats)) {
+ b = Capabilities.CapabilitiesType.PORT_STATS_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityStp)) {
+ b = Capabilities.CapabilitiesType.STP_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityIpReasm)) {
+ b = Capabilities.CapabilitiesType.IP_REASSEM_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityQueueStats)) {
+ b = Capabilities.CapabilitiesType.QUEUE_STATS_CAPABILITY.value.bitwiseOr(b)
+ } else if (capability.equals(FlowFeatureCapabilityArpMatchIp)) {
+ b = Capabilities.CapabilitiesType.ARP_MATCH_IP_CAPABILITY.value.bitwiseOr(b)
+ }
+ }
+ return new Capabilities(b)
+ }
+
+ public static def toADBuffers(Long buffers) {
+ return new Buffers(buffers.intValue)
+ }