use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.
the class SwitchManager method deleteRuleWithCookie.
@Override
public List<Long> deleteRuleWithCookie(final DatapathId dpid, final List<Long> cookiesToRemove) throws SwitchOperationException {
IOFSwitch sw = lookupSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
for (long cookie : cookiesToRemove) {
OFFlowDelete dropFlowDelete = ofFactory.buildFlowDelete().setCookie(U64.of(cookie)).build();
pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
}
// TODO: it'd be better to identify what was deleted and what wasn't there .. and confirm it is deleted.
return cookiesToRemove;
}
use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.
the class SwitchManager method installLegacyMeter.
private long installLegacyMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth, final long burstSize, final long meterId) throws OFInstallException {
logger.debug("installing legacy meter {} on OVS switch {} width bandwidth {}", meterId, dpid, bandwidth);
Set<OFLegacyMeterFlags> flags = new HashSet<>(asList(OFLegacyMeterFlags.KBPS, OFLegacyMeterFlags.BURST));
OFFactory ofFactory = sw.getOFFactory();
OFLegacyMeterBandDrop.Builder bandBuilder = ofFactory.legacyMeterBandDrop(bandwidth, burstSize).createBuilder();
OFLegacyMeterMod meterMod = ofFactory.buildLegacyMeterMod().setMeterId(meterId).setCommand(OFLegacyMeterModCommand.ADD).setMeters(singletonList(bandBuilder.build())).setFlags(flags).build();
return pushFlow(sw, "--InstallMeter", meterMod);
}
use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.
the class SwitchManagerOF12Test method installTransitFlow.
@Test
public void installTransitFlow() throws Exception {
Capture<OFFlowMod> capture = prepareForInstallFlowOperation();
String flowId = "test-transit-flow-rule";
int inputPort = 2;
int outputPort = 4;
int transitVlanId = 512;
switchManager.installTransitFlow(switchDpId, flowId, commonFlowCookie, inputPort, outputPort, transitVlanId);
OFFactory referenceOfFactory = new OFFactoryVer12Mock();
OFFlowMod expected = referenceOfFactory.buildFlowAdd().setCookie(U64.of(commonFlowCookie).applyMask(U64.of(SwitchManager.FLOW_COOKIE_MASK))).setPriority(FlowModUtils.PRIORITY_VERY_HIGH).setMatch(referenceOfFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(inputPort)).setMasked(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlanId), OFVlanVidMatch.ofRawVid((short) 0x0FFF)).build()).setInstructions(singletonList(referenceOfFactory.instructions().applyActions(singletonList(referenceOfFactory.actions().buildOutput().setMaxLen(0xFFFFFFFF).setPort(OFPort.of(outputPort)).build())).createBuilder().build())).build();
assertEquals(expected, capture.getValue());
}
use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.
the class SwitchManager method installMeter.
private long installMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth, final long burstSize, final long meterId) throws OFInstallException {
logger.debug("installing meter {} on switch {} width bandwidth {}", meterId, dpid, bandwidth);
Set<OFMeterFlags> flags = new HashSet<>(asList(OFMeterFlags.KBPS, OFMeterFlags.BURST));
OFFactory ofFactory = sw.getOFFactory();
OFMeterBandDrop.Builder bandBuilder = ofFactory.meterBands().buildDrop().setRate(bandwidth).setBurstSize(burstSize);
OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod().setMeterId(meterId).setCommand(OFMeterModCommand.ADD).setFlags(flags);
if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
meterModBuilder.setBands(singletonList(bandBuilder.build()));
} else {
meterModBuilder.setMeters(singletonList(bandBuilder.build()));
}
OFMeterMod meterMod = meterModBuilder.build();
return pushFlow(sw, "--InstallMeter--", meterMod);
}
use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.
the class SwitchManager method deleteMeter.
public long deleteMeter(IOFSwitch sw, final DatapathId dpid, final long meterId) throws OFInstallException {
logger.debug("deleting meter {} from switch {}", meterId, dpid);
OFFactory ofFactory = sw.getOFFactory();
OFMeterMod.Builder meterDeleteBuilder = ofFactory.buildMeterMod().setMeterId(meterId).setCommand(OFMeterModCommand.DELETE);
if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
meterDeleteBuilder.setBands(emptyList());
} else {
meterDeleteBuilder.setMeters(emptyList());
}
OFMeterMod meterDelete = meterDeleteBuilder.build();
return pushFlow(sw, "--DeleteMeter--", meterDelete);
}
Aggregations