@Nullable @Override public Comparable apply(@Nullable final EndpointGroupId input) { if (input == null) { return EMPTY_COMPARABLE; } return MoreObjects.firstNonNull(input.getValue(), EMPTY_COMPARABLE); } });
public static int getContextOrdinal(Endpoint ep, NetworkDomainId networkContainment) { Set<String> epgs = new TreeSet<>(); // Get EPGs and add to ordered Set if (ep.getEndpointGroup() != null) { epgs.add(ep.getEndpointGroup().getValue()); } if (ep.getEndpointGroups() != null) { for (EndpointGroupId epgId : ep.getEndpointGroups()) { epgs.add(epgId.getValue()); } } StringBuilder key = new StringBuilder(ep.getTenant().getValue()); for (String epg : epgs) { key.append('|'); key.append(epg); } key.append("|").append(networkContainment); return getContextOrdinalFromString(key.toString()); }
public static int getContextOrdinal(Endpoint ep) { Set<String> epgs = new TreeSet<>(); // Get EPGs and add to ordered Set if (ep.getEndpointGroup() != null) { epgs.add(ep.getEndpointGroup().getValue()); } if (ep.getEndpointGroups() != null) { for (EndpointGroupId epgId : ep.getEndpointGroups()) { epgs.add(epgId.getValue()); } } StringBuilder key = new StringBuilder(ep.getTenant().getValue()); for (String epg : epgs) { key.append('|'); key.append(epg); } return getContextOrdinalFromString(key.toString()); }
/*** * Gets the list of endpoints that matches an intent subject id * @param subjectId * @return */ private List<Endpoint> readEPNodes(String subjectId) { List<Endpoint> matchingGroup = new ArrayList<>(); InstanceIdentifier<Endpoints> nodePath = GBPRendererHelper.createEndpointsIdentifier(); Endpoints node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath); if (node != null) { for (Endpoint endpoint : node.getEndpoint()) { if (endpoint.getEndpointGroup().getValue().equalsIgnoreCase(subjectId)) { matchingGroup.add(endpoint); } } } else { LOG.error("Endpoints not found for the path {}", nodePath); } return matchingGroup; } }
@VisibleForTesting void registerFollowedEndpointgroup(TenantId gbpTenantId, EndpointGroupId epgId) { if (epgId == null) { return; } FollowedEndpointGroupBuilder fEpgBuilder = new FollowedEndpointGroupBuilder(); fEpgBuilder.setId(epgId); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.followedEndpointgroupIid(rendererName, gbpTenantId, epgId), fEpgBuilder.build()); if (DataStoreHelper.submitToDs(wTx)) { LOG.trace("EPG {} in Tenant {} is followed by renderer {}", epgId.getValue(), gbpTenantId.getValue(), rendererName.getValue()); } else { LOG.info("Couldn't register EPG {} in Tenant {} that is followed by renderer {}", epgId.getValue(), gbpTenantId.getValue(), rendererName.getValue()); } }
@Override public void onDeleted(SecurityGroup deletedSecGroup, Neutron oldNeutron, Neutron newNeutron) { LOG.trace("deleted securityGroup - {}", deletedSecGroup); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); TenantId tenantId = new TenantId(deletedSecGroup.getTenantId().getValue()); EndpointGroupId epgId = new EndpointGroupId(deletedSecGroup.getUuid().getValue()); Optional<EndpointGroup> potentialEpg = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, epgId), rwTx); if (!potentialEpg.isPresent()) { LOG.warn("Illegal state - Endpoint group {} does not exist.", epgId.getValue()); rwTx.cancel(); return; } DataStoreHelper.submitToDs(rwTx); }
private LogicalSwitchBuilder initLogicalSwitchBuilder(EndpointGroup epg, Uuid tenantId) { LogicalSwitchBuilder builder = new LogicalSwitchBuilder(); builder.setAdminStateUp(true); builder.setName(new Text(epg.getId().getValue())); if (epg.getDescription() != null) builder.setDescription(new Text("gbp-epg: " + epg.getDescription().getValue())); else builder.setDescription(new Text("gbp-epg")); builder.setTenantId(tenantId); builder.setUuid(new Uuid(UUID.randomUUID().toString())); return builder; }
private LogicalRouterBuilder initLogicalRouterBuilder(EndpointGroup epg, Uuid tenantId, boolean isPublic) { LogicalRouterBuilder builder = new LogicalRouterBuilder(); builder.setAdminStateUp(true); builder.setName(new Text(epg.getId().getValue())); if (epg.getDescription() != null) builder.setDescription(new Text("gbp-epg: " + epg.getDescription().getValue())); else builder.setDescription(new Text("gbp-epg")); builder.setPublic(isPublic); builder.setTenantId(tenantId); builder.setUuid(new Uuid(UUID.randomUUID().toString())); return builder; }
private LogicalNetworkBuilder buildLayer2LogicalNetwork(EndpointGroup consEpg, EndpointGroup provEpg, TenantId gbpTenantId, Uuid layer2SecRulesId, ExternalImplicitGroup externalImplicitGroup) { LOG.trace("Start buildLayer2LogicalNetwork: Consumer EPG {} Provider Epg {}", consEpg.getId().getValue(), provEpg.getId().getValue()); List<SubnetId> consSubnetIds = cloneAndGetEpgSubnets(consEpg.getId(), gbpTenantId); List<Uuid> consFaasSubnetIds = new ArrayList<>(); consEpg.getId().getValue()); return null; provEpg.getId().getValue()); return null;
protected void createLayer3LogicalNetwork(EndpointGroup consEpg, ContractId contractId, EndpointGroup provEpg, TenantId gbpTenantId, ServiceCommunicationLayer comLayer, ExternalImplicitGroup externalImplicitGroup) { LOG.trace("Start createLayer3LogicalNetwork: Consumer EPG {} Provider Epg {} Contract {}", consEpg.getId() .getValue(), provEpg.getId().getValue(), contractId); LogicalNetworkBuilder lNetbuilder = buildLayer2LogicalNetwork(consEpg, provEpg, gbpTenantId, null, externalImplicitGroup); LOG.error("Couldn't Cache in Datastore Mapped Logical Network {}", result); LOG.debug("Created Layer 3 Logical network consEpg {}, contractId {}, provEpg {}", consEpg.getId().getValue(), contractId.getValue(), provEpg.getId().getValue());
public boolean addNeutronSecurityGroup(SecurityGroup secGroup, ReadWriteTransaction rwTx) { TenantId tId = new TenantId(secGroup.getTenantId().getValue()); EndpointGroupId epgId = new EndpointGroupId(secGroup.getUuid().getValue()); if (epgId.getValue().equals(MappingUtils.EIG_UUID.getValue())) { ExternalImplicitGroup eig = new ExternalImplicitGroupBuilder().setId(epgId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tId, epgId), eig, true); } EndpointGroupBuilder epgBuilder = new EndpointGroupBuilder().setId(epgId); if (!Strings.isNullOrEmpty(secGroup.getName())) { try { epgBuilder.setName(new Name(secGroup.getName())); } catch (Exception e) { LOG.info("Name '{}' of Neutron Security-group '{}' is ignored.", secGroup.getName(), secGroup.getUuid().getValue()); LOG.debug("Name exception", e); } } epgBuilder.setIntraGroupPolicy(IntraGroupPolicy.RequireContract); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tId, epgId), epgBuilder.build(), true); return true; }
protected void createLayer2LogicalNetwork(EndpointGroup consEpg, ContractId contractId, EndpointGroup provEpg, TenantId gbpTenantId, ServiceCommunicationLayer comLayer, ExternalImplicitGroup externalImplicitGroup) { LOG.trace("Start createLayer2LogicalNetwork: Consumer EPG {} Provider Epg {} Contract {}", consEpg.getId() .getValue(), provEpg.getId().getValue(), contractId); Uuid secRulesId = getFaasSecRulesId(contractId, gbpTenantId); if (secRulesId == null) { LOG.error("Couldn't Cache in Datastore Mapped Logical Network {}", result); LOG.debug("Created Layer 2 Logical network consEpg {}, contractId {}, provEpg {}", consEpg.getId().getValue(), contractId.getValue(), provEpg.getId().getValue());