use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleInternalVpnSubnetRoutePacket.
private void handleInternalVpnSubnetRoutePacket(BigInteger metadata, byte[] dstIp, String srcIpStr, String dstIpStr, int destinationAddress, String vpnIdVpnInstanceName, long elanTag) throws InterruptedException, ExecutionException, UnknownHostException {
String vmVpnInterfaceName = VpnUtil.getVpnInterfaceName(odlInterfaceRpcService, metadata);
if (isTunnel(vmVpnInterfaceName)) {
handlePacketFromTunnelToExternalNetwork(vpnIdVpnInstanceName, srcIpStr, dstIp, elanTag);
}
VpnInterface vmVpnInterface = VpnUtil.getVpnInterface(dataBroker, vmVpnInterfaceName);
if (vmVpnInterface == null) {
LOG.error("Vpn interface {} doesn't exist.", vmVpnInterfaceName);
VpnManagerCounters.subnet_route_packet_failed.inc();
return;
}
if (VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnIdVpnInstanceName, vmVpnInterface.getVpnInstanceNames()) && !VpnUtil.isBgpVpnInternet(dataBroker, vpnIdVpnInstanceName)) {
LOG.trace("Unknown IP is in internal network");
handlePacketToInternalNetwork(dstIp, dstIpStr, destinationAddress, elanTag);
} else {
LOG.trace("Unknown IP is in external network");
String vpnName = VpnUtil.getInternetVpnFromVpnInstanceList(dataBroker, vmVpnInterface.getVpnInstanceNames());
if (vpnName != null) {
handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, elanTag);
} else {
vpnName = VpnHelper.getFirstVpnNameFromVpnInterface(vmVpnInterface);
LOG.trace("Unknown IP is in external network, but internet VPN not found." + " fallback to first VPN");
handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), vpnName, dstIp, elanTag);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class SubnetmapChangeListener method add.
@Override
protected void add(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmap) {
LOG.debug("SubnetmapChangeListener add subnetmap method - key: {}, value: {}", identifier, subnetmap);
Uuid subnetId = subnetmap.getId();
Network network = VpnUtil.getNeutronNetwork(dataBroker, subnetmap.getNetworkId());
if (network == null) {
LOG.error("SubnetMapChangeListener:add: network was not found for subnetId {}", subnetId.getValue());
return;
}
if (VpnUtil.getIsExternal(network)) {
LOG.debug("SubnetmapListener:add: provider subnetwork {} is handling in " + "ExternalSubnetVpnInstanceListener", subnetId.getValue());
return;
}
String elanInstanceName = subnetmap.getNetworkId().getValue();
long elanTag = getElanTag(elanInstanceName);
if (elanTag == 0L) {
LOG.error("SubnetMapChangeListener:add: unable to fetch elantag from ElanInstance {} for subnet {}", elanInstanceName, subnetId.getValue());
return;
}
if (subnetmap.getVpnId() != null) {
boolean isBgpVpn = !subnetmap.getVpnId().equals(subnetmap.getRouterId());
LOG.info("SubnetMapChangeListener:add: subnetmap {} with elanTag {} to VPN {}", subnetmap, elanTag, subnetmap.getVpnId());
vpnSubnetRouteHandler.onSubnetAddedToVpn(subnetmap, isBgpVpn, elanTag);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class NetvirtProviderTest method getLogicalInterfacesFromNeutronNetwork.
@Test
public void getLogicalInterfacesFromNeutronNetwork() {
// Network doesnt exist
NeutronNetworkBuilder nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_NOEXIST_STR);
List<String> interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet list empty
createNetworkMap(NW_UUID_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet does not exist
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, false, EMPTY_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet exists, no ports
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, EMPTY_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet exists, port exists
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, PORT_UUID_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertFalse(interfaces.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class ExternalNetworkGroupInstaller method installExtNetGroupEntries.
public void installExtNetGroupEntries(Uuid networkId, BigInteger dpnId) {
if (networkId == null) {
return;
}
List<Uuid> subnetIds = NatUtil.getSubnetIdsFromNetworkId(broker, networkId);
if (subnetIds.isEmpty()) {
LOG.error("installExtNetGroupEntries : No subnet ids associated network id {}", networkId.getValue());
return;
}
for (Uuid subnetId : subnetIds) {
String macAddress = NatUtil.getSubnetGwMac(broker, subnetId, networkId.getValue());
installExtNetGroupEntry(networkId, subnetId, dpnId, macAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class ExternalNetworksChangeListener method update.
@Override
protected void update(InstanceIdentifier<Networks> identifier, Networks original, Networks update) {
// Check for VPN disassociation
Uuid originalVpn = original.getVpnid();
Uuid updatedVpn = update.getVpnid();
coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + update.getKey(), () -> {
WriteTransaction writeFlowInvTx = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (originalVpn == null && updatedVpn != null) {
// external network is dis-associated from L3VPN instance
associateExternalNetworkWithVPN(update, writeFlowInvTx);
} else if (originalVpn != null && updatedVpn == null) {
// external network is associated with vpn
disassociateExternalNetworkFromVPN(update, originalVpn.getValue());
// Remove the SNAT entries
removeSnatEntries(original, original.getId(), writeFlowInvTx);
}
futures.add(NatUtil.waitForTransactionToComplete(writeFlowInvTx));
return futures;
}, NatConstants.NAT_DJC_MAX_RETRIES);
}
Aggregations