public GBPTenantPolicyCreator(DataBroker dataBroker, Intent intent) { this.dataProvider = dataBroker; this.intent = intent; this.mdsalUtils = new MdsalUtils(dataProvider); this.contractId = GBPRendererHelper.createUniqueId(); this.providerL3Addresses = new ArrayList<>(); this.consumerL3Addresses = new ArrayList<>(); this.bridgeDomainIds = new ArrayList<>(); this.l3ContextIds = new ArrayList<>(); this.providerNetworkDomainId = new NetworkDomainId(GBPRendererHelper.createUniqueId()); this.consumerNetworkDomainId = new NetworkDomainId(GBPRendererHelper.createUniqueId()); this.providerFloodDomainId = new L2FloodDomainId(GBPRendererHelper.createUniqueId()); this.consumerFloodDomainId = new L2FloodDomainId(GBPRendererHelper.createUniqueId()); }
L3Context getL3ContextForSubnet(IndexedTenant indexedTenant, Subnet subnet) { if (indexedTenant == null || subnet == null || subnet.getParent() == null) { return null; } return indexedTenant.resolveL3Context(new L2FloodDomainId(subnet.getParent().getValue())); }
private @Nullable L2BridgeDomainId resolveL2BridgeDomainId(EndpointL3 l3Ep, ReadTransaction rTx) { TenantId tenantId = l3Ep.getTenant(); Subnet subnetOfL3Ep = readSubnet(l3Ep, rTx); if (subnetOfL3Ep == null) { return null; } ContextId parentOfSubnet = subnetOfL3Ep.getParent(); if (parentOfSubnet == null) { return null; } L2ContextId l2ContextId = new L2ContextId(parentOfSubnet); Optional<L2BridgeDomain> potentialL2Bd = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.l2BridgeDomainIid(tenantId, new L2BridgeDomainId(l2ContextId)), rTx); if (potentialL2Bd.isPresent()) { return potentialL2Bd.get().getId(); } Optional<L2FloodDomain> potentialL2Fd = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.l2FloodDomainIid(tenantId, new L2FloodDomainId(l2ContextId)), rTx); if (!potentialL2Fd.isPresent()) { return null; } return potentialL2Fd.get().getParent(); }
@Deprecated private void removeTenantNetworkDomains(Network network, TenantId tenantId, ReadWriteTransaction rwTx) { L2FloodDomainId l2FdId = new L2FloodDomainId(network.getUuid().getValue()); Optional<L2FloodDomain> potentialL2Fd = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.l2FloodDomainIid(tenantId, l2FdId), rwTx); if (!potentialL2Fd.isPresent()) { LOG.warn("Illegal state - l2-flood-domain {} does not exist.", l2FdId.getValue()); return; } L2BridgeDomainId l2BdId = new L2BridgeDomainId(l2FdId); Optional<L2BridgeDomain> potentialL2Bd = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx); if (!potentialL2Bd.isPresent()) { LOG.warn("Illegal state - l2-bridge-domain {} does not exist.", l2BdId.getValue()); return; } L3ContextId l3CtxId = new L3ContextId(l2FdId); Optional<L3Context> potentialL3Ctx = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3CtxId), rwTx); if (!potentialL3Ctx.isPresent()) { LOG.warn("Illegal state - l3-context {} does not exist.", l3CtxId.getValue()); return; } } }
@Deprecated private void addProviderPhysicalNetworkMapping(TenantId tenantId, L2FloodDomainId l2FdId, String segmentationId, WriteTransaction wTx) { org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomain provNetAsL2Fd = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.neutron.gbp.mapper.rev150513.mappings.neutron.by.gbp.mappings.provider.physical.networks.as.l2.flood.domains.ProviderPhysicalNetworkAsL2FloodDomainBuilder().setTenantId( tenantId) .setL2FloodDomainId(new L2FloodDomainId(l2FdId.getValue())) .setSegmentationId(segmentationId) .build(); wTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.providerPhysicalNetworkAsL2FloodDomainIid(tenantId, l2FdId), provNetAsL2Fd); }
L2FloodDomainId consL2FldId = new L2FloodDomainId(consSubnet.getParent().getValue()); L2FloodDomain consFloodDomain = readL2FloodDomain(consL2FldId, tenantId); if (consFloodDomain == null) { return null; L2FloodDomainId provL2FldId = new L2FloodDomainId(provSubnet.getParent().getValue()); L2FloodDomain provFloodDomain = readL2FloodDomain(provL2FldId, tenantId); if (provFloodDomain == null) {
@Deprecated private void createTenantNetworkDomains(Network network, TenantId tenantId, ReadWriteTransaction rwTx) { Name name; L3ContextBuilder l3CtxBuilder = new L3ContextBuilder(); L2FloodDomainBuilder l2FdBuilder = new L2FloodDomainBuilder(); L2BridgeDomainBuilder l2BdBuilder = new L2BridgeDomainBuilder(); if (!Strings.isNullOrEmpty(network.getName())) { try { name = new Name(network.getName()); l3CtxBuilder.setName(name); l2FdBuilder.setName(name); l2BdBuilder.setName(name); } catch (Exception e) { name = null; LOG.info("Name of Neutron Network '{}' is ignored.", network.getName()); LOG.debug("Name exception", e); } } L2FloodDomainId l2FdId = new L2FloodDomainId(network.getUuid().getValue()); L3ContextId l3ContextId = new L3ContextId(l2FdId); L3Context l3Context = l3CtxBuilder.setId(l3ContextId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context, true); L2BridgeDomainId l2BdId = new L2BridgeDomainId(l2FdId); L2BridgeDomain l2Bd = l2BdBuilder.setId(l2BdId).setParent(l3Context.getId()).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2Bd, true); L2FloodDomain l2Fd = l2FdBuilder.setId(l2FdId).setParent(l2BdId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2FloodDomainIid(tenantId, l2FdId), l2Fd, true); }
addProviderPhysicalNetworkMapping(tenantId, new L2FloodDomainId(ctxId.getValue()), NetworkUtils.getSegmentationId(network), rwTx);
if (natIpSubnet != null && natIpSubnet.getParent() != null) { L2FloodDomain natEpl2Fd = ctx.getTenant(natL3Ep.getTenant()).resolveL2FloodDomain(new L2FloodDomainId(natIpSubnet.getParent().getValue())); if (natEpl2Fd != null && natEpl2Fd.getAugmentation(Segmentation.class) != null) { Integer vlanId = natEpl2Fd.getAugmentation(Segmentation.class).getSegmentationId(); L2FloodDomain l2Fd = ctx.getTenant(endpoint.getTenant()).resolveL2FloodDomain(new L2FloodDomainId(sub.getParent().getValue())); if (l2Fd == null) { return;
Subnet subnet = ctx.getTenant(extEp.getTenant()).resolveSubnet(new SubnetId(extEp.getNetworkContainment())); L2FloodDomain l2Fd = ctx.getTenant(extEp.getTenant()) .resolveL2FloodDomain(new L2FloodDomainId(subnet.getParent().getValue())); if (l2Fd != null) { Segmentation segmentation = l2Fd.getAugmentation(Segmentation.class);
L2FloodDomain l2Fd = null; if (extSubnet != null && extSubnet.getParent() != null) { l2Fd = tenant.resolveL2FloodDomain(new L2FloodDomainId(extSubnet.getParent().getValue()));
L2FloodDomainId l2fdId = new L2FloodDomainId(s.getParent().getValue()); L2BridgeDomain bd = tenant.resolveL2BridgeDomain(l2fdId); L2FloodDomain fd = tenant.resolveL2FloodDomain(l2fdId);