use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class DhcpNeutronPortListener method processArpResponderForElanDpns.
/**
* Handle(Add/Remove) ARP Responder for DHCP IP on all the DPNs when DHCP is
* enabled/disabled on subnet add or update or delete.
*
* @param port
* DHCP port for which ARP Responder flow to be added when dhcp
* flag is enabled on the subnet or DHCP port for which ARP
* Responder flow to be removed when dhcp flag is disabled on the
* Subnet
* @param arpResponderAction
* ARP Responder Action to be performed i.e., add or remove flow
*/
private void processArpResponderForElanDpns(Port port, Consumer<ArpResponderInput> arpResponderAction) {
java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(port);
if (!ip4Address.isPresent()) {
LOG.warn("There is no IPv4Address for port {}, not performing ARP responder add/remove flow operation", port.getName());
return;
}
ElanHelper.getDpnInterfacesInElanInstance(broker, port.getNetworkId().getValue()).stream().map(ifName -> DhcpServiceUtils.getInterfaceInfo(interfaceManager, ifName)).forEach(interfaceInfo -> {
ArpResponderInput arpResponderInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(interfaceInfo.getDpId()).setInterfaceName(interfaceInfo.getInterfaceName()).setLportTag(interfaceInfo.getInterfaceTag()).setSha(port.getMacAddress().getValue()).setSpa(ip4Address.get()).build();
arpResponderAction.accept(arpResponderInput);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class DhcpNeutronPortListener method update.
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
LOG.trace("Port changed to {}", update);
// With Ipv6 changes we can get ipv4 subnets later. The below check is to support such scenario.
if (original.getFixedIps().size() < update.getFixedIps().size()) {
final String interfaceName = update.getUuid().getValue();
List<FixedIps> updatedFixedIps = update.getFixedIps();
// Need to check only the newly added fixed ip.
updatedFixedIps.removeAll(original.getFixedIps());
Subnet subnet = dhcpManager.getNeutronSubnet(updatedFixedIps);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.trace("Subnet is null/not ipv4 or not enabled {}", subnet);
return;
}
// Binding the DHCP service for an existing port because of subnet change.
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
})), DhcpMConstants.RETRY_COUNT);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
BigInteger dpnId = interfaceManager.getDpnForInterface(interfaceName);
if (dpnId == null || dpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install the DHCP flow since dpn is not available");
return Collections.emptyList();
}
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> dhcpManager.installDhcpEntries(dpnId, DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager), tx)));
}, DhcpMConstants.RETRY_COUNT);
}
if (!isVnicTypeDirectOrMacVtap(update)) {
LOG.trace("Port updated is normal {}", update.getUuid());
if (isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original Port was direct/macvtap {} so removing flows and cache entry if any", update.getUuid());
removePort(original);
}
return;
}
if (!isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original port was normal and updated is direct. Calling addPort()");
addPort(update);
return;
}
String macOriginal = getMacAddress(original);
String macUpdated = getMacAddress(update);
String segmentationIdOriginal = DhcpServiceUtils.getSegmentationId(original.getNetworkId(), broker);
String segmentationIdUpdated = DhcpServiceUtils.getSegmentationId(update.getNetworkId(), broker);
if (macOriginal != null && !macOriginal.equalsIgnoreCase(macUpdated) && segmentationIdOriginal != null && !segmentationIdOriginal.equalsIgnoreCase(segmentationIdUpdated)) {
LOG.trace("Mac/segment id has changed");
dhcpExternalTunnelManager.removeVniMacToPortCache(new BigInteger(segmentationIdOriginal), macOriginal);
dhcpExternalTunnelManager.updateVniMacToPortCache(new BigInteger(segmentationIdUpdated), macUpdated, update);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class DhcpSubnetListener method installDirectPortEntries.
private void installDirectPortEntries(List<Uuid> directPortList) {
LOG.trace("DhcpSubnetListener installDirectPortEntries : directPortList: {}", directPortList);
for (Uuid portIntf : directPortList) {
Port port = dhcpManager.getNeutronPort(portIntf.getValue());
String vmMacAddress = port.getMacAddress().getValue();
Uuid networkId = port.getNetworkId();
// install the entries on designated dpnId
List<BigInteger> listOfDpns = DhcpServiceUtils.getListOfDpns(dataBroker);
IpAddress tunnelIp = dhcpExternalTunnelManager.getTunnelIpBasedOnElan(networkId.getValue(), vmMacAddress);
if (null == tunnelIp) {
LOG.warn("DhcpSubnetListener installDirectPortEntries tunnelIP is null for port {}", portIntf);
continue;
}
BigInteger designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, networkId.getValue());
LOG.trace("CR-DHCP DhcpSubnetListener update Install DIRECT vmMacAddress: {} tunnelIp: {} " + "designatedDpnId : {} ListOf Dpn: {}", vmMacAddress, tunnelIp, designatedDpnId, listOfDpns);
dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, networkId.getValue(), listOfDpns, designatedDpnId, vmMacAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class DhcpSubnetListener method update.
@Override
protected void update(InstanceIdentifier<Subnet> identifier, Subnet original, Subnet update) {
LOG.trace("DhcpSubnetListener Update : Original dhcpstatus: {}, Updated dhcpstatus {}", original.isEnableDhcp(), update.isEnableDhcp());
if (!Objects.equals(original.isEnableDhcp(), update.isEnableDhcp())) {
// write api to get port list
SubnetmapBuilder subnetmapBuilder = getSubnetMapBuilder(dataBroker, update.getUuid());
List<Uuid> portList = subnetmapBuilder.getPortList();
List<Uuid> directPortList = subnetmapBuilder.getDirectPortList();
if (update.isEnableDhcp()) {
if (null != portList) {
// Install Entries for neutron ports
installNeutronPortEntries(portList);
}
if (null != directPortList) {
// install Entries for direct ports
installDirectPortEntries(directPortList);
}
} else {
if (null != portList) {
// UnInstall Entries for neutron ports
uninstallNeutronPortEntries(portList);
}
if (null != directPortList) {
// Uninstall Entries for direct ports
uninstallDirectPortEntries(directPortList);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class PodListener method onPodInterfacesChanged.
public void onPodInterfacesChanged(final DataObjectModification<Interface> dataObjectModification, final InstanceIdentifier<Pods> rootIdentifier, DataObjectModification<Pods> rootNode) {
Pods pods = rootNode.getDataAfter();
Pods podsBefore = rootNode.getDataBefore();
Interface podInterfaceBefore = dataObjectModification.getDataBefore();
Interface podInterfaceAfter = dataObjectModification.getDataAfter();
switch(dataObjectModification.getModificationType()) {
case DELETE:
remove(podsBefore, podInterfaceBefore);
break;
case SUBTREE_MODIFIED:
update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
break;
case WRITE:
if (podInterfaceBefore == null) {
add(rootIdentifier, pods, podInterfaceAfter);
} else {
update(rootIdentifier, pods, podsBefore, podInterfaceBefore, podInterfaceAfter);
}
break;
default:
LOG.error("Unhandled Modificiation Type{} for {}", dataObjectModification.getModificationType(), rootIdentifier);
}
}
Aggregations