use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps 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.neutronvpn.rev150602.Subnetmaps 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