use of org.projectfloodlight.openflow.protocol.OFMeterMod 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);
}
use of org.projectfloodlight.openflow.protocol.OFMeterMod in project open-kilda by telstra.
the class ReplaceInstallFlowTest method runTest.
/**
* Runs test case.
*
* @param value data string from json resource file
* @param flowCommand OFFlowAdd instance to compare result with
* @throws InterruptedException if test was interrupted during run
*/
private void runTest(final String value, final OFFlowAdd flowCommand, final OFMeterMod meterCommand, final OFFlowAdd reverseFlowCommand, final OFMeterMod reverseMeterCommand) throws InterruptedException {
// construct kafka message
ConsumerRecord<String, String> record = new ConsumerRecord<>("", 0, 0, "", value);
// create parser instance
ConsumerContext kafkaContext = new ConsumerContext(context, collector);
RecordHandler parseRecord = new RecordHandler(kafkaContext, record, new MeterPool());
// init test mocks
Capture<OFFlowAdd> flowAddCapture = flowCommand == null ? null : newCapture(CaptureType.ALL);
Capture<OFMeterMod> meterAddCapture = meterCommand == null ? null : newCapture(CaptureType.ALL);
prepareMocks(flowAddCapture, meterAddCapture, reverseFlowCommand != null, reverseMeterCommand != null);
// run parser and wait for termination or timeout
parseRecordExecutor.execute(parseRecord);
parseRecordExecutor.shutdown();
parseRecordExecutor.awaitTermination(10, TimeUnit.SECONDS);
// verify results
if (meterCommand != null) {
assertEquals(meterCommand, meterAddCapture.getValues().get(0));
if (reverseMeterCommand != null) {
assertEquals(reverseMeterCommand, meterAddCapture.getValues().get(1));
}
}
if (flowCommand != null) {
assertEquals(flowCommand, flowAddCapture.getValues().get(0));
if (reverseFlowCommand != null) {
assertEquals(reverseFlowCommand, flowAddCapture.getValues().get(1));
}
}
}
use of org.projectfloodlight.openflow.protocol.OFMeterMod in project open-kilda by telstra.
the class ReplaceInstallFlowTest method installIngressNoneFlow.
@Test
public void installIngressNoneFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_none_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressNoneFlowMod(data.getInputPort(), data.getOutputPort(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
use of org.projectfloodlight.openflow.protocol.OFMeterMod in project open-kilda by telstra.
the class ReplaceInstallFlowTest method installOneSwitchPopFlow.
@Test
public void installOneSwitchPopFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_one_switch_pop_flow.json"), Charsets.UTF_8);
InstallOneSwitchFlow data = (InstallOneSwitchFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.oneSwitchPopFlowMod(data.getInputPort(), data.getOutputPort(), data.getInputVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
use of org.projectfloodlight.openflow.protocol.OFMeterMod in project open-kilda by telstra.
the class ReplaceInstallFlowTest method installIngressPopFlow.
@Test
public void installIngressPopFlow() throws IOException, InterruptedException {
String value = Resources.toString(getClass().getResource("/install_ingress_pop_flow.json"), Charsets.UTF_8);
InstallIngressFlow data = (InstallIngressFlow) prepareData(value);
OFMeterMod meterCommand = scheme.installMeter(data.getBandwidth(), 1024, data.getMeterId());
OFFlowAdd flowCommand = scheme.ingressPopFlowMod(data.getInputPort(), data.getOutputPort(), data.getInputVlanId(), data.getTransitVlanId(), data.getMeterId(), 123L);
runTest(value, flowCommand, meterCommand, null, null);
}
Aggregations