use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort in project netvirt by opendaylight.
the class ArpNotificationHandler method getSubnetId.
private String getSubnetId(String vpnName, String ip) {
// Check if this IP belongs to a router_interface
VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ip);
if (vpnPortipToPort != null && vpnPortipToPort.isSubnetIp()) {
List<Adjacency> adjacecnyList = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, vpnPortipToPort.getPortName());
for (Adjacency adjacency : adjacecnyList) {
if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
return adjacency.getSubnetId().getValue();
}
}
}
// Check if this IP belongs to a router_gateway
List<Uuid> routerIds = VpnUtil.getExternalNetworkRouterIds(dataBroker, new Uuid(vpnName));
for (Uuid routerId : routerIds) {
Uuid subnetId = VpnUtil.getSubnetFromExternalRouterByIp(dataBroker, routerId, ip);
if (subnetId != null) {
return subnetId.getValue();
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort in project netvirt by opendaylight.
the class ArpNotificationHandler method processArpLearning.
private void processArpLearning(String srcInterface, IpAddress srcIP, PhysAddress srcMac, BigInteger metadata, IpAddress dstIP) {
if (metadata != null && !Objects.equals(metadata, BigInteger.ZERO)) {
Optional<List<String>> vpnList = VpnUtil.getVpnHandlingIpv4AssociatedWithInterface(dataBroker, srcInterface);
if (vpnList.isPresent()) {
for (String vpnName : vpnList.get()) {
LOG.info("Received ARP for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIP.getIpv4Address().getValue(), srcInterface);
String ipToQuery = srcIP.getIpv4Address().getValue();
LOG.info("ARP being processed for Source IP {}", ipToQuery);
VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ipToQuery);
if (vpnPortipToPort != null) {
/* This is a well known neutron port and so should be ignored
* from being discovered
*/
continue;
}
LearntVpnVipToPort learntVpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
if (learntVpnVipToPort != null) {
String oldPortName = learntVpnVipToPort.getPortName();
String oldMac = learntVpnVipToPort.getMacAddress();
if (!oldMac.equalsIgnoreCase(srcMac.getValue())) {
// MAC has changed for requested IP
LOG.info("ARP Source IP/MAC data modified for IP {} with MAC {} and Port {}", ipToQuery, srcMac, srcInterface);
synchronized ((vpnName + ipToQuery).intern()) {
removeMipAdjacency(vpnName, oldPortName, srcIP);
VpnUtil.removeLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
putVpnIpToMigrateArpCache(vpnName, ipToQuery, srcMac);
}
}
} else if (!isIpInArpMigrateCache(vpnName, ipToQuery)) {
learnMacFromArpPackets(vpnName, srcInterface, srcIP, srcMac, dstIP);
}
}
} else {
LOG.info("ARP NO_RESOLVE: VPN not configured. Ignoring responding to ARP requests from this" + " Interface {}.", srcInterface);
return;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort in project netvirt by opendaylight.
the class NatUtil method getSubnetGwMac.
public static String getSubnetGwMac(DataBroker broker, Uuid subnetId, String vpnName) {
if (subnetId == null) {
LOG.error("getSubnetGwMac : subnetID is null");
return null;
}
InstanceIdentifier<Subnet> subnetInst = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, new SubnetKey(subnetId));
Optional<Subnet> subnetOpt = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, subnetInst);
if (!subnetOpt.isPresent()) {
LOG.error("getSubnetGwMac : unable to obtain Subnet for id : {}", subnetId);
return null;
}
IpAddress gatewayIp = subnetOpt.get().getGatewayIp();
if (gatewayIp == null) {
LOG.warn("getSubnetGwMac : No GW ip found for subnet {}", subnetId.getValue());
return null;
}
InstanceIdentifier<VpnPortipToPort> portIpInst = InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class, new VpnPortipToPortKey(gatewayIp.getIpv4Address().getValue(), vpnName)).build();
Optional<VpnPortipToPort> portIpToPortOpt = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, portIpInst);
if (portIpToPortOpt.isPresent()) {
return portIpToPortOpt.get().getMacAddress();
}
InstanceIdentifier<LearntVpnVipToPort> learntIpInst = InstanceIdentifier.builder(LearntVpnVipToPortData.class).child(LearntVpnVipToPort.class, new LearntVpnVipToPortKey(gatewayIp.getIpv4Address().getValue(), vpnName)).build();
Optional<LearntVpnVipToPort> learntIpToPortOpt = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.OPERATIONAL, learntIpInst);
if (learntIpToPortOpt.isPresent()) {
return learntIpToPortOpt.get().getMacAddress();
}
LOG.info("getSubnetGwMac : No resolution was found to GW ip {} in subnet {}", gatewayIp, subnetId.getValue());
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort in project netvirt by opendaylight.
the class ShowVpnIpToPort method doExecute.
@Override
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
protected Object doExecute() throws Exception {
if (vpnName == null && portFixedIp == null) {
getNeutronVpnPort();
getLearntVpnVipPort();
System.out.println(vpnPortipToPortList.size() + " Entries are present: ");
System.out.println("-----------------------------------------------------------------------");
System.out.println(String.format(" %s %24s %20s %32s", "VpnName", "IPAddress", "MacAddress", "Port"));
System.out.println("-----------------------------------------------------------------------");
for (VpnPortipToPort vpnPortipToPort : vpnPortipToPortList) {
System.out.println(String.format(" %-32s %-16s %-16s %-32s", vpnPortipToPort.getVpnName(), vpnPortipToPort.getPortFixedip(), vpnPortipToPort.getMacAddress(), vpnPortipToPort.getPortName()));
}
for (LearntVpnVipToPort learntVpnVipToPort : vpnVipToPortList) {
System.out.println(String.format("* %-32s %-16s %-16s %-32s", learntVpnVipToPort.getVpnName(), learntVpnVipToPort.getPortFixedip(), learntVpnVipToPort.getMacAddress(), learntVpnVipToPort.getPortName()));
}
System.out.println("\n * prefixed entries are Learned.");
System.out.println("\n" + getshowVpnCLIHelp());
} else if (portFixedIp == null || vpnName == null) {
System.out.println("Insufficient arguments" + "\nCorrect Usage : neutronvpn-port-show [<vpnName> <portFixedIp>]");
} else {
InstanceIdentifier<VpnPortipToPort> id = InstanceIdentifier.builder(NeutronVpnPortipPortData.class).child(VpnPortipToPort.class, new VpnPortipToPortKey(portFixedIp, vpnName)).build();
Optional<VpnPortipToPort> vpnPortipToPortData = syncReadOptional(dataBroker, CONFIGURATION, id);
if (vpnPortipToPortData.isPresent()) {
VpnPortipToPort data = vpnPortipToPortData.get();
System.out.println("\n----------" + "---------------------------------------------------------------------------------");
System.out.println("VpnName: " + data.getVpnName() + "\nIPAddress: " + data.getPortFixedip() + "\nMacAddress: " + data.getMacAddress() + "\nPort: " + data.getPortName());
System.out.println("\n----------" + "---------------------------------------------------------------------------------");
} else {
InstanceIdentifier<LearntVpnVipToPort> learntId = InstanceIdentifier.builder(LearntVpnVipToPortData.class).child(LearntVpnVipToPort.class, new LearntVpnVipToPortKey(portFixedIp, vpnName)).build();
Optional<LearntVpnVipToPort> learntVpnVipToPortData = syncReadOptional(dataBroker, OPERATIONAL, learntId);
if (!learntVpnVipToPortData.isPresent()) {
System.out.println("Data not available");
return null;
}
LearntVpnVipToPort data = learntVpnVipToPortData.get();
System.out.println("\n----------" + "---------------------------------------------------------------------------------");
System.out.println("VpnName: * " + data.getVpnName() + "\nIPAddress: " + data.getPortFixedip() + "\nMacAddress: " + data.getMacAddress() + "\nPort: " + data.getPortName());
System.out.println("\n----------" + "---------------------------------------------------------------------------------");
}
System.out.println("\n" + getshowVpnCLIHelp());
}
return null;
}
Aggregations