use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handleBgpVpnSubnetRoute.
private void handleBgpVpnSubnetRoute(IPv4 ipv4, byte[] srcMac, byte[] dstIp, String dstIpStr, String srcIpStr, long elanTag) throws UnknownHostException {
LOG.info("{} handleBgpVpnSubnetRoute: Processing IPv4 Packet received with Source IP {} and Target IP {}" + " and elan Tag {}", LOGGING_PREFIX, srcIpStr, dstIpStr, elanTag);
SubnetOpDataEntry targetSubnetForPacketOut = getTargetSubnetForPacketOut(dataBroker, elanTag, ipv4.getDestinationAddress());
if (targetSubnetForPacketOut != null) {
// Handle subnet routes ip requests
transmitArpPacket(targetSubnetForPacketOut.getNhDpnId(), srcIpStr, NWUtil.toStringMacAddress(srcMac), dstIp, elanTag);
} else {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.debug("{} handleBgpVpnSubnetRoute: Could not find target subnet for packet out {}", LOGGING_PREFIX, dstIpStr);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry in project netvirt by opendaylight.
the class SubnetmapChangeListener method update.
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void update(InstanceIdentifier<Subnetmap> identifier, Subnetmap subnetmapOriginal, Subnetmap subnetmapUpdate) {
LOG.debug("SubnetMapChangeListener update method - key {}, original {}, update {}", identifier, subnetmapOriginal, subnetmapUpdate);
Uuid subnetId = subnetmapUpdate.getId();
Network network = VpnUtil.getNeutronNetwork(dataBroker, subnetmapUpdate.getNetworkId());
if (network == null) {
LOG.error("SubnetMapChangeListener:update: network was not found for subnetId {}", subnetId.getValue());
return;
}
if (VpnUtil.getIsExternal(network)) {
LOG.debug("SubnetMapChangeListener:update: provider subnetwork {} is handling in " + "ExternalSubnetVpnInstanceListener", subnetId.getValue());
return;
}
String elanInstanceName = subnetmapUpdate.getNetworkId().getValue();
long elanTag = getElanTag(elanInstanceName);
if (elanTag == 0L) {
LOG.error("SubnetMapChangeListener:update: unable to fetch elantag from ElanInstance {} for subnetId {}", elanInstanceName, subnetId);
return;
}
// update on BGPVPN or InternalVPN change
Uuid vpnIdOld = subnetmapOriginal.getVpnId();
Uuid vpnIdNew = subnetmapUpdate.getVpnId();
if (!Objects.equals(vpnIdOld, vpnIdNew)) {
LOG.info("SubnetMapChangeListener:update: update subnetOpDataEntry for subnet {} imported in VPN", subnetmapUpdate.getId().getValue());
updateSubnetmapOpDataEntry(subnetmapOriginal.getVpnId(), subnetmapUpdate.getVpnId(), subnetmapUpdate, subnetmapOriginal, elanTag);
}
// update on Internet VPN Id change
Uuid inetVpnIdOld = subnetmapOriginal.getInternetVpnId();
Uuid inetVpnIdNew = subnetmapUpdate.getInternetVpnId();
if (!Objects.equals(inetVpnIdOld, inetVpnIdNew)) {
LOG.info("SubnetMapChangeListener:update: update subnetOpDataEntry for subnet {} imported in InternetVPN", subnetmapUpdate.getId().getValue());
updateSubnetmapOpDataEntry(inetVpnIdOld, inetVpnIdNew, subnetmapUpdate, subnetmapOriginal, elanTag);
}
// update on PortList change
List<Uuid> oldPortList;
List<Uuid> newPortList;
newPortList = subnetmapUpdate.getPortList() != null ? subnetmapUpdate.getPortList() : new ArrayList<>();
oldPortList = subnetmapOriginal.getPortList() != null ? subnetmapOriginal.getPortList() : new ArrayList<>();
if (newPortList.size() == oldPortList.size()) {
return;
}
LOG.info("SubnetMapChangeListener:update: update port list for subnet {}", subnetmapUpdate.getId().getValue());
if (newPortList.size() > oldPortList.size()) {
for (Uuid portId : newPortList) {
if (!oldPortList.contains(portId)) {
vpnSubnetRouteHandler.onPortAddedToSubnet(subnetmapUpdate, portId);
return;
}
}
} else {
for (Uuid portId : oldPortList) {
if (!newPortList.contains(portId)) {
vpnSubnetRouteHandler.onPortRemovedFromSubnet(subnetmapUpdate, portId);
return;
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry in project netvirt by opendaylight.
the class ShowSubnet method doExecute.
@Override
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
protected Object doExecute() throws Exception {
if (subnetmap == null && subnetopdata == null && (options == null || options.isEmpty())) {
getSubnet();
System.out.println("Following subnetId is present in both subnetMap and subnetOpDataEntry\n");
for (Subnetmap candidateSubnetmap : subnetmapList) {
SubnetOpDataEntry data = subnetOpDataEntryMap.get(candidateSubnetmap.getId());
if (data != null) {
System.out.println(candidateSubnetmap.getId().toString() + "\n");
}
}
System.out.println("\n\nFollowing subnetId is present in subnetMap but not in subnetOpDataEntry\n");
for (Subnetmap candidateSubnetmap : subnetmapList) {
SubnetOpDataEntry data = subnetOpDataEntryMap.get(candidateSubnetmap.getId());
if (data == null) {
System.out.println(candidateSubnetmap.getId().toString() + "\n");
}
}
getshowVpnCLIHelp();
} else if (subnetmap == null) {
InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(new Uuid(subnetopdata))).build();
Optional<SubnetOpDataEntry> optionalSubs = syncReadOptional(dataBroker, OPERATIONAL, subOpIdentifier);
SubnetOpDataEntry data = optionalSubs.get();
System.out.println("Fetching subnetmap for given subnetId\n");
System.out.println("------------------------------------------------------------------------------");
System.out.println("Key: " + data.getKey() + "\n" + "VrfId: " + data.getVrfId() + "\n" + "ElanTag: " + "" + data.getElanTag() + "\n" + "NhDpnId: " + data.getNhDpnId() + "\n" + "RouteAdvState: " + data.getRouteAdvState() + "\n" + "SubnetCidr: " + data.getSubnetCidr() + "\n" + "SubnetToDpnList: " + data.getSubnetToDpn() + "\n" + "VpnName: " + data.getVpnName() + "\n");
System.out.println("------------------------------------------------------------------------------");
}
if (subnetmap == null && subnetopdata != null) {
InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class).build();
Optional<SubnetOpDataEntry> optionalSubnetOpDataEntries = syncReadOptional(dataBroker, OPERATIONAL, subOpIdentifier);
if (optionalSubnetOpDataEntries.isPresent()) {
optionalSubnetOpDataEntries.asSet().forEach(subnetOpDataEntry -> {
SubnetOpDataEntry data = subnetOpDataEntry;
System.out.println("Fetching subnetmapdataentry for given subnetId\n");
System.out.println("------------------------" + "------------------------------------------------------");
System.out.println("Key: " + data.getKey() + "\n" + "VrfId: " + data.getVrfId() + "\n" + "ElanTag: " + "" + data.getElanTag() + "\n" + "NhDpnId: " + data.getNhDpnId() + "\n" + "RouteAdvState: " + data.getRouteAdvState() + "\n" + "SubnetCidr: " + data.getSubnetCidr() + "\n" + "SubnetToDpnList: " + data.getSubnetToDpn() + "\n" + "VpnName: " + data.getVpnName() + "\n");
System.out.println("------------------------" + "------------------------------------------------------");
});
}
}
if (subnetmap != null && subnetopdata == null) {
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(new Uuid(subnetmap))).build();
Optional<Subnetmap> sn = syncReadOptional(dataBroker, CONFIGURATION, id);
Subnetmap data = sn.get();
System.out.println("Fetching subnetopdata for given subnetId\n");
System.out.println("------------------------------------------------------------------------------");
String getRouterInterfacePortId = (data.getRouterInterfacePortId() != null ? data.getRouterInterfacePortId().getValue() : "null");
System.out.println("Key: " + data.getKey() + "\n" + "VpnId: " + data.getVpnId() + "\n" + "InternetVpnId: " + data.getInternetVpnId() + "\n" + "DirectPortList: " + data.getDirectPortList() + "\n" + "NetworkId: " + data.getNetworkId() + "\n" + "Network-type: " + data.getNetworkType() + "\n" + "Network-segmentation-Id: " + data.getSegmentationId() + "\n" + "PortList: " + data.getPortList() + "\n" + "RouterInterfaceFixedIp: " + data.getRouterInterfaceFixedIp() + "\n" + "RouterInterfacePortId: " + getRouterInterfacePortId + "\n" + "RouterIntfMacAddress: " + data.getRouterIntfMacAddress() + "\n" + "SubnetIp: " + data.getSubnetIp() + "\n" + "TenantId: " + data.getTenantId() + "\n");
System.out.println("------------------------------------------------------------------------------");
} else if (subnetopdata == null) {
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(new Uuid(subnetmap))).build();
Optional<Subnetmap> sn = syncReadOptional(dataBroker, CONFIGURATION, id);
Subnetmap data = sn.get();
System.out.println("Fetching subnetopdata for given subnetId\n");
System.out.println("------------------------------------------------------------------------------");
String getRouterInterfacePortId = (data.getRouterInterfacePortId() != null ? data.getRouterInterfacePortId().getValue() : "null");
System.out.println("Key: " + data.getKey() + "\n" + "VpnId: " + data.getVpnId() + "\n" + "InternetVpnId: " + data.getInternetVpnId() + "\n" + "DirectPortList: " + data.getDirectPortList() + "\n" + "NetworkId: " + data.getNetworkId() + "\n" + "Network-type: " + data.getNetworkType() + "\n" + "Network-segmentation-Id: " + data.getSegmentationId() + "\n" + "PortList: " + data.getPortList() + "\n" + "RouterInterfaceFixedIp: " + data.getRouterInterfaceFixedIp() + "\n" + "RouterInterfacePortId: " + getRouterInterfacePortId + "\n" + "RouterIntfMacAddress: " + data.getRouterIntfMacAddress() + "\n" + "SubnetIp: " + data.getSubnetIp() + "\n" + "TenantId: " + data.getTenantId() + "\n");
System.out.println("------------------------------------------------------------------------------");
} else {
InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(new Uuid(subnetopdata))).build();
Optional<SubnetOpDataEntry> optionalSubs = syncReadOptional(dataBroker, OPERATIONAL, subOpIdentifier);
SubnetOpDataEntry data = optionalSubs.get();
System.out.println("Fetching subnetmap for given subnetId\n");
System.out.println("------------------------------------------------------------------------------");
System.out.println("Key: " + data.getKey() + "\n" + "VrfId: " + data.getVrfId() + "\n" + "ElanTag: " + "" + data.getElanTag() + "\n" + "NhDpnId: " + data.getNhDpnId() + "\n" + "RouteAdvState: " + data.getRouteAdvState() + "\n" + "SubnetCidr: " + data.getSubnetCidr() + "\n" + "SubnetToDpnList: " + data.getSubnetToDpn() + "\n" + "VpnName: " + data.getVpnName() + "\n");
System.out.println("------------------------------------------------------------------------------");
}
Boolean optionsSubnetopdataall = false;
Boolean optionsSubnetmapall = false;
if (options != null && !options.isEmpty()) {
for (String opt : options) {
String optLowCase = opt == null ? "" : opt.toLowerCase(Locale.ENGLISH);
if (optLowCase.startsWith("subnetop")) {
optionsSubnetopdataall = true;
}
if (optLowCase.startsWith("subnetmap")) {
optionsSubnetmapall = true;
}
}
}
if (optionsSubnetopdataall) {
InstanceIdentifier<SubnetOpData> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).build();
Optional<SubnetOpData> optionalSubnetOpData = syncReadOptional(dataBroker, OPERATIONAL, subOpIdentifier);
if (optionalSubnetOpData.isPresent()) {
List<SubnetOpDataEntry> subnetOpDataEntryList = optionalSubnetOpData.get().getSubnetOpDataEntry();
System.out.println("number of subnetOpDataEntry found are : " + subnetOpDataEntryList + "\n");
subnetOpDataEntryList.forEach(subnetOpDataEntry -> {
SubnetOpDataEntry data = subnetOpDataEntry;
System.out.println("Fetching subnetmap for given subnetId\n");
System.out.println("------------------------" + "------------------------------------------------------");
System.out.println("Key: " + data.getKey() + "\n" + "VrfId: " + data.getVrfId() + "\n" + "ElanTag: " + "" + data.getElanTag() + "\n" + "NhDpnId: " + data.getNhDpnId() + "\n" + "RouteAdvState: " + data.getRouteAdvState() + "\n" + "SubnetCidr: " + data.getSubnetCidr() + "\n" + "SubnetToDpnList: " + data.getSubnetToDpn() + "\n" + "VpnName: " + data.getVpnName() + "\n");
System.out.println("------------------------" + "------------------------------------------------------");
});
} else {
System.out.println("No SubnetOpDataEntry present in Oper DS");
}
}
if (optionsSubnetmapall) {
InstanceIdentifier<Subnetmaps> subMapIdentifier = InstanceIdentifier.builder(Subnetmaps.class).build();
Optional<Subnetmaps> optionalSubnetmaps = syncReadOptional(dataBroker, CONFIGURATION, subMapIdentifier);
if (optionalSubnetmaps.isPresent()) {
List<Subnetmap> subnetMapList = optionalSubnetmaps.get().getSubnetmap();
System.out.println("number of subnetmaps found are : " + subnetMapList.size() + "\n");
subnetMapList.forEach(sn -> {
if (sn != null) {
System.out.println("Fetching subnetmap for given subnetId\n");
System.out.println("------------------------" + "------------------------------------------------------");
System.out.println("Uuid: " + sn.getId() + "\n" + "SubnetIp: " + sn.getSubnetIp() + "\n" + "NetworkId: " + sn.getNetworkId() + "\n" + "NetworkType: " + sn.getNetworkType() + "\nSegmentationId: " + sn.getSegmentationId() + "\n" + "TenantId: " + sn.getTenantId() + "\n" + "RouterId: " + sn.getRouterId() + "\n" + "RouterInterfacePortId: " + sn.getRouterInterfacePortId() + "\nRouterIntfMacAddress: " + sn.getRouterIntfMacAddress() + "\n" + "RouterInterfaceFixedIp: " + sn.getRouterInterfaceFixedIp() + "\n" + "VpnId: " + sn.getVpnId() + "\n" + "InternetVpnId: " + sn.getInternetVpnId() + "\n");
if (sn.getPortList() != null) {
System.out.println("There are " + sn.getPortList().size() + " port in the port-list");
for (int i = 0; i < sn.getPortList().size(); i++) {
System.out.println("\tport num " + i + " :\t" + sn.getPortList().get(i));
}
}
if (sn.getDirectPortList() != null) {
System.out.println("There are " + sn.getDirectPortList().size() + " port in the list of direct-port");
for (int i = 0; i < sn.getDirectPortList().size(); i++) {
System.out.println("\tdirect port num " + i + " :\t" + sn.getDirectPortList().get(i));
}
}
System.out.println("------------------------" + "------------------------------------------------------");
}
});
} else {
System.out.println("No Subnetmap present in Config DS");
}
}
getshowVpnCLIHelp();
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry in project netvirt by opendaylight.
the class ShowSubnet method getSubnet.
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
private void getSubnet() throws ReadFailedException {
List<SubnetOpDataEntry> subnetOpDataEntryList = new ArrayList<>();
InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build();
InstanceIdentifier<SubnetOpData> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).build();
Optional<Subnetmaps> optionalSubnetmaps = syncReadOptional(dataBroker, CONFIGURATION, subnetmapsid);
if (!optionalSubnetmaps.isPresent()) {
System.out.println("No Subnetmaps configured.");
} else {
subnetmapList = optionalSubnetmaps.get().getSubnetmap();
}
Optional<SubnetOpData> optionalSubnetOpData = syncReadOptional(dataBroker, OPERATIONAL, subOpIdentifier);
if (!optionalSubnetOpData.isPresent()) {
System.out.println("No SubnetOpData configured.");
} else {
subnetOpDataEntryList = optionalSubnetOpData.get().getSubnetOpDataEntry();
}
for (SubnetOpDataEntry subnetOpDataEntry : subnetOpDataEntryList) {
subnetOpDataEntryMap.put(subnetOpDataEntry.getSubnetId(), subnetOpDataEntry);
}
}
Aggregations