// add custom validation form module attributes here.
}
- @SuppressWarnings("resource")
@Override
public java.lang.AutoCloseable createInstance() {
final OpflexConnectionService connectionService = new OpflexConnectionService();
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService;
import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
+import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
t.put(LogicalDatastoreType.OPERATIONAL,
iid, new EndpointsBuilder().build());
- ListenableFuture<RpcResult<TransactionStatus>> f = t.commit();
- Futures.addCallback(f, new FutureCallback<RpcResult<TransactionStatus>>() {
-
+ CheckedFuture<Void, TransactionCommitFailedException> f = t.submit();
+ Futures.addCallback(f, new FutureCallback<Void>() {
@Override
- public void onSuccess(RpcResult<TransactionStatus> result) {
-
+ public void onFailure(Throwable t) {
+ LOG.error("Could not write endpoint base container", t);
}
@Override
- public void onFailure(Throwable t) {
- LOG.error("Could not write endpoint base container", t);
+ public void onSuccess(Void result) {
+ // TODO Auto-generated method stub
+
}
});
}
t.put(LogicalDatastoreType.OPERATIONAL, iid_l3, ep3);
}
}
- ListenableFuture<RpcResult<TransactionStatus>> r = t.commit();
+ ListenableFuture<Void> r = t.submit();
return Futures.transform(r, futureTrans, executor);
}
}
}
- ListenableFuture<RpcResult<TransactionStatus>> r = t.commit();
+ ListenableFuture<Void> r = t.submit();
return Futures.transform(r, futureTrans, executor);
}
t.put(LogicalDatastoreType.OPERATIONAL, iid, condition);
}
- ListenableFuture<RpcResult<TransactionStatus>> r = t.commit();
+ ListenableFuture<Void> r = t.submit();
return Futures.transform(r, futureTrans, executor);
}
t.delete(LogicalDatastoreType.OPERATIONAL, iid);
}
- ListenableFuture<RpcResult<TransactionStatus>> r = t.commit();
+ ListenableFuture<Void> r = t.submit();
return Futures.transform(r, futureTrans, executor);
}
- Function<RpcResult<TransactionStatus>, RpcResult<Void>> futureTrans =
- new Function<RpcResult<TransactionStatus>,RpcResult<Void>>() {
+ Function<Void, RpcResult<Void>> futureTrans =
+ new Function<Void,RpcResult<Void>>() {
@Override
- public RpcResult<Void> apply(RpcResult<TransactionStatus> input) {
- if (input.isSuccessful())
- return RpcResultBuilder.<Void>success().build();
- else
- return RpcResultBuilder.<Void>failed()
- .withRpcErrors(input.getErrors()).build();
+ public RpcResult<Void> apply(Void input) {
+ return RpcResultBuilder.<Void>success().build();
}
};
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.DestinationMapper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.builder(SubjectFeatureDefinitions.class)
.build(),
SubjectFeatures.OF_OVERLAY_FEATURES);
- t.commit();
+ t.submit();
}
FlowTableCtx ctx = new FlowTableCtx(dataBroker, rpcRegistry,
t.put(LogicalDatastoreType.CONFIGURATION,
FlowUtils.createNodePath(nodeId),
nb.build());
- ListenableFuture<RpcResult<TransactionStatus>> result = t.commit();
+ ListenableFuture<Void> result = t.submit();
Futures.addCallback(result,
- new FutureCallback<RpcResult<TransactionStatus>>() {
-
+ new FutureCallback<Void>() {
@Override
- public void onSuccess(RpcResult<TransactionStatus> result) {
+ public void onSuccess(Void result) {
dirty.get().addNode(nodeId);
scheduleUpdate();
}
OfOverlayContext ofc = e.getAugmentation(OfOverlayContext.class);
if (ofc == null || ofc.getNodeId() == null) continue;
- syncEPL2(t, tiid, flowMap, nodeId, e, ofc, key);
+ syncEP(t, tiid, flowMap, nodeId, e, ofc, key);
}
}
- private void syncEPL2(ReadWriteTransaction t,
- InstanceIdentifier<Table> tiid,
- Map<String, FlowCtx> flowMap,
- NodeId nodeId,
- Endpoint e, OfOverlayContext ofc,
- EgKey key)
+ private void syncEP(ReadWriteTransaction t,
+ InstanceIdentifier<Table> tiid,
+ Map<String, FlowCtx> flowMap,
+ NodeId nodeId,
+ Endpoint e, OfOverlayContext ofc,
+ EgKey key)
throws Exception {
ArrayList<Instruction> instructions = new ArrayList<>();
// this is a local endpoint
nextHop = ofc.getNodeConnectorId().getValue();
+ Action output = FlowUtils.outputAction(ofc.getNodeConnectorId());
+
instructions.add(new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(FlowUtils.outputActionIns(ofc.getNodeConnectorId()))
+ .setOrder(order)
+ .setInstruction(FlowUtils.writeActionIns(output))
.build());
l3instructions.add(new InstructionBuilder()
.setOrder(order)
.setInstruction(FlowUtils.writeActionIns(setDlSrc,
setDlDst,
- decTtl))
+ decTtl,
+ output))
.build());
+ order +=1;
} else {
// this endpoint is on a different switch; send to the
// appropriate tunnel
LOG.error("Tunnel IP for {} invalid", ofc.getNodeId());
return;
}
+
+ Action output = FlowUtils.outputAction(tunPort);
// XXX - TODO Add action: set tunnel_id from sEPG register
instructions.add(new InstructionBuilder()
- .setOrder(order++)
- .setInstruction(FlowUtils.outputActionIns(tunPort))
+ .setOrder(order)
+ .setInstruction(FlowUtils.writeActionIns(output))
.build());
l3instructions.add(new InstructionBuilder()
.setOrder(order)
- .setInstruction(FlowUtils.writeActionIns(setDlSrc, decTtl))
+ .setInstruction(FlowUtils.writeActionIns(setDlSrc,
+ decTtl,
+ output))
.build());
+ order +=1;
}
}
Instruction gotoTable = new InstructionBuilder()
l3instructions.add(gotoTable);
FlowId flowid = new FlowId(new StringBuilder()
- .append(e.getL2Context())
+ .append(e.getL2Context().getValue())
.append("|l2|")
- .append(e.getMacAddress())
+ .append(e.getMacAddress().getValue())
.append("|")
.append(nextHop)
.toString());
.setInstructions(new InstructionsBuilder()
.setInstruction(instructions)
.build());
-
+
writeFlow(t, tiid, flowb.build());
}
if (e.getL3Address() == null) return;
continue;
flowid = new FlowId(new StringBuilder()
- .append(l3a.getL3Context())
+ .append(l3a.getL3Context().getValue())
.append("|l3|")
- .append(l3a.getIpAddress())
+ .append(ikey)
.append("|")
.append(nextHop)
.toString());
.setInstructions(new InstructionsBuilder()
.setInstruction(l3instructions)
.build());
-
+
writeFlow(t, tiid, flowb.build());
}
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.EndpointManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- ListenableFuture<RpcResult<TransactionStatus>> result = t.commit();
+ ListenableFuture<Void> result = t.submit();
Futures.addCallback(result, updateCallback);
}
*
* @param <T> the expected output type
*/
- protected static class FlowCallback<T> implements FutureCallback<RpcResult<T>> {
-
+ protected static class FlowCallback<T> implements FutureCallback<T> {
@Override
- public void onSuccess(RpcResult<T> result) {
- if (!result.isSuccessful()) {
- LOG.error("Failed to update flow entry", result.getErrors());
- }
+ public void onSuccess(T result) {
}
@Override
LOG.error("Failed to add flow entry", t);
}
}
- protected static final FlowCallback<TransactionStatus> updateCallback =
+ protected static final FlowCallback<Void> updateCallback =
new FlowCallback<>();
/**
* @author readams
*/
public class PolicyEnforcer extends FlowTable {
- public static final short TABLE_ID = 2;
+ public static final short TABLE_ID = 3;
public PolicyEnforcer(FlowTableCtx ctx) {
super(ctx);
if (dataProvider != null) {
WriteTransaction t = dataProvider.newWriteOnlyTransaction();
t.delete(LogicalDatastoreType.CONFIGURATION, DOMAINS_IID);
- t.commit().get();
+ t.submit().get();
}
}
endpoint group, and provider named selectors select
contracts to provide capabilities for the endpoint group.";
- leaf name {
- description "A name for the named selector.";
- type gbp-common:selector-name;
- mandatory true;
- }
-
leaf-list contract {
description "Specific contracts to select.";
type leafref {
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.Matchers;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowTable.FlowCtx;
public void testNoEps() throws Exception {
ReadWriteTransaction t = dosync(null);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
private void verifyDMap(Endpoint remoteEp,
- Endpoint localEp) throws Exception {
+ Endpoint localEp) throws Exception {
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, atLeastOnce()).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
((WriteActionsCase)ins.getInstruction()).getWriteActions().getAction();
assertEquals(FlowUtils.setDlSrc(DestinationMapper.ROUTER_MAC),
actions.get(0).getAction());
+ assertEquals(Integer.valueOf(0), actions.get(0).getOrder());
assertEquals(FlowUtils.setDlDst(localEp.getMacAddress()),
actions.get(1).getAction());
+ assertEquals(Integer.valueOf(1), actions.get(1).getOrder());
assertEquals(FlowUtils.decNwTtl(),
actions.get(2).getAction());
+ assertEquals(Integer.valueOf(2), actions.get(2).getOrder());
+ assertEquals(FlowUtils.outputAction(nodeConnectorId),
+ actions.get(3).getAction());
+ assertEquals(Integer.valueOf(3), actions.get(3).getOrder());
count += 1;
} else if (f.getMatch().getLayer3Match() instanceof Ipv6Match) {
// should be remote port with rewrite dlsrc plus
((WriteActionsCase)ins.getInstruction()).getWriteActions().getAction();
assertEquals(FlowUtils.setDlSrc(DestinationMapper.ROUTER_MAC),
actions.get(0).getAction());
+ assertEquals(Integer.valueOf(0), actions.get(0).getOrder());
assertEquals(FlowUtils.decNwTtl(),
actions.get(1).getAction());
+ assertEquals(Integer.valueOf(1), actions.get(1).getOrder());
+ assertEquals(FlowUtils.outputAction(tunnelId),
+ actions.get(2).getAction());
+ assertEquals(Integer.valueOf(2), actions.get(2).getOrder());
count += 1;
}
}
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.Matchers;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowTable.FlowCtx;
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, times(4)).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
count += 1;
assertEquals(FlowUtils.dropInstructions(),
f.getInstructions());
- }
+ }
}
assertEquals(4, count);
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, atLeastOnce()).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, atLeastOnce()).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
-
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
+
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
for (Flow f : ac.getAllValues()) {
assertEquals(1, count);
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, atLeastOnce()).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
assertEquals(3, count);
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
}
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.Matchers;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.FlowTable.FlowCtx;
endpointManager.addEndpoint(localEP().build());
ReadWriteTransaction t = dosync(null);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
ReadWriteTransaction t = dosync(null);
ArgumentCaptor<Flow> ac = ArgumentCaptor.forClass(Flow.class);
verify(t, times(1)).put(eq(LogicalDatastoreType.CONFIGURATION),
- any(InstanceIdentifier.class), ac.capture());
+ Matchers.<InstanceIdentifier<Flow>>any(),
+ ac.capture());
int count = 0;
HashMap<String, FlowCtx> flowMap = new HashMap<>();
LOG.info("{}", f);
count += 1;
}
-
}
assertEquals(1, count);
t = dosync(flowMap);
verify(t, never()).put(any(LogicalDatastoreType.class),
- any(InstanceIdentifier.class),
+ Matchers.<InstanceIdentifier<Flow>>any(),
any(Flow.class));
}
package org.opendaylight.groupbasedpolicy.renderer.opflex;
-import static io.netty.buffer.Unpooled.copiedBuffer;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.CharsetUtil;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.groupbasedpolicy.jsonrpc.JsonRpcDecoder;
import org.opendaylight.groupbasedpolicy.jsonrpc.JsonRpcEndpoint;
import org.opendaylight.groupbasedpolicy.jsonrpc.JsonRpcServiceBinderHandler;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.domains.domain.discovery.definitions.ObserverBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.domains.domain.discovery.definitions.PolicyRepository;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.domains.domain.discovery.definitions.PolicyRepositoryBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
+import static io.netty.buffer.Unpooled.*;
+
+import static org.junit.Assert.*;
+
+import static org.mockito.Matchers.*;
+
+import static org.mockito.Mockito.*;
+
/**
*
* Test the serialization and deserialization of RPC Messages,
@Mock
private ListenableFuture<Optional<Domains>> mockOption;
@Mock
- ListenableFuture<RpcResult<TransactionStatus>> mockStatus;
+ CheckedFuture<Void, TransactionCommitFailedException> mockStatus;
@Mock
private Optional<Domains> mockDao;
@Mock
*/
when(mockDataBroker.newReadOnlyTransaction()).thenReturn(mockRead);
when(mockDataBroker.newWriteOnlyTransaction()).thenReturn(mockWrite);
- when(mockWrite.commit()).thenReturn(mockStatus);
+ when(mockWrite.submit()).thenReturn(mockStatus);
when(mockRead.read(LogicalDatastoreType.CONFIGURATION,
OpflexConnectionService.DOMAINS_IID)).thenReturn(mockOption);
when(mockOption.get()).thenReturn(mockDao);