@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; } } }
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(); }
public static Boolean contains(List<L2BridgeDomainId> l2Domains, L2BridgeDomainId l2Domain) { for (L2BridgeDomainId l2BridgeDomain : l2Domains) { if (l2BridgeDomain.getValue() != null && l2Domain.getValue() != null && l2BridgeDomain.getValue().equalsIgnoreCase(l2Domain.getValue())) { return true; } } return false; }
if (endpoint.getL2Context().equals(natL3Ep.getL2Context()) && endpoint.getMacAddress().equals(natL3Ep.getMacAddress())) { IpAddress natIpAddress = natL3Ep.getAugmentation(NatAddress.class).getNatAddress();
@Deprecated private static org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder createBasicEndpointInputBuilder( Port port) { return new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInputBuilder().setL2Context( new L2BridgeDomainId(port.getNetworkId().getValue())) .setMacAddress(new MacAddress(port.getMacAddress().getValue())) .setTenant(new TenantId(port.getTenantId().getValue())) .setTimestamp(System.currentTimeMillis()); }
epLocBuilder.setName(new Text(endpoint.getL2Context().getValue())); epLocBuilder.setTenantId(tenantId); epLocBuilder.setFaasPortRefId(endpoint.getAugmentation(FaasEndpointContext.class).getFaasPortRefId());
@Deprecated private void modifyForwardingOnDelete(Subnet routerPortSubnet, L3ContextId l3contextId, TenantId tenantId, ReadWriteTransaction rwTx) { L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue()); L2BridgeDomain l2Bd = new L2BridgeDomainBuilder().setId(l2BdId).setParent(l3contextId).build(); rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2Bd); // remove virtual router IP for subnet org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet tenantSubnet = NeutronSubnetAware.createTenantSubnet(routerPortSubnet, null); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, tenantSubnet.getId()), tenantSubnet); }
@Deprecated private void unregisterEndpointAndRemoveMapping( org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEpInput, Port port, ReadWriteTransaction rwTx) { boolean isUnregisteredEndpoint = epRegistrator.unregisterEndpoint(unregEpInput); if (isUnregisteredEndpoint) { UniqueId portId = new UniqueId(port.getUuid().getValue()); EndpointKey epKey = new EndpointKey(new L2BridgeDomainId(port.getNetworkId().getValue()), new MacAddress( port.getMacAddress().getValue())); LOG.trace("Removing Port-Endpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid() .getValue(), port.getDeviceOwner(), epKey); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.endpointByPortIid(portId), rwTx); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.portByEndpointIid(epKey.getL2Context(), epKey.getMacAddress()), rwTx); } }
@Deprecated private void registerEndpointAndStoreMapping( org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEpInput, Port port, ReadWriteTransaction rwTx) { boolean isRegisteredEndpoint = epRegistrator.registerEndpoint(regEpInput); if (!isRegisteredEndpoint) { LOG.error("Failed to register an endpoint: {}", regEpInput); return; } UniqueId portId = new UniqueId(port.getUuid().getValue()); EndpointKey epKey = new EndpointKey(new L2BridgeDomainId(port.getNetworkId().getValue()), new MacAddress( port.getMacAddress().getValue())); LOG.trace("Adding Port-Endpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid() .getValue(), port.getDeviceOwner(), epKey); EndpointByPort endpointByPort = MappingFactory.createEndpointByPort(epKey, portId); rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.endpointByPortIid(portId), endpointByPort, true); PortByEndpoint portByEndpoint = MappingFactory.createPortByEndpoint(portId, epKey); rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.portByEndpointIid(epKey.getL2Context(), epKey.getMacAddress()), portByEndpoint, true); }
@Deprecated private org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput createUnregisterEndpointInput( Port port, Neutron neutron) { org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder inputBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInputBuilder(); L2 l2Ep = new L2Builder().setL2Context(new L2BridgeDomainId(port.getNetworkId().getValue())) .setMacAddress(new MacAddress(port.getMacAddress().getValue())) .build(); inputBuilder.setL2(ImmutableList.of(l2Ep)); // we've registered EP with only first IP so remove only EP with first IP Optional<FixedIps> potentialFirstIp = PortUtils.resolveFirstFixedIps(port); if (potentialFirstIp.isPresent()) { FixedIps firstIp = potentialFirstIp.get(); L3Address l3Address = resolveL3AddressFromPort(port, firstIp, neutron); L3 l3 = new L3Builder().setIpAddress(l3Address.getIpAddress()) .setL3Context(l3Address.getL3Context()) .build(); inputBuilder.setL3(ImmutableList.of(l3)); } return inputBuilder.build(); }
@Deprecated private void processTenantForwarding(Subnet routerPortSubnet, ContextId routerL3Context, FixedIps portIpWithSubnet, TenantId tenantId, ReadWriteTransaction rwTx) { L2BridgeDomainId l2BdId = new L2BridgeDomainId(routerPortSubnet.getNetworkId().getValue()); L2BridgeDomain l2Bd = new L2BridgeDomainBuilder().setId(l2BdId).setParent(new L3ContextId(routerL3Context)).build(); rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2Bd, true); // set virtual router IP for subnet org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet subnet = NeutronSubnetAware.createTenantSubnet( routerPortSubnet, portIpWithSubnet.getIpAddress()); rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnet.getId()), subnet); }
rwTx.merge(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetWithGw.getId()), subnetWithGw); L2BridgeDomainId l2BdId = new L2BridgeDomainId(potentialSubnet.get().getNetworkId().getValue()); Optional<L2BridgeDomain> optBd = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), rwTx);
@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); }