private List<SubnetId> cloneAndGetEpgSubnets(EndpointGroupId epgId, TenantId tenantId) { synchronized (this) { List<SubnetId> list1 = epgSubnetsMap.get(new Pair<>(epgId, tenantId)); if (list1 == null) { return new ArrayList<>(); } List<SubnetId> list2 = new ArrayList<>(); for (SubnetId id : list1) { list2.add(new SubnetId(id)); } return list2; } }
@Deprecated private void removeTenantSubnet(TenantId tenantId, SubnetId subnetId, ReadWriteTransaction rwTx) { Optional<Subnet> potentialSubnet = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetId), rwTx); if (!potentialSubnet.isPresent()) { LOG.warn("Illegal state - subnet {} does not exist.", subnetId.getValue()); rwTx.cancel(); return; } } }
private @Nullable Subnet readSubnet(EndpointL3 l3Ep, ReadTransaction rTx) { NetworkDomainId l3EpNetworkContainment = l3Ep.getNetworkContainment(); if (l3EpNetworkContainment == null) { LOG.debug("L3 endpoint {} does not contain network containment.", l3Ep.getKey()); return null; } if (l3Ep.getTenant() == null) { LOG.debug("L3 endpoint {} does not contain tenat.", l3Ep.getKey()); return null; } Optional<Subnet> potentialSubnet = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(l3Ep.getTenant(), new SubnetId(l3EpNetworkContainment)), rTx); if (!potentialSubnet.isPresent()) { LOG.debug( "Network containment {} of L3 endpoint {} does not point to a subnet or the subnet does not exist.", l3EpNetworkContainment.getValue(), l3Ep.getKey()); return null; } return potentialSubnet.get(); }
public void loadAll(List<Subnet> subnets, List<MappedSubnet> mpSubnets) { if (mpSubnets != null) { for (MappedSubnet mpSubnet : mpSubnets) { mappedSubnets.putIfAbsent(mpSubnet.getGbpSubnetId(), mpSubnet.getFaasSubnetId()); } } if (subnets != null) { for (Subnet subnet : subnets) { LOG.debug("Loading Subnet {}", subnet.getId().getValue()); UlnDatastoreApi.submitSubnetToDs(initSubnetBuilder(subnet).build()); } } }
private Uuid getFaasSubnetId(Endpoint endpoint) { if (endpoint.getEndpointGroup() == null) { LOG.error("Failed Endpoint registration -- No Endpoint-Group Id in endpoint {}", endpoint); return null; } SubnetId subnetId = null; if (endpoint.getNetworkContainment() != null) { LOG.trace("Subnet is defined based on endpoint containment value {}", endpoint.getNetworkContainment() .getValue()); subnetId = new SubnetId(endpoint.getNetworkContainment()); } if (subnetId == null) { LOG.error("Failed Endpoint registration -- Couldn't find a subnet for endpoint {}", endpoint.getKey()); return null; } LOG.debug("Using subnetId {} for endpoint {}", subnetId, endpoint.getKey()); policyManager.registerSubnetWithEpg(endpoint.getEndpointGroup(), endpoint.getTenant(), subnetId); Optional<MappedSubnet> subnetOp = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, FaasIidFactory.mappedSubnetIid(endpoint.getTenant(), subnetId), dataProvider.newReadWriteTransaction()); if (subnetOp.isPresent()) { return subnetOp.get().getFaasSubnetId(); } LOG.error("Failed Endpoint registration -- Couldn't find Mapped Subnet Id based on GBP Subnet Id {}", subnetId); return null; }
private Uuid getFaasSubnetId(SubnetId subnetId) { Uuid val = mappedSubnets.get(subnetId); if (val != null) { return val; } Uuid faasSubnetId = null; if (FaasPolicyManager.isUUid(subnetId.getValue())) { faasSubnetId = new Uuid(subnetId.getValue()); } else { faasSubnetId = new Uuid(UUID.randomUUID().toString()); } mappedSubnets.putIfAbsent(subnetId, faasSubnetId); val = mappedSubnets.get(subnetId); MappedSubnetBuilder builder = new MappedSubnetBuilder(); builder.setFaasSubnetId(val); builder.setGbpSubnetId(subnetId); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); MappedSubnet result = builder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, FaasIidFactory.mappedSubnetIid(gbpTenantId, subnetId), result); if (DataStoreHelper.submitToDs(wTx)) { LOG.debug("Cached in Datastore Mapped Subnet {}", result); } else { LOG.error("Couldn't Cache in Datastore Mapped Subnet {}", result); } return val; }
private Subnet createSubnet(List<L3Address> endPoints, NetworkDomainId networkDomainId , L2FloodDomainId floodDomainId) { L3Address endPoint = endPoints.get(0); String ip = endPoint.getIpAddress().getIpv4Address().getValue(); ip = ip.substring(0, ip.lastIndexOf('.')) + ".1"; return new SubnetBuilder() .setId(new SubnetId(networkDomainId.getValue())) .setParent(new ContextId(floodDomainId.getValue())) .setVirtualRouterIp( GBPRendererHelper.createIpAddress(ip)) .setIpPrefix(GBPRendererHelper.createIpPrefix(ip + "/24")) .build(); }
List<Subnet> getLocalSubnets(NodeId nodeId) { Collection<Endpoint> endpointsForNode = ctx.getEndpointManager().getEndpointsForNode(nodeId); List<Subnet> localSubnets = new ArrayList<>(); for (Endpoint endpoint : endpointsForNode) { HashSet<Subnet> subnets = getSubnets(endpoint.getTenant()); if (subnets.isEmpty()) { LOG.debug("No local subnets in tenant {} for EP {}.", endpoint.getTenant(), endpoint.getKey()); continue; } NetworkDomainId epNetworkContainment = getEPNetworkContainment(endpoint, ctx.getTenant(endpoint.getTenant())); for (Subnet subnet : subnets) { if (epNetworkContainment.getValue().equals(subnet.getId().getValue())) { localSubnets.add(subnet); } } } return localSubnets; }
@Override public void onDeleted( org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet neutronSubnet, Neutron oldNeutron, Neutron newNeutron) { LOG.trace("deleted subnet - {}", neutronSubnet); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); NetworkDomainId subnetId = new NetworkDomainId(neutronSubnet.getUuid().getValue()); TenantId tenantId = new TenantId(neutronSubnet.getTenantId().getValue()); Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx); if (!potentialSubnetDomain.isPresent()) { LOG.warn("Illegal state - subnet network domain {} does not exist.", subnetId.getValue()); rwTx.cancel(); return; } removeTenantSubnet(tenantId, new SubnetId(subnetId), rwTx); // TODO remove default gateway EP in case when subnet is in provider physical network DataStoreHelper.submitToDs(rwTx); }
if (dao instanceof Subnet) { Subnet subnet = (Subnet) dao; LOG.debug("Subnet {} is Created.", subnet.getId().getValue()); UlnDatastoreApi.submitSubnetToDs(initSubnetBuilder(subnet).build()); if (entry.getValue() instanceof Subnet) { Subnet subnet = (Subnet) entry.getValue(); LOG.debug("Subnet {} is Updated.", subnet.getId().getValue()); UlnDatastoreApi.submitSubnetToDs(initSubnetBuilder(subnet).build());
@Deprecated public static Subnet createTenantSubnet( org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet subnet, IpAddress virtualRouterIp) { org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder subnetBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder(); subnetBuilder.setId(new SubnetId(subnet.getUuid().getValue())); subnetBuilder.setParent(new ContextId(subnet.getNetworkId().getValue())); if (!Strings.isNullOrEmpty(subnet.getName())) { try { subnetBuilder.setName(new Name(subnet.getName())); } catch (Exception e) { LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(), subnet.getUuid().getValue()); LOG.debug("Name exception", e); } } subnetBuilder.setIpPrefix(subnet.getCidr()); subnetBuilder.setVirtualRouterIp(virtualRouterIp); return subnetBuilder.build(); }
Subnet epSubnet = endpointTenant.resolveSubnet(new SubnetId(endpoint.getNetworkContainment())); Endpoint l2GatewayEp = utils.getL2EpOfSubnetGateway(endpoint.getTenant(), epSubnet); boolean peerEpIsExternal = peerEndpoint.getNetworkContainment() != null
new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder().setId(new SubnetId(ipWithSubnetFromGwPort.getSubnetId().getValue())) .setVirtualRouterIp(gatewayIp) .build();
builder.setName(new Text(gbpSubnet.getId().getValue())); if (gbpSubnet.getDescription() != null) builder.setDescription(new Text("gbp-subnet: " + gbpSubnet.getDescription().getValue()));
.resolveSubnet(new SubnetId(endpoint.getNetworkContainment()));
&& subnet.getVirtualRouterIp().getIpv6Address() != null) { LOG.warn("IPv6 virtual router {} for subnet {} not supported", subnet.getVirtualRouterIp(), subnet.getId() .getValue()); return;
.resolveSubnet(new SubnetId(peerEndpoint.getNetworkContainment()));
if (extEp.getNetworkContainment() != null && extEp.getNetworkContainment().equals(endpoint.getNetworkContainment())) { Subnet subnet = ctx.getTenant(extEp.getTenant()).resolveSubnet(new SubnetId(extEp.getNetworkContainment())); L2FloodDomain l2Fd = ctx.getTenant(extEp.getTenant()) .resolveL2FloodDomain(new L2FloodDomainId(subnet.getParent().getValue()));