.build());
return emb.build();
}
+
+ /**
+ * Parse an OF port number from a node connector ID
+ * @param id the ID
+ * @return the port number
+ */
+ public static long getOfPortNum(NodeConnectorId id) {
+ String cnid = id.getValue();
+ int ci = cnid.lastIndexOf(':');
+ if (ci < 0 || (ci+1 >= cnid.length()))
+ throw new NumberFormatException("Invalid node connector ID " + cnid);
+ return Long.parseLong(cnid.substring(ci+1));
+ }
}
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.SwitchManager;
import org.opendaylight.groupbasedpolicy.resolver.PolicyInfo;
import org.opendaylight.groupbasedpolicy.resolver.PolicyResolver;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract void update(NodeId nodeId,
PolicyInfo policyInfo,
Dirty dirty) throws Exception;
-
- // ***************
- // Utility methods
- // ***************
-
- /**
- * Parse an OF port number from a node connector ID
- * @param id the ID
- * @return the port number
- */
- protected static long getOfPortNum(NodeConnectorId id) {
- String cnid = id.getValue();
- int ci = cnid.lastIndexOf(':');
- if (ci < 0 || (ci+1 >= cnid.length()))
- throw new NumberFormatException("Invalid node connector ID " + cnid);
- return Long.parseLong(cnid.substring(ci+1));
- }
}
int icount = 0;
for (Instruction ins : f.getInstructions().getInstruction()) {
if (ins.getInstruction() instanceof ApplyActionsCase) {
- long p = OfTable.getOfPortNum(nodeConnectorId);
+ long p = getOfPortNum(nodeConnectorId);
List<Action> actions = ((ApplyActionsCase)ins.getInstruction()).getApplyActions().getAction();
assertEquals(nxLoadRegAction(NxmNxReg7.class,
BigInteger.valueOf(p)),
int icount = 0;
for (Instruction ins : f.getInstructions().getInstruction()) {
if (ins.getInstruction() instanceof ApplyActionsCase) {
- long p = OfTable.getOfPortNum(tunnelId);
+ long p = getOfPortNum(tunnelId);
List<Action> actions = ((ApplyActionsCase)ins.getInstruction()).getApplyActions().getAction();
assertEquals(nxLoadRegAction(NxmNxReg7.class,
BigInteger.valueOf(p)),
Instruction ins = f.getInstructions().getInstruction().get(0);
assertTrue(ins.getInstruction() instanceof ApplyActionsCase);
List<Action> actions = ((ApplyActionsCase)ins.getInstruction()).getApplyActions().getAction();
- long p = OfTable.getOfPortNum(nodeConnectorId);
+ long p = getOfPortNum(nodeConnectorId);
assertEquals(nxLoadRegAction(NxmNxReg7.class,
BigInteger.valueOf(p)),
actions.get(2).getAction());
Instruction ins = f.getInstructions().getInstruction().get(0);
assertTrue(ins.getInstruction() instanceof ApplyActionsCase);
List<Action> actions = ((ApplyActionsCase)ins.getInstruction()).getApplyActions().getAction();
- long p = OfTable.getOfPortNum(tunnelId);
+ long p = getOfPortNum(tunnelId);
assertEquals(nxLoadRegAction(NxmNxReg7.class,
BigInteger.valueOf(p)),
actions.get(4).getAction());