- /**
- * Create the {@link UnregisterEndpointInput} state needed to remove
- * the existing {@link Endpoint} from the Endpoint Registry.
- *
- * @param ep The {@link Endpoint} to remove from the registry
- * @return The {@link UnregisterEndpointInput}, null if failure
- */
- public static UnregisterEndpointInput createUnregisterEndpointInput(Endpoint ep) {
- UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder();
- L2 l2Ep = new L2Builder().setL2Context(ep.getL2Context()).setMacAddress(ep.getMacAddress()).build();
- inputBuilder.setL2(ImmutableList.of(l2Ep));
- // TODO Li msunal this has to be rewrite when OFOverlay renderer will support l3-endpoints.
- // Endpoint probably will not have l3-addresses anymore, because L2 and L3 endpoints should
- // be registered separately.
- if (ep.getL3Address() != null && !ep.getL3Address().isEmpty()) {
- List<L3> l3Eps = new ArrayList<>();
- for (L3Address ip : ep.getL3Address()) {
- l3Eps.add(new L3Builder().setL3Context(ip.getL3Context()).setIpAddress(ip.getIpAddress()).build());
- }
- inputBuilder.setL3(l3Eps);
- }
- return inputBuilder.build();
- }
-
- /**
- * Create the updated {@link RegisterEndpointInput}, using the existing
- * {@link Endpoint} and the new OfOverlay augmentation information (i.e.
- * port name, NodeId, and NodeConnectorId).
- *
- * @param ep The existing {@link Endpoint} state
- * @param portName The new port name in the OfOverlay augmentation
- * @param nodeIdString The new NodeId in the OfOverlay augmentation
- * @param nodeConnectorIdString The new NodeConnectorId in the OfOverlay augmentation
- * @return The new {@link RegisterEndpointInput}, null if failure
- */
- public static RegisterEndpointInput createRegisterEndpointInput(Endpoint ep,
- String portName, String nodeIdString, String nodeConnectorIdString) {
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId invNodeId =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId(nodeIdString);
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId ncId =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId(nodeConnectorIdString);
-
- RegisterEndpointInputBuilder inputBuilder = new RegisterEndpointInputBuilder().setL2Context(
- ep.getL2Context())
- .setMacAddress(new MacAddress(ep.getMacAddress()))
- .setTenant(new TenantId(ep.getTenant()))
- .setEndpointGroups(ep.getEndpointGroups())
- .addAugmentation(OfOverlayContextInput.class,
- new OfOverlayContextInputBuilder()
- .setPortName(new Name(portName))
- .setNodeId(invNodeId)
- .setNodeConnectorId(ncId)
- .build())
- .setTimestamp(System.currentTimeMillis());
-
- // TODO Li msunal this getting of just first IP has to be rewrite when OFOverlay renderer
- // will support l3-endpoints. Then we will register L2 and L3 endpoints separately.
- if (ep.getNetworkContainment() != null) {
- inputBuilder.setNetworkContainment(new SubnetId(ep.getNetworkContainment()));
- L3Address l3Address = new L3AddressBuilder()
- .setIpAddress(ep.getL3Address().get(0).getIpAddress())
- .setL3Context(ep.getL3Address().get(0).getL3Context())
- .build();
- inputBuilder.setL3Address(ImmutableList.of(l3Address));
- }
- return inputBuilder.build();