use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPortKey in project netvirt by opendaylight.
the class VpnUtil method createLearntVpnVipToPort.
protected static void createLearntVpnVipToPort(DataBroker broker, String vpnName, String fixedIp, String portName, String macAddress) {
synchronized ((vpnName + fixedIp).intern()) {
InstanceIdentifier<LearntVpnVipToPort> id = buildLearntVpnVipToPortIdentifier(vpnName, fixedIp);
LearntVpnVipToPortBuilder builder = new LearntVpnVipToPortBuilder().setKey(new LearntVpnVipToPortKey(fixedIp, vpnName)).setVpnName(vpnName).setPortFixedip(fixedIp).setPortName(portName).setMacAddress(macAddress.toLowerCase(Locale.getDefault())).setCreationTime(new SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date()));
MDSALUtil.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, id, builder.build());
LOG.debug("createLearntVpnVipToPort: ARP learned for fixedIp: {}, vpn {}, interface {}, mac {}," + " added to VpnPortipToPort DS", fixedIp, vpnName, portName, macAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPortKey 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.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPortKey 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