/*
- * Copyright (c) 2016 Ericsson Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.openflowplugin.applications.bulk.o.matic;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class BulkOMaticUtils {
+public final class BulkOMaticUtils {
- public final static int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
- public final static int DEFAULT_FLOW_COUNT = 0;
- public final static long DEFAULT_COMPLETION_TIME = 0;
- public final static String DEFAULT_UNITS = "ns";
- public final static String DEVICE_TYPE_PREFIX = "openflow:";
+ public static final int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
+ public static final int DEFAULT_FLOW_COUNT = 0;
+ public static final int DEFAULT_TABLE_COUNT = 0;
+ public static final long DEFAULT_COMPLETION_TIME = 0;
+ public static final String DEFAULT_UNITS = "ns";
+ public static final String DEVICE_TYPE_PREFIX = "openflow:";
- public static String ipIntToStr (int k) {
- return new StringBuilder().append(((k >> 24) & 0xFF)).append(".")
- .append(((k >> 16) & 0xFF)).append(".")
- .append(((k >> 8) & 0xFF)).append(".")
- .append((k & 0xFF)).append("/32").toString();
+ private BulkOMaticUtils() {
}
- public static Match getMatch(final Integer sourceIp){
- Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(
- new Ipv4Prefix(ipIntToStr(sourceIp))).build();
+ public static String ipIntToStr(int number) {
+ return new StringBuilder().append(number >> 24 & 0xFF).append(".")
+ .append(number >> 16 & 0xFF).append(".")
+ .append(number >> 8 & 0xFF).append(".")
+ .append(number & 0xFF).append("/32").toString();
+ }
+
+ public static Match getMatch(final int sourceIp) {
+ Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setLayer3Match(ipv4Match);
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
return matchBuilder.build();
}
- public static Flow buildFlow(Short tableId, String flowId, Match match){
+ public static Flow buildFlow(Short tableId, String flowId, Match match) {
FlowBuilder flowBuilder = new FlowBuilder();
- flowBuilder.setKey(new FlowKey(new FlowId(flowId)));
+ flowBuilder.withKey(new FlowKey(new FlowId(flowId)));
flowBuilder.setTableId(tableId);
flowBuilder.setMatch(match);
return flowBuilder.build();
}
public static InstanceIdentifier<Flow> getFlowInstanceIdentifier(Short tableId, String flowId, String dpId) {
- return InstanceIdentifier.create(Nodes.class).child(Node.class,
- new NodeKey(new NodeId(dpId)))
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(tableId))
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
+ .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId))
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow.class,
new FlowKey(new FlowId(flowId)));
}
- public static InstanceIdentifier<Node> getFlowCapableNodeId(String dpId){
- return InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, new NodeKey(new NodeId(dpId)))
- .build();
+ public static InstanceIdentifier<Node> getFlowCapableNodeId(String dpId) {
+ return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId))).build();
}
public static InstanceIdentifier<Table> getTableId(Short tableId, String dpId) {
- return InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, new NodeKey(new NodeId(dpId)))
- .augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(tableId))
- .build();
-
+ return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
+ .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).build();
}
public static InstanceIdentifier<Flow> getFlowId(final InstanceIdentifier<Table> tablePath, final String flowId) {