/** * An endpoint is internal if none of its endpoint-groups is external implicit group. * * @param ep an endpoint * @param eigs external implicit groups * @return {@code true} if the given endpoint does not have EPG representing external implicit * group; * {@code false} otherwise * @throws NullPointerException if the given endpoint is {@code null} * @throws IllegalArgumentException if the given endpoint does not contain any endpoint-group */ public static boolean isInternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs) { Preconditions.checkNotNull(ep); if (eigs == null || eigs.isEmpty()) { return true; } Set<EndpointGroupId> epgs = getEpgs(ep); Preconditions.checkArgument(!epgs.isEmpty()); for (EndpointGroupId epg : epgs) { for (ExternalImplicitGroup eig : eigs) { if (epg.equals(eig.getId())) { return false; } } } return true; }
private boolean isSameEpg(RegisterEndpointInput epInput, AddressEndpoint input) { if (epInput == null || epInput.getAddressEndpointReg() == null || epInput.getAddressEndpointReg().isEmpty()) { return true; } final AddressEndpointReg epInputAddressEndpoint = epInput.getAddressEndpointReg().get(0); if (epInputAddressEndpoint.getEndpointGroup() == null || epInputAddressEndpoint.getEndpointGroup().isEmpty()) { return true; } if (input == null || input.getEndpointGroup() == null || input.getEndpointGroup().isEmpty()) { return true; } final EndpointGroupId addressEndpointGroupId = epInputAddressEndpoint.getEndpointGroup().get(0); final EndpointGroupId existingEndpointGroupId = input.getEndpointGroup().get(0); return addressEndpointGroupId.equals(existingEndpointGroupId); }
private void mapAllTenantResolvedPolicies(TenantId gbpTenantId, EndpointGroupId epgId) { Optional<ResolvedPolicies> resolvedPoliciesOptional = DataStoreHelper.readFromDs( LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(ResolvedPolicies.class).build(), dataProvider.newReadOnlyTransaction()); if (!resolvedPoliciesOptional.isPresent() || resolvedPoliciesOptional.get().getResolvedPolicy() == null) { return; } List<ResolvedPolicy> resolvedPolicies = resolvedPoliciesOptional.get().getResolvedPolicy(); for (ResolvedPolicy policy : resolvedPolicies) { if (policy.getConsumerTenantId().equals(gbpTenantId)) { if (epgId == null || epgId.equals(policy.getConsumerEpgId()) || epgId.equals(policy.getProviderEpgId())) { // if any epg or a specific epg policy updateLogicalNetwork(policy); } } } }
private boolean isEqualService(ResolvedPolicy newPolicy, ResolvedPolicy oldPolicy) { return oldPolicy != null && newPolicy.getConsumerEpgId().equals(oldPolicy.getConsumerEpgId()) && newPolicy.getProviderEpgId().equals(oldPolicy.getProviderEpgId()) && newPolicy.getConsumerTenantId().equals(oldPolicy.getConsumerTenantId()) && newPolicy.getProviderTenantId().equals(oldPolicy.getProviderTenantId()); }