@Test public void createIpSgtBindingItem() throws Exception { final Sgt sgt = new Sgt(42); final IpPrefix ipPrefix = new IpPrefix("10.11.12.42/32".toCharArray()); final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId("dummy-topology"))) .child(Node.class, new NodeKey(new NodeId("dummy-node-1"))); final PeerNode peerNode = new PeerNodeBuilder() .setNodeIid(nodeII) .build(); final AddressEndpointWithLocation addressEndpointWithLocation = new AddressEndpointWithLocationBuilder() .setAddressType(IpPrefixType.class) .setAddress(ipPrefix.getIpv4Prefix().getValue()) .setAbsoluteLocation(new AbsoluteLocationBuilder() .setLocationType(new ExternalLocationCaseBuilder() .setExternalNodeMountPoint(nodeII) .build()) .build()) .build(); final java.util.Optional<Binding> ipSgtBindingItem = PolicyManagerUtil.createIpSgtBindingItem(sgt, addressEndpointWithLocation); Assert.assertTrue(ipSgtBindingItem.isPresent()); final Binding binding = ipSgtBindingItem.get(); Assert.assertEquals(sgt, binding.getSgt()); Assert.assertEquals(ipPrefix, binding.getIpPrefix()); Assert.assertEquals(1, binding.getPeerNode().size()); Assert.assertEquals(peerNode, binding.getPeerNode().get(0)); }
public static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation) { final Optional<Binding> result; final LocationType locationType = addressEndpointWithLocation.getAbsoluteLocation().getLocationType(); if (IpPrefixType.class == addressEndpointWithLocation.getAddressType() && locationType instanceof ExternalLocationCase && sgt != null) { final Binding binding = new BindingBuilder() .setSgt(sgt) .setIpPrefix(new IpPrefix(addressEndpointWithLocation.getAddress().toCharArray())) .setPeerNode(Collections.singletonList(new PeerNodeBuilder() .setNodeIid(((ExternalLocationCase) locationType).getExternalNodeMountPoint()) .build())) .build(); result = Optional.ofNullable(binding); } else { result = Optional.empty(); } return result; }
PolicyManagerUtil { public static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation) { final Optional<Binding> result; final LocationType locationType = addressEndpointWithLocation.getAbsoluteLocation().getLocationType(); if (IpPrefixType.class == addressEndpointWithLocation.getAddressType() && locationType instanceof ExternalLocationCase && sgt != null) { final Binding binding = new BindingBuilder() .setSgt(sgt) .setIpPrefix(new IpPrefix(addressEndpointWithLocation.getAddress().toCharArray())) .setPeerNode(Collections.singletonList(new PeerNodeBuilder() .setNodeIid(((ExternalLocationCase) locationType).getExternalNodeMountPoint()) .build())) .build(); result = Optional.ofNullable(binding); } else { result = Optional.empty(); } return result; } }
PolicyManagerUtil { public static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation) { final Optional<Binding> result; final LocationType locationType = addressEndpointWithLocation.getAbsoluteLocation().getLocationType(); if (IpPrefixType.class == addressEndpointWithLocation.getAddressType() && locationType instanceof ExternalLocationCase && sgt != null) { final Binding binding = new BindingBuilder() .setSgt(sgt) .setIpPrefix(new IpPrefix(addressEndpointWithLocation.getAddress().toCharArray())) .setPeerNode(Collections.singletonList(new PeerNodeBuilder() .setNodeIid(((ExternalLocationCase) locationType).getExternalNodeMountPoint()) .build())) .build(); result = Optional.ofNullable(binding); } else { result = Optional.empty(); } return result; } private  PolicyManagerUtil(); }
PolicyManagerUtil { public static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation) { final Optional<Binding> result; final LocationType locationType = addressEndpointWithLocation.getAbsoluteLocation().getLocationType(); if (IpPrefixType.class == addressEndpointWithLocation.getAddressType() && locationType instanceof ExternalLocationCase && sgt != null) { final Binding binding = new BindingBuilder() .setSgt(sgt) .setIpPrefix(new IpPrefix(addressEndpointWithLocation.getAddress().toCharArray())) .setPeerNode(Collections.singletonList(new PeerNodeBuilder() .setNodeIid(((ExternalLocationCase) locationType).getExternalNodeMountPoint()) .build())) .build(); result = Optional.ofNullable(binding); } else { result = Optional.empty(); } return result; } private  PolicyManagerUtil(); static void syncEndpointPairCreatePolicy(final Sgt sourceSgt, final Sgt destinationSgt,
                                                    final PolicyConfigurationContext context, final Configuration data,
                                                    final PeerEndpoint peerEndpoint, final DataBroker dataBroker); static void syncEndpointPairRemovePolicy(final Sgt sourceSgt, final Sgt destinationSgt,
                                                    final PolicyConfigurationContext context, final Configuration data,
                                                    final PeerEndpoint peerEndpoint); @Nullable static Sgt findSgtTag(final EPToSgtMapper sxpEpProvider, final AddressEndpointKey endpointKey,
                                 final List<AddressEndpointWithLocation> endpointsWithLocation, final long timeout, final TimeUnit unit); static ServicePolicy createServicePolicy(final String chainName, final Direction direction); static InstanceIdentifier getMountpointIidFromAbsoluteLocation(final RendererEndpoint endpoint,
                                                                          final List<AddressEndpointWithLocation> endpointsWithLocation); static String getInterfaceNameFromAbsoluteLocation(final RendererEndpoint endpoint,
                                                              final List<AddressEndpointWithLocation> endpointsWithLocation); static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation); }
PolicyManagerUtil { public static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation) { final Optional<Binding> result; final LocationType locationType = addressEndpointWithLocation.getAbsoluteLocation().getLocationType(); if (IpPrefixType.class == addressEndpointWithLocation.getAddressType() && locationType instanceof ExternalLocationCase && sgt != null) { final Binding binding = new BindingBuilder() .setSgt(sgt) .setIpPrefix(new IpPrefix(addressEndpointWithLocation.getAddress().toCharArray())) .setPeerNode(Collections.singletonList(new PeerNodeBuilder() .setNodeIid(((ExternalLocationCase) locationType).getExternalNodeMountPoint()) .build())) .build(); result = Optional.ofNullable(binding); } else { result = Optional.empty(); } return result; } private  PolicyManagerUtil(); static void syncEndpointPairCreatePolicy(final Sgt sourceSgt, final Sgt destinationSgt,
                                                    final PolicyConfigurationContext context, final Configuration data,
                                                    final PeerEndpoint peerEndpoint, final DataBroker dataBroker); static void syncEndpointPairRemovePolicy(final Sgt sourceSgt, final Sgt destinationSgt,
                                                    final PolicyConfigurationContext context, final Configuration data,
                                                    final PeerEndpoint peerEndpoint); @Nullable static Sgt findSgtTag(final EPToSgtMapper sxpEpProvider, final AddressEndpointKey endpointKey,
                                 final List<AddressEndpointWithLocation> endpointsWithLocation, final long timeout, final TimeUnit unit); static ServicePolicy createServicePolicy(final String chainName, final Direction direction); static InstanceIdentifier getMountpointIidFromAbsoluteLocation(final RendererEndpoint endpoint,
                                                                          final List<AddressEndpointWithLocation> endpointsWithLocation); static String getInterfaceNameFromAbsoluteLocation(final RendererEndpoint endpoint,
                                                              final List<AddressEndpointWithLocation> endpointsWithLocation); static Optional<Binding> createIpSgtBindingItem(final Sgt sgt, final AddressEndpointWithLocation addressEndpointWithLocation);  }