Bug 7403 : getl3vpn RPC behavioural issues 47/49547/4
authorAbhinav Gupta <abhinav.gupta@ericsson.com>
Mon, 19 Dec 2016 10:26:46 +0000 (15:56 +0530)
committerSam Hague <shague@redhat.com>
Wed, 11 Jan 2017 03:12:27 +0000 (03:12 +0000)
Following issues are fixed wrt getL3VPN RPC:

1. When fetches all VPNs and none is present, incorrectly shows error. >>
should display success

2. When all VPNs are deleted after being created, and then the RPC is used
to fetch for all VPNs and none is present, shows success by processing
wrongly. >> logic needs to be hardened.

3. when all VPNs are fetched, vlan-provider implicit VPNs should not be
displayed.

4. When specific VPN is fetched, internal VPNs corresponding to routers
should not be displayed.

5. When specific VPN is fetched, vlan-provider implicit VPNs should not be
displayed.

Change-Id: Ic08bd2fb5b1558e036531e7613e881a42adfd9b1
Signed-off-by: Abhinav Gupta <abhinav.gupta@ericsson.com>
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java

index 05a887583d419b8bdd8d9db122db41b4b0d89514..71b7dbfc51e8f0a871a432341b7e18044c20c64e 100644 (file)
@@ -944,32 +944,31 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even
                 // get all vpns
                 InstanceIdentifier<VpnInstances> vpnsIdentifier = InstanceIdentifier.builder(VpnInstances.class)
                         .build();
-                Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(dataBroker,
-                        LogicalDatastoreType.CONFIGURATION,
-                        vpnsIdentifier);
-                if (optionalVpns.isPresent() && optionalVpns.get().getVpnInstance() != null) {
+                Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType
+                        .CONFIGURATION, vpnsIdentifier);
+                if (optionalVpns.isPresent() && !optionalVpns.get().getVpnInstance().isEmpty()) {
                     for (VpnInstance vpn : optionalVpns.get().getVpnInstance()) {
-                        // eliminating internal VPNs from getL3VPN output
+                        // eliminating implicitly created (router and VLAN provider external network specific) VPNs
+                        // from getL3VPN output
                         if (vpn.getIpv4Family().getRouteDistinguisher() != null) {
                             vpns.add(vpn);
                         }
                     }
                 } else {
                     // No VPN present
-                    result.set(RpcResultBuilder.<GetL3VPNOutput>failed().withWarning(ErrorType.PROTOCOL, "", "No VPN " +
-                            "is present").build());
+                    result.set(RpcResultBuilder.<GetL3VPNOutput> success().withResult(opBuilder.build()).build());
                     return result;
                 }
             } else {
                 String name = inputVpnId.getValue();
                 InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class)
-                        .child(VpnInstance.class,
-                                new VpnInstanceKey(name))
-                        .build();
+                        .child(VpnInstance.class, new VpnInstanceKey(name)).build();
                 // read VpnInstance Info
                 Optional<VpnInstance> optionalVpn = NeutronvpnUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION,
                         vpnIdentifier);
-                if (optionalVpn.isPresent()) {
+                // eliminating implicitly created (router or VLAN provider external network specific) VPN from
+                // getL3VPN output
+                if (optionalVpn.isPresent() && optionalVpn.get().getIpv4Family().getRouteDistinguisher() != null) {
                     vpns.add(optionalVpn.get());
                 } else {
                     String message = String.format("GetL3VPN failed because VPN %s is not present", name);