/** * Creates an ordinal for the OfOverlay pipeline comparison, based on @TenantId and a * uniqueID (UUID) associated with any other attribute. * * @param tenantId the tenant id * @param id a unique id * @return the ordinal */ public static int getContextOrdinal(final TenantId tenantId, final UniqueId id) { if (tenantId == null || id == null) return 0; return getContextOrdinalFromString(tenantId.getValue() + "|" + id.getValue()); }
@VisibleForTesting boolean handledPolicy(ResolvedPolicy policy) { if (!policy.getConsumerTenantId().equals(policy.getProviderTenantId())) { // FAAS always assumes consumer and provider EPGs belong to the same tenant LOG.warn( "Ignore Resolved Policy between Consumer EPG {} and Provider EPG {} becuase they belong to different Tenants", policy.getConsumerTenantId().getValue(), policy.getProviderTenantId().getValue()); return false; } return isTenantRegistered(policy.getConsumerTenantId()); }
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()); }
public static String createFlowCacheName(InstanceIdentifier<Classifier> classifierIid, FlowCacheCons.Value value) { PolicyRuleGroupKey policyRuleGroup = classifierIid.firstKeyOf(PolicyRuleGroup.class); ResolvedRuleKey resolvedRule = classifierIid.firstKeyOf(ResolvedRule.class); ClassifierKey classifier = classifierIid.firstKeyOf(Classifier.class); StringBuilder sb = new StringBuilder(); sb.append(createStringFromCompositeKey(policyRuleGroup.getTenantId().getValue(), policyRuleGroup.getContractId().getValue(), policyRuleGroup.getSubjectName().getValue())) .append(DELIMETER) .append(resolvedRule.getName().getValue()) .append(DELIMETER) .append(classifier.getName().getValue()) .append(DELIMETER) .append(value.get()); return sb.toString(); }
@VisibleForTesting void executeEvent(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) { // Remove for (InstanceIdentifier<?> iid : change.getRemovedPaths()) { DataObject old = change.getOriginalData().get(iid); if (old == null) { continue; } if (old instanceof Tenant) { Tenant tenant = (Tenant) old; if (tenant.getId().equals(gbpTenantId)) { LOG.info("Removed gbp Tenant {} -- faas Tenant {}", gbpTenantId.getValue(), faasTenantId.getValue()); this.policyManager.removeTenantLogicalNetwork(gbpTenantId, faasTenantId); } } } } }
public Uuid getFaasTenantId(TenantId tenantId) { Uuid val = mappedTenants.get(tenantId); if (val != null) { return val; } Uuid faasTenantId; if (isUUid(tenantId.getValue())) { faasTenantId = new Uuid(tenantId.getValue()); } else { faasTenantId = new Uuid(UUID.randomUUID().toString()); } mappedTenants.putIfAbsent(tenantId, faasTenantId); val = mappedTenants.get(tenantId); MappedTenantBuilder builder = new MappedTenantBuilder(); builder.setFaasTenantId(val); builder.setGbpTenantId(tenantId); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); MappedTenant result = builder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, FaasIidFactory.mappedTenantIid(tenantId), result); if (DataStoreHelper.submitToDs(wTx)) { LOG.debug("Cached in Datastore Mapped Tenant {}", result); } else { LOG.error("Couldn't Cache in Datastore Mapped Tenant {}", result); } return val; }
@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()); } }
private void registerFollowedTenant(TenantId gbpTenantId, EndpointGroupId epgId) { FollowedTenantBuilder fTenantBuilder = new FollowedTenantBuilder(); fTenantBuilder.setId(gbpTenantId); if (epgId != null) { List<FollowedEndpointGroup> epgs = new ArrayList<>(); epgs.add(new FollowedEndpointGroupBuilder().setId(epgId).build()); fTenantBuilder.setFollowedEndpointGroup(epgs); } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.followedTenantIid(rendererName, gbpTenantId), fTenantBuilder.build()); if (DataStoreHelper.submitToDs(wTx)) { LOG.info("Tenant {} is followed by renderer {}", gbpTenantId.getValue(), rendererName.getValue()); } else { LOG.info("Couldn't register Tenant {} that is followed by renderer {}", gbpTenantId.getValue(), rendererName.getValue()); } }
String tenantName = netElements.getSrcEp().getTenant().getValue();