use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpInterfaceAddJob method call.
@Override
public List<ListenableFuture<Void>> call() {
String interfaceName = interfaceAdd.getName();
LOG.trace("Received add DCN for interface {}, dpid {}", interfaceName, dpnId);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
if (iface != null) {
IfTunnel tunnelInterface = iface.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
if (!dpnId.equals(DhcpMConstants.INVALID_DPID)) {
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.debug("DHCP is not enabled for port {}", port.getName());
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));
LOG.info("DhcpInterfaceEventListener add isEnableDhcp:{}", subnet.isEnableDhcp());
futures.addAll(installDhcpEntries(interfaceAdd.getName(), dpnId));
LOG.trace("Checking ElanDpnInterface {} for dpn {} ", interfaceName, dpnId);
String subnetId = subnet.getUuid().getValue();
java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId);
if (!subnetToDhcp.isPresent()) {
return Collections.emptyList();
}
LOG.trace("Installing the Arp responder for interface {} with DHCP MAC {} & IP {}.", interfaceName, subnetToDhcp.get().getPortMacaddress(), subnetToDhcp.get().getPortFixedip());
ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
return futures;
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnNatManager method removeRouterFromExternalSubnets.
private void removeRouterFromExternalSubnets(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
LOG.debug("Removing routerID {} from external subnets of external network{}", routerId, externalNetworkId);
List<Subnets> fixedIpsSubnets = getSubnets(getExternalSubnetsUuidsSetForFixedIps(externalFixedIps));
for (Subnets subnets : fixedIpsSubnets) {
Uuid subnetId = subnets.getId();
List<Uuid> routerIds = subnets.getRouterIds();
if (routerIds != null) {
if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(externalNetworkId) && routerIds.contains(routerId)) {
routerIds.remove(routerId);
LOG.debug("Will remove routerIDs {} from external subnet {} router ID {}", routerIds, subnetId, routerId);
addExternalSubnet(externalNetworkId, subnetId, routerIds);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnNatManager method addRouterIdToExternalSubnet.
public void addRouterIdToExternalSubnet(Uuid networkId, Uuid subnetId, Uuid routerId) {
Optional<Subnets> optionalExternalSubnets = neutronvpnUtils.getOptionalExternalSubnets(subnetId);
if (optionalExternalSubnets.isPresent()) {
Subnets subnets = optionalExternalSubnets.get();
List<Uuid> routerIds;
if (subnets.getRouterIds() != null) {
routerIds = subnets.getRouterIds();
} else {
routerIds = new ArrayList<>();
}
if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(networkId) && !routerIds.contains(routerId)) {
LOG.debug("Will add routerID {} for external subnet {}.", routerId, subnetId);
routerIds.add(routerId);
updateExternalSubnet(networkId, subnetId, routerIds);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnNatManager method updateExternalSubnet.
public void updateExternalSubnet(Uuid networkId, Uuid subnetId, List<Uuid> routerIds) {
InstanceIdentifier<Subnets> subnetsIdentifier = InstanceIdentifier.builder(ExternalSubnets.class).child(Subnets.class, new SubnetsKey(subnetId)).build();
try {
Subnets newExternalSubnets = createSubnets(subnetId, networkId, routerIds);
LOG.debug("Updating external subnet {}", newExternalSubnets);
SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetsIdentifier, newExternalSubnets);
} catch (TransactionCommitFailedException ex) {
LOG.error("Update of External Subnets {} failed", subnetId, ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class NeutronvpnUtils method getSubnetIpPrefixes.
protected List<IpPrefixOrAddress> getSubnetIpPrefixes(Port port) {
List<Uuid> subnetIds = getSubnetIdsFromNetworkId(port.getNetworkId());
if (subnetIds == null) {
LOG.error("Failed to get Subnet Ids for the Network {}", port.getNetworkId());
return null;
}
List<IpPrefixOrAddress> subnetIpPrefixes = new ArrayList<>();
for (Uuid subnetId : subnetIds) {
Subnet subnet = getNeutronSubnet(subnetId);
if (subnet != null) {
subnetIpPrefixes.add(new IpPrefixOrAddress(subnet.getCidr()));
}
}
return subnetIpPrefixes;
}
Aggregations