use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class DhcpInterfaceEventListener method add.
@Override
public void add(InstanceIdentifier<Interface> identifier, Interface add) {
// We're only interested in Vlan and Tunnel ports
if (!L2vlan.class.equals(add.getType()) && !Tunnel.class.equals(add.getType())) {
return;
}
String interfaceName = add.getName();
LOG.trace("DhcpInterfaceAddJob to be created for interface {}", interfaceName);
List<String> ofportIds = add.getLowerLayerIf();
if (ofportIds == null || ofportIds.isEmpty()) {
return;
}
if (!Tunnel.class.equals(add.getType())) {
Port port = dhcpManager.getNeutronPort(interfaceName);
if (NeutronConstants.IS_DHCP_PORT.test(port)) {
return;
}
dhcpPortCache.put(interfaceName, port);
}
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
Uint64 dpnId = DhcpServiceUtils.getDpnIdFromNodeConnectorId(nodeConnectorId);
DhcpInterfaceAddJob job = new DhcpInterfaceAddJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, add, dpnId, interfaceManager, elanService, itmRpcService);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class DhcpSubnetListener method update.
@Override
public void update(InstanceIdentifier<Subnet> identifier, Subnet original, Subnet update) {
if (!config.isControllerDhcpEnabled()) {
return;
}
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.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class NatUtil method getNeutronPort.
private static Port getNeutronPort(DataBroker broker, String ifaceName) {
InstanceIdentifier<Port> portsIdentifier = InstanceIdentifier.create(Neutron.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports.class).child(Port.class, new PortKey(new Uuid(ifaceName)));
Optional<Port> portsOptional;
try {
portsOptional = SingleTransactionDataBroker.syncReadOptional(broker, LogicalDatastoreType.CONFIGURATION, portsIdentifier);
} catch (InterruptedException | ExecutionException e) {
LOG.error("Read Failed Exception While Reading Neutron Port for {}", ifaceName, e);
portsOptional = Optional.empty();
}
if (!portsOptional.isPresent()) {
LOG.error("getNeutronPort : No neutron ports found for interface {}", ifaceName);
return null;
}
return portsOptional.get();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class NatUtil method getNeutronPortForIp.
@Nullable
public static Port getNeutronPortForIp(DataBroker broker, IpAddress targetIP, String deviceType) {
List<Port> ports = getNeutronPorts(broker);
for (Port port : ports) {
if (deviceType.equals(port.getDeviceOwner()) && port.getFixedIps() != null) {
for (FixedIps ip : port.nonnullFixedIps().values()) {
if (Objects.equals(ip.getIpAddress(), targetIP)) {
return port;
}
}
}
}
LOG.error("getNeutronPortForIp : Neutron Port missing for IP:{} DeviceType:{}", targetIP, deviceType);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class NatVpnMapsChangeListener method handleDNATConfigurationForRouterAssociation.
void handleDNATConfigurationForRouterAssociation(String routerName, String vpnName, String externalNetwork) throws ExecutionException, InterruptedException {
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerName);
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("handleDNATConfigurationForRouterAssociation : Could not read Router Ports data " + "object with id: {} to handle associate vpn {}", routerName, vpnName);
return;
}
Uuid networkId = Uuid.getDefaultInstance(externalNetwork);
for (Ports port : optRouterPorts.get().nonnullPorts().values()) {
String portName = port.getPortName();
Uint64 dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
if (dpnId.equals(Uint64.ZERO)) {
LOG.warn("handleDNATConfigurationForRouterAssociation : DPN not found for {}, " + "skip handling of router {} association with vpn {}", portName, routerName, vpnName);
continue;
}
for (InternalToExternalPortMap intExtPortMap : port.nonnullInternalToExternalPortMap().values()) {
// remove all NAT related entries with routerName
// floatingIpListener.removeNATOnlyFlowEntries(dpnId, portName, routerName, null,
// intExtPortMap.getInternalIp(), externalIp);
// Create NAT entries with VPN Id
LOG.debug("handleDNATConfigurationForRouterAssociation : Updating DNAT flows with VPN metadata {} ", vpnName);
floatingIpListener.createNATOnlyFlowEntries(dpnId, routerName, vpnName, networkId, intExtPortMap);
}
}
}
Aggregations