}
container renderer-policy {
+ presence "Enforce mandatory node only if renderer-policy container is present";
description "Policy is named by version and describes desired vs real state.
Desired state of policy described by /renderers/renderer/renderer-policy/configuration and version are stored in CONF.
The real state of policy described by /renderers/renderer/renderer-policy/status and version are stored in OPER.";
}
container endpoints {
+ presence "Enforce mandatory node only if endpoints container is present";
list address-endpoint-with-location {
min-elements 1;
key "context-type context-id address-type address";
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.unregister.endpoint.input.ContainmentEndpointUnreg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.unregister.endpoint.input.ContainmentEndpointUnregBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.NetworkDomainId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.rev160427.AddressType;
.setTimestamp(addrEp.getTimestamp())
.setParentEndpointChoice(addrEp.getParentEndpointChoice())
.setChildEndpoint(addrEp.getChildEndpoint())
+ .setEndpointGroup(addrEp.getEndpointGroup())
.build());
}
builder.setAddressEndpointReg(addrEpRegs);
.setTenant(contEp.getTenant())
.setNetworkContainment(contEp.getNetworkContainment())
.setChildEndpoint(contEp.getChildEndpoint())
+ .setEndpointGroup(contEp.getEndpointGroup())
.build());
}
builder.setContainmentEndpointReg(contEpRegs);
.setAddress(MAC_ADDRESS)
.setAddressType(AddressType.class)
.setNetworkContainment(new NetworkContainmentBuilder().setContainment(networkDomainContainment).build())
- .setTimestamp(timestamp);
+ .setTimestamp(timestamp)
+ .setEndpointGroup(Collections.singletonList(new EndpointGroupId("testEPGID")));
}
private AddressEndpointBuilder createBaseL3EpBuilder() {
.setAddress(IP_ADDRESS)
.setAddressType(AddressType.class)
.setNetworkContainment(new NetworkContainmentBuilder().setContainment(networkDomainContainment).build())
- .setTimestamp(timestamp);
+ .setTimestamp(timestamp)
+ .setEndpointGroup(Collections.singletonList(new EndpointGroupId("testEPGID")));
}
private ContainmentEndpointBuilder createBaseContEpBuilder() {
.setContextId(new ContextId(CONTEXT_ID))
.setContextType(ContextType.class)
.setTenant(new TenantId(TENANT))
- .setNetworkContainment(new NetworkContainmentBuilder().setContainment(networkDomainContainment).build());
+ .setNetworkContainment(new NetworkContainmentBuilder().setContainment(networkDomainContainment).build())
+ .setEndpointGroup(Collections.singletonList(new EndpointGroupId("testEPGID")));
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.location.type.ExternalLocationCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.NetworkDomainId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.NetworkElements;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.NetworkElementsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.network.elements.NetworkElement;
public class NeLocationProviderTest extends CustomDataBrokerTest {
+ private static final TenantId TENANT = new TenantId("Tenant");
+ private static final List<EndpointGroupId> DEFAULT_EPG =
+ Collections.singletonList(new EndpointGroupId("defaultEPG"));
private DataBroker dataBroker;
private NeLocationProvider neProvider;
private String L3_CONTEXT_ID = "l3Context";
@Override
public Collection<Class<?>> getClassesFromModules() {
- return ImmutableList.<Class<?>>of(NetworkElements.class, LocationProviders.class, Endpoints.class, L3Context.class, Nodes.class);
+ return ImmutableList.<Class<?>>of(NetworkElements.class, LocationProviders.class, Endpoints.class,
+ L3Context.class, Nodes.class);
}
@Before
@Test
public void test_AddressEndpointWrite_NoNE_Overwrite() throws Exception {
writeBaseAddrEndpoint();
- NetworkContainment nc = new NetworkContainmentBuilder()
- .setContainment(new NetworkDomainContainmentBuilder().setNetworkDomainId(new NetworkDomainId(L3_CONTEXT_ID)).build())
- .build();
+ NetworkContainment nc = new NetworkContainmentBuilder().setContainment(
+ new NetworkDomainContainmentBuilder().setNetworkDomainId(new NetworkDomainId(L3_CONTEXT_ID)).build())
+ .build();
AddressEndpoint endpoint = new AddressEndpointBuilder().setKey(
- new AddressEndpointKey(IPv4_HOST_ADDRESS_1, IpPrefixType.class, new ContextId(L3_CONTEXT_ID), L3Context.class))
- .setNetworkContainment(nc)
- .build();
+ new AddressEndpointKey(IPv4_HOST_ADDRESS_1, IpPrefixType.class, new ContextId(L3_CONTEXT_ID),
+ L3Context.class)).setNetworkContainment(nc).setTenant(TENANT).setEndpointGroup(DEFAULT_EPG).build();
InstanceIdentifier<AddressEndpoint> iid = IidFactory.addressEndpointIid(endpoint.getKey());
WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
wtx.put(LogicalDatastoreType.OPERATIONAL, iid, endpoint, true);
@Test
public void test_AddressEndpointModified_NoNE() throws Exception {
writeBaseAddrEndpoint();
- NetworkContainment nc = new NetworkContainmentBuilder()
- .setContainment(new NetworkDomainContainmentBuilder().setNetworkDomainId(new NetworkDomainId(L3_CONTEXT_ID)).build())
+ NetworkContainment nc =
+ new NetworkContainmentBuilder().setContainment(
+ new NetworkDomainContainmentBuilder().setNetworkDomainId(new NetworkDomainId(L3_CONTEXT_ID)).build())
.build();
InstanceIdentifier<NetworkContainment> iid = InstanceIdentifier
.builder(Endpoints.class)
private AddressEndpoint createAddressEndpoint(String ipAddr, Class<? extends AddressType> addrType,
String context, Class<? extends ContextType> cType) {
- return new AddressEndpointBuilder().setAddress(ipAddr).setAddressType(addrType)
- .setContextId(new ContextId(context)).setContextType(cType).build();
+ return new AddressEndpointBuilder()
+ .setAddress(ipAddr)
+ .setAddressType(addrType)
+ .setContextId(new ContextId(context))
+ .setContextType(cType).setTenant(TENANT)
+ .setEndpointGroup(DEFAULT_EPG).build();
}
private NetworkElements createNetworkElements(String node, String iface, String l3c, String prefix) {
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.General;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Ip;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Neighbor;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborBuilder;
@Override
void put(ReadWriteTransaction rwTx) {
InstanceIdentifier<Neighbor> iid = VppIidFactory.getNeighborIid(interfaceKey, new NeighborKey(ip));
+ InstanceIdentifier<Interface> intfIid = VppIidFactory.getInterfaceIID(interfaceKey);
+ rwTx.merge(LogicalDatastoreType.CONFIGURATION, intfIid, new InterfaceBuilder().setKey(interfaceKey).setType(Ip.class).build());
rwTx.put(LogicalDatastoreType.CONFIGURATION, iid, getNeighborBuilder().build());
}
@Override
void merge(ReadWriteTransaction rwTx) {
InstanceIdentifier<Neighbor> iid = VppIidFactory.getNeighborIid(interfaceKey, new NeighborKey(ip));
+ InstanceIdentifier<Interface> intfIid = VppIidFactory.getInterfaceIID(interfaceKey);
+ rwTx.merge(LogicalDatastoreType.CONFIGURATION, intfIid, new InterfaceBuilder().setKey(interfaceKey).setType(Ip.class).build());
rwTx.merge(LogicalDatastoreType.CONFIGURATION, iid, getNeighborBuilder().build());
}
public static <T extends DataObject> boolean executeCommand(InstanceIdentifier<Node> nodeIid,
AbstractLispCommand<T> lispStateCommand) {
- final boolean transactionState = GbpNetconfTransaction.netconfSyncedWrite(nodeIid, lispStateCommand.getIid(),
- lispStateCommand.getData(), GbpNetconfTransaction.RETRY_COUNT);
+ final boolean transactionState;
+ switch (lispStateCommand.getOperation()) {
+ case MERGE:
+ case PUT: {
+ transactionState = GbpNetconfTransaction.netconfSyncedWrite(nodeIid, lispStateCommand.getIid(),
+ lispStateCommand.getData(), GbpNetconfTransaction.RETRY_COUNT);
+ break;
+ }
+ case DELETE: {
+ transactionState = GbpNetconfTransaction.netconfSyncedDelete(nodeIid, lispStateCommand.getIid(),
+ GbpNetconfTransaction.RETRY_COUNT);
+ }
+ break;
+ default:
+ throw new IllegalStateException("No supported operation specified.");
+ }
if (transactionState) {
LOG.trace("Successfully executed command: {}", lispStateCommand);
} else {
private void enableLispOnHost(EndpointHost endpointHost, LispState lispState)
throws LispConfigCommandFailedException {
+ LOG.debug("Enabling LISP on host {}", endpointHost.getHostName());
AbstractLispCommand<Lisp> lispEnableCommand = LispCommandWrapper.enableLisp();
if (LispStateCommandExecutor.executePutCommand(endpointHost.getHostName(), lispEnableCommand)) {
lispState.setLispEnabled(true);
.augmentation(StaticRoutes1.class)
.child(Ipv4.class);
- if (GbpNetconfTransaction.netconfSyncedMerge(VppIidFactory.getNetconfNodeIid(new NodeId(hostName)), iid,
+ RoutingProtocolKey routingProtocolKey = new RoutingProtocolKey(hostVrfStateForPortVrf.getProtocolName());
+ boolean routingProtocol = GbpNetconfTransaction.netconfSyncedMerge(VppIidFactory.getNetconfNodeIid(new NodeId(hostName)), VppIidFactory
+ .getRoutingInstanceIid(routingProtocolKey),
+ new RoutingProtocolBuilder().setKey(routingProtocolKey).setType(Static.class).build(), GbpNetconfTransaction.RETRY_COUNT);
+
+ if (routingProtocol && GbpNetconfTransaction.netconfSyncedMerge(VppIidFactory.getNetconfNodeIid(new NodeId(hostName)), iid,
ipv4Route, GbpNetconfTransaction.RETRY_COUNT)) {
hostVrfStateForPortVrf.addNewPortIpInVrf(portSubnetUuid, nextHopAddress);
hostPortInterfaces.addRouteToPortInterface(outgoingInterface, portSubnetUuid, nextHopAddress, routeId);
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.LocationProviders;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.LocationProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.location.provider.ProviderAddressEndpointLocation;
InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, BASIC_VPP_EP_KEY).build();
private final static NodeKey NODE_KEY = new NodeKey(new NodeId("node1"));
private final static String SOCKET = "socket1";
+ private final static String TENANT = "tenant";
private InterfaceManager manager;
private FlatOverlayManager flatOverlayManager;
.setKey(new AddressEndpointKey(vhostVppEpBuilder().getAddress(), vhostVppEpBuilder().getAddressType(),
vhostVppEpBuilder().getContextId(), vhostVppEpBuilder().getContextType()))
.setEndpointGroup(ImmutableList.of())
+ .setTenant(new TenantId(TENANT))
.build();
VppEndpointLocationProvider vppEpLocProvider = new VppEndpointLocationProvider(dataBroker);
WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.parent.endpoint._case.ParentEndpointBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.parent.child.endpoints.parent.endpoint.choice.parent.endpoint._case.ParentEndpointKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.LocationProviders;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.LocationProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.location.provider.ProviderAddressEndpointLocation;
public class VppEndpointLocationProviderTest extends CustomDataBrokerTest {
+ private static final EndpointGroupId DEFAULT_EPG = new EndpointGroupId("Default");
private DataBroker dataBroker;
private VppEndpointLocationProvider locationProvider;
private final String INTF_NAME = "interface-name";
+ private final static String TENANT = "tenant";
private final NodeId NODE_1 = new NodeId("vpp-node-1");
private final NodeId NODE_2 = new NodeId("vpp-node-2");
private final NodeId NODE_3 = new NodeId("vpp-node-3");
}
private void l2ChildHasTwoIpParents(boolean vppEndpointEvent) {
- AddressEndpointBuilder child = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder child = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(child, IP_KEY_1_22, IP_KEY_2_22);
- AddressEndpointBuilder firstParent = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
- AddressEndpointBuilder secondParent = new AddressEndpointBuilder().setKey(IP_KEY_2_22);
+ AddressEndpointBuilder firstParent = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder secondParent = getAddressEndpointBuilder().setKey(IP_KEY_2_22);
setChildEndpoints(firstParent, MAC_KEY_23_45);
setChildEndpoints(secondParent, MAC_KEY_23_45);
submitEndpointsToDatastore(child.build(), firstParent.build(), secondParent.build());
}
private void l2ChildHasOneIpParent(boolean vppEndpointEvent) {
- AddressEndpointBuilder child = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder child = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(child, IP_KEY_1_22);
- AddressEndpointBuilder firstParent = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder firstParent = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
setChildEndpoints(firstParent, MAC_KEY_23_45);
submitEndpointsToDatastore(child.build(), firstParent.build());
assertEndpointsInDatastore(child.getKey(), firstParent.getKey());
*/
@Test
public void lifecycleTest() {
- AddressEndpointBuilder child = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder child = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(child, IP_KEY_1_22);
- AddressEndpointBuilder firstParent = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder firstParent = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
setChildEndpoints(firstParent, MAC_KEY_23_45);
submitEndpointsToDatastore(child.build(), firstParent.build());
assertEndpointsInDatastore(child.getKey(), firstParent.getKey());
Assert.assertTrue(location.getKey().equals(getLocationKey(MAC_KEY_23_45)));
assertNodeConnector(location.getAbsoluteLocation(), INTF_NAME);
assertMountPoint(location.getAbsoluteLocation(), NODE_1);
- AddressEndpointBuilder secondParent = new AddressEndpointBuilder().setKey(IP_KEY_2_22);
+ AddressEndpointBuilder secondParent = getAddressEndpointBuilder().setKey(IP_KEY_2_22);
setChildEndpoints(secondParent, MAC_KEY_23_45);
setParentEndpoints(child, IP_KEY_1_22, IP_KEY_2_22);
submitEndpointsToDatastore(child.build(), secondParent.build());
*/
@Test
public void testRelativeLocation_multihome() {
- AddressEndpointBuilder mac1 = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder mac1 = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(mac1, IP_KEY_1_22);
- AddressEndpointBuilder mac2 = new AddressEndpointBuilder().setKey(MAC_KEY_24_45);
+ AddressEndpointBuilder mac2 = getAddressEndpointBuilder().setKey(MAC_KEY_24_45);
setParentEndpoints(mac2, IP_KEY_1_22);
- AddressEndpointBuilder ip1 = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder ip1 = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
setChildEndpoints(ip1, MAC_KEY_23_45, MAC_KEY_24_45);
submitEndpointsToDatastore(mac1.build(), mac2.build(), ip1.build());
assertEndpointsInDatastore(mac1.getKey(), mac2.getKey(), ip1.getKey());
*/
@Test
public void testMetadataHaUseCase() {
- AddressEndpointBuilder mac1 = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder mac1 = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(mac1, IP_KEY_1_22, IP_KEY_9_99);
- AddressEndpointBuilder mac2 = new AddressEndpointBuilder().setKey(MAC_KEY_24_45);
+ AddressEndpointBuilder mac2 = getAddressEndpointBuilder().setKey(MAC_KEY_24_45);
setParentEndpoints(mac2, IP_KEY_2_22, IP_KEY_9_99);
- AddressEndpointBuilder mac3 = new AddressEndpointBuilder().setKey(MAC_KEY_25_45);
+ AddressEndpointBuilder mac3 = getAddressEndpointBuilder().setKey(MAC_KEY_25_45);
setParentEndpoints(mac3, IP_KEY_3_22, IP_KEY_9_99);
- AddressEndpointBuilder ip1 = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder ip1 = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
setChildEndpoints(ip1, MAC_KEY_23_45);
- AddressEndpointBuilder ip2 = new AddressEndpointBuilder().setKey(IP_KEY_2_22);
+ AddressEndpointBuilder ip2 = getAddressEndpointBuilder().setKey(IP_KEY_2_22);
setChildEndpoints(ip2, MAC_KEY_24_45);
- AddressEndpointBuilder ip3 = new AddressEndpointBuilder().setKey(IP_KEY_3_22);
+ AddressEndpointBuilder ip3 = getAddressEndpointBuilder().setKey(IP_KEY_3_22);
setChildEndpoints(ip3, MAC_KEY_25_45);
- AddressEndpointBuilder ip9 = new AddressEndpointBuilder().setKey(IP_KEY_9_99);
+ AddressEndpointBuilder ip9 = getAddressEndpointBuilder().setKey(IP_KEY_9_99);
setChildEndpoints(ip9, MAC_KEY_23_45, MAC_KEY_24_45, MAC_KEY_25_45);
submitEndpointsToDatastore(mac1.build(), mac2.build(), mac3.build(), ip1.build(), ip2.build(), ip3.build(),
ip9.build());
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_23_45_VPP, NODE_1, INTF_NAME));
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_24_45_VPP, NODE_2, INTF_NAME));
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_25_45_VPP, NODE_3, INTF_NAME));
- assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds();
+ assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds(4L);
}
/**
*/
@Test
public void metadataHaUseCase_swapped_order() {
- AddressEndpointBuilder mac1 = new AddressEndpointBuilder().setKey(MAC_KEY_23_45);
+ AddressEndpointBuilder mac1 = getAddressEndpointBuilder().setKey(MAC_KEY_23_45);
setParentEndpoints(mac1, IP_KEY_1_22, IP_KEY_9_99);
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_23_45_VPP, NODE_1, INTF_NAME));
- AddressEndpointBuilder ip1 = new AddressEndpointBuilder().setKey(IP_KEY_1_22);
+ AddressEndpointBuilder ip1 = getAddressEndpointBuilder().setKey(IP_KEY_1_22);
setChildEndpoints(ip1, MAC_KEY_23_45);
- AddressEndpointBuilder ip9 = new AddressEndpointBuilder().setKey(IP_KEY_9_99);
+ AddressEndpointBuilder ip9 = getAddressEndpointBuilder().setKey(IP_KEY_9_99);
setChildEndpoints(ip9, MAC_KEY_23_45);
submitEndpointsToDatastore(mac1.build(), ip1.build(), ip9.build());
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_24_45_VPP, NODE_2, INTF_NAME));
- AddressEndpointBuilder mac2 = new AddressEndpointBuilder().setKey(MAC_KEY_24_45);
+ AddressEndpointBuilder mac2 = getAddressEndpointBuilder().setKey(MAC_KEY_24_45);
setParentEndpoints(mac2, IP_KEY_2_22, IP_KEY_9_99);
- AddressEndpointBuilder ip2 = new AddressEndpointBuilder().setKey(IP_KEY_2_22);
+ AddressEndpointBuilder ip2 = getAddressEndpointBuilder().setKey(IP_KEY_2_22);
setChildEndpoints(ip2, MAC_KEY_24_45);
- ip9 = new AddressEndpointBuilder().setKey(IP_KEY_9_99);
+ ip9 = getAddressEndpointBuilder().setKey(IP_KEY_9_99);
setChildEndpoints(ip9, MAC_KEY_23_45, MAC_KEY_24_45);
submitEndpointsToDatastore(mac2.build(), ip2.build(), ip9.build());
- AddressEndpointBuilder mac3 = new AddressEndpointBuilder().setKey(MAC_KEY_25_45);
+ AddressEndpointBuilder mac3 = getAddressEndpointBuilder().setKey(MAC_KEY_25_45);
setParentEndpoints(mac3, IP_KEY_3_22, IP_KEY_9_99);
- AddressEndpointBuilder ip3 = new AddressEndpointBuilder().setKey(IP_KEY_3_22);
+ AddressEndpointBuilder ip3 = getAddressEndpointBuilder().setKey(IP_KEY_3_22);
setChildEndpoints(ip3, MAC_KEY_25_45);
- ip9 = new AddressEndpointBuilder().setKey(IP_KEY_9_99);
+ ip9 = getAddressEndpointBuilder().setKey(IP_KEY_9_99);
setChildEndpoints(ip9, MAC_KEY_23_45, MAC_KEY_24_45, MAC_KEY_25_45);
locationProvider.createLocationForVppEndpoint(vppEndpointBuilder(MAC_KEY_25_45_VPP, NODE_3, INTF_NAME));
submitEndpointsToDatastore(mac3.build(), ip3.build(), ip9.build());
assertEndpointsInDatastore(mac1.getKey(), mac2.getKey(), mac3.getKey(), ip1.getKey(), ip2.getKey(),
ip3.getKey(), ip9.getKey());
- assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds();
+ assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds(4L);
}
- private void assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds() {
+ private AddressEndpointBuilder getAddressEndpointBuilder() {
+ return new AddressEndpointBuilder()
+ .setTenant(new TenantId(TENANT))
+ .setEndpointGroup(Collections.singletonList(DEFAULT_EPG))
+ ;
+ }
+
+ private void assertL2ChildHasTwoIpParentsAndIpParentHasMultipleChilds(long expected) {
List<ProviderAddressEndpointLocation> locations = readLocations();
- Assert.assertEquals(locations.size(), 4);
+ Assert.assertEquals(expected, locations.size());
locations.forEach(location -> {
if (location.getKey().equals(getLocationKey(IP_KEY_1_22))) {
assertNodeConnector(location.getAbsoluteLocation(), INTF_NAME);
}
DataStoreHelper.submitToDs(wTx);
}
-}
\ No newline at end of file
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.rev160427.ContextType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.rev160427.Forwarding;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.Config;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425._interface.attributes._interface.type.choice.VhostUserCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpoint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.vpp_renderer.rev160425.config.VppEndpointBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private final static String ADDRESS = "1.1.1.1/32";
private final static ContextId CONTEXT_ID = new ContextId("ctx1");
private final static String IFACE_NAME = "ifaceName";
+ public static final NodeId TEST_NODE = new NodeId("testNode");
+ private static final String DEFAULT_IFACE_NAME = "defaultIfaceName";
+ private static final String TEST_SOCKET = "/tmp/test_socket";
private DataBroker dataBroker;
private VppEndpointListener listener;
@Test
public void testOnWrite() throws Exception {
ArgumentCaptor<VppEndpointConfEvent> argVppEpEvent = ArgumentCaptor.forClass(VppEndpointConfEvent.class);
- VppEndpoint vppEndpoint = new VppEndpointBuilder().setAddress(ADDRESS)
- .setAddressType(AddressType.class)
- .setContextId(CONTEXT_ID)
- .setContextType(ContextType.class)
- .build();
+ VppEndpoint vppEndpoint = getBaseVppEndpointBuilder().build();
InstanceIdentifier<VppEndpoint> vppEpIid =
InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, vppEndpoint.getKey()).build();
WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
VppEndpointConfEvent capturedVppEpEvent = argVppEpEvent.getValue();
Assert.assertEquals(vppEpIid, capturedVppEpEvent.getIid());
assertEqualsOptional(null, capturedVppEpEvent.getBefore());
+ Optional<VppEndpoint> after = capturedVppEpEvent.getAfter();
assertEqualsOptional(vppEndpoint, capturedVppEpEvent.getAfter());
}
@Test
public void testOnDelete() throws Exception {
ArgumentCaptor<VppEndpointConfEvent> argVppEpEvent = ArgumentCaptor.forClass(VppEndpointConfEvent.class);
- VppEndpoint vppEndpoint = new VppEndpointBuilder().setAddress(ADDRESS)
- .setAddressType(AddressType.class)
- .setContextId(CONTEXT_ID)
- .setContextType(ContextType.class)
+ VppEndpoint vppEndpoint = getBaseVppEndpointBuilder()
.build();
InstanceIdentifier<VppEndpoint> vppEpIid =
InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, vppEndpoint.getKey()).build();
@Test
public void testOnSubtreeModified() throws Exception {
ArgumentCaptor<VppEndpointConfEvent> argVppEpEvent = ArgumentCaptor.forClass(VppEndpointConfEvent.class);
- VppEndpointBuilder vppEndpointBuilder = new VppEndpointBuilder().setAddress(ADDRESS)
- .setAddressType(AddressType.class)
- .setContextId(CONTEXT_ID)
- .setContextType(ContextType.class);
+ VppEndpointBuilder vppEndpointBuilder = getBaseVppEndpointBuilder();
VppEndpoint vppEndpoint = vppEndpointBuilder.build();
InstanceIdentifier<VppEndpoint> vppEpIid =
InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, vppEndpoint.getKey()).build();
WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.CONFIGURATION, vppEpIid, vppEndpoint);
wTx.submit().get();
- VppEndpoint modifiedVppEndpoint = vppEndpointBuilder.setVppInterfaceName(IFACE_NAME).build();
+ VppEndpoint modifiedVppEndpoint =
+ vppEndpointBuilder.setVppInterfaceName(IFACE_NAME).build();
wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.CONFIGURATION, vppEpIid, modifiedVppEndpoint);
wTx.submit().get();
assertEqualsOptional(modifiedVppEndpoint, capturedSecondVppEpEvent.getAfter());
}
+ private VppEndpointBuilder getBaseVppEndpointBuilder() {
+ return new VppEndpointBuilder().setAddress(ADDRESS)
+ .setAddressType(AddressType.class)
+ .setContextId(CONTEXT_ID)
+ .setContextType(ContextType.class)
+ .setInterfaceTypeChoice(new VhostUserCaseBuilder().setSocket(TEST_SOCKET).build())
+ .setVppNodeId(TEST_NODE)
+ .setVppInterfaceName(DEFAULT_IFACE_NAME);
+ }
+
private <T> void assertEqualsOptional(T expected, Optional<T> actual) {
if (expected == null) {
Assert.assertFalse(actual.isPresent());
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.locks.ReentrantLock;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpointKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.LocationProviders;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.LocationProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint_location_provider.rev160419.location.providers.location.provider.ProviderAddressEndpointLocation;
IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class);
private final static String SOCKET = "socket";
+ public static final TenantId TENANT = new TenantId("tenant");
+ public static final List<EndpointGroupId>
+ ENDPOINT_GROUP =
+ Collections.singletonList(new EndpointGroupId("default"));
+
private MountedDataBrokerProvider mountedDataProviderMock;
private DataBroker mountPointDataBroker;
private DataBroker dataBroker;
InstanceIdentifier<VppEndpoint> vppEpIid) {
AddressEndpoint addrEp = new AddressEndpointBuilder().setKey(new AddressEndpointKey(clientEp.getAddress(),
clientEp.getAddressType(), clientEp.getContextId(), clientEp.getContextType()))
+ .setTenant(TENANT)
+ .setEndpointGroup(ENDPOINT_GROUP)
.build();
InstanceIdentifier<AddressEndpoint> iid = InstanceIdentifier.create(Endpoints.class)
.child(AddressEndpoints.class)