From: Sridhar Gaddam Date: Wed, 11 Oct 2017 07:23:16 +0000 (+0530) Subject: Shell Commands to Display Ipv6Service Cache X-Git-Tag: release/oxygen~232 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=7def530565fb6937a623e5d8801dae879b21ebcb;p=netvirt.git Shell Commands to Display Ipv6Service Cache IPv6Service in netvirt maintains a cache of various Neutron resources to honor the Router Solicitation/Neighbor Solicitation requests (which are time sensitive) coming from the VMs spawned on the IPv6 Network. This patch implements the necessary shell commands to dump the ipv6Cache. Conflicts: vpnservice/features/vpnservice-features/pom.xml vpnservice/features/vpnservice-features/src/main/features/features.xml Change-Id: Ie1aed6d47da540e3fd94c6a8cc3eedf7b4954989 Signed-off-by: Sridhar Gaddam (cherry picked from commit 156124fda4f55fe7c1f34f1e4e8c0584441ad65f) --- diff --git a/vpnservice/features/odl-netvirt-impl/pom.xml b/vpnservice/features/odl-netvirt-impl/pom.xml index 74de22e20a..9af1c995c1 100644 --- a/vpnservice/features/odl-netvirt-impl/pom.xml +++ b/vpnservice/features/odl-netvirt-impl/pom.xml @@ -164,6 +164,11 @@ ipv6service-impl ${project.version} + + ${project.groupId} + ipv6service-shell + ${project.version} + ${project.groupId} statemanager-impl diff --git a/vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/IfMgr.java b/vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/IfMgr.java index c761dcd902..9cba3a1276 100644 --- a/vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/IfMgr.java +++ b/vpnservice/ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/IfMgr.java @@ -696,4 +696,36 @@ public class IfMgr { LOG.debug("re-started periodic RA Timer for routerIntf {}, int {}s", port.getIntfUUID(), Ipv6Constants.PERIODIC_RA_INTERVAL); } + + public List getInterfaceCache() { + List virtualPorts = new ArrayList<>(); + for (VirtualPort vport: vintfs.values()) { + virtualPorts.add(vport); + } + return virtualPorts; + } + + public List getNetworkCache() { + List virtualNetworks = new ArrayList<>(); + for (VirtualNetwork vnet: vnetworks.values()) { + virtualNetworks.add(vnet); + } + return virtualNetworks; + } + + public List getSubnetCache() { + List virtualSubnets = new ArrayList<>(); + for (VirtualSubnet vsubnet: vsubnets.values()) { + virtualSubnets.add(vsubnet); + } + return virtualSubnets; + } + + public List getRouterCache() { + List virtualRouter = new ArrayList<>(); + for (VirtualRouter vrouter: vrouters.values()) { + virtualRouter.add(vrouter); + } + return virtualRouter; + } } diff --git a/vpnservice/ipv6service/pom.xml b/vpnservice/ipv6service/pom.xml index 2978cb7718..e521cc7a9a 100644 --- a/vpnservice/ipv6service/pom.xml +++ b/vpnservice/ipv6service/pom.xml @@ -25,6 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL api impl + shell diff --git a/vpnservice/ipv6service/shell/pom.xml b/vpnservice/ipv6service/shell/pom.xml new file mode 100644 index 0000000000..32e10e8b75 --- /dev/null +++ b/vpnservice/ipv6service/shell/pom.xml @@ -0,0 +1,72 @@ + + + + + + org.opendaylight.netvirt + binding-parent + 0.6.0-SNAPSHOT + ../../commons/binding-parent + + + 4.0.0 + ipv6service-shell + ODL :: netvirt :: ${project.artifactId} + bundle + + + + org.apache.karaf.shell + org.apache.karaf.shell.console + provided + + + org.opendaylight.netvirt + ipv6service-impl + ${project.version} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + + + org.apache.karaf.shell.commands;version="[3.0.0,4.1)", + org.apache.karaf.shell.console;version="[3.0.0,4.1)", + * + + + + + + + + + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + + diff --git a/vpnservice/ipv6service/shell/src/main/java/org/opendaylight/netvirt/ipv6service/shell/ShowIpv6Command.java b/vpnservice/ipv6service/shell/src/main/java/org/opendaylight/netvirt/ipv6service/shell/ShowIpv6Command.java new file mode 100644 index 0000000000..998a6d2e16 --- /dev/null +++ b/vpnservice/ipv6service/shell/src/main/java/org/opendaylight/netvirt/ipv6service/shell/ShowIpv6Command.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.netvirt.ipv6service.shell; + +import java.util.List; +import org.apache.karaf.shell.commands.Argument; +import org.apache.karaf.shell.commands.Command; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.opendaylight.infrautils.utils.TablePrinter; +import org.opendaylight.netvirt.ipv6service.IfMgr; +import org.opendaylight.netvirt.ipv6service.VirtualNetwork; +import org.opendaylight.netvirt.ipv6service.VirtualPort; +import org.opendaylight.netvirt.ipv6service.VirtualRouter; +import org.opendaylight.netvirt.ipv6service.VirtualSubnet; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; + +@Command(scope = "ipv6service", name = "ipv6CacheShow", description = "Displays the IPv6Service Cache info") +public class ShowIpv6Command extends OsgiCommandSupport { + private IfMgr ifMgr = null; + + + @Argument(name = "resource", description = "List the various resource specific cache, where resource " + + "could be ", required = false, multiValued = false) + private final String listResource = null; + + private String getPortIpv6Addresses(VirtualPort vport) { + List ipv6Addresses = vport.getIpv6Addresses(); + StringBuffer str = new StringBuffer(); + for (Ipv6Address ipaddr: ipv6Addresses) { + str.append(ipaddr.getValue()); + str.append(" "); + } + return str.toString(); + } + + @Override + protected Object doExecute() throws Exception { + ifMgr = IfMgr.getIfMgrInstance(); + TablePrinter tp = new TablePrinter(); + + if (listResource != null) { + if (listResource.equalsIgnoreCase("networks") + || (listResource.equalsIgnoreCase("net"))) { + tp.setTitle("Network Cache List"); + tp.setColumnNames("Sno", "NetworkId", "dpnId"); + int count = 1; + List vnetworks = ifMgr.getNetworkCache(); + for (VirtualNetwork vnet: vnetworks) { + tp.addRow(count++, String.valueOf(vnet.getNetworkUuid().getValue()), vnet.getDpnsHostingNetwork()); + } + session.getConsole().print(tp.toString()); + } else if (listResource.equalsIgnoreCase("subnets") + || (listResource.equalsIgnoreCase("subnet"))) { + tp.setTitle("Subnet Cache List"); + tp.setColumnNames("Sno", "SubnetId", "SubnetCIDR", "ipVersion"); + int count = 1; + List vsubnets = ifMgr.getSubnetCache(); + for (VirtualSubnet vsubnet : vsubnets) { + tp.addRow(count++, String.valueOf(vsubnet.getSubnetUUID().getValue()), + String.valueOf(vsubnet.getSubnetCidr().getValue()), + vsubnet.getIpVersion()); + } + session.getConsole().print(tp.toString()); + } else if (listResource.equalsIgnoreCase("routers") + || (listResource.equalsIgnoreCase("router"))) { + tp.setTitle("Router Cache List"); + tp.setColumnNames("Sno", "RouterId"); + List vrouters = ifMgr.getRouterCache(); + int count = 1; + for (VirtualRouter vrouter : vrouters) { + tp.addRow(count++, String.valueOf(vrouter.getRouterUUID().getValue())); + } + session.getConsole().print(tp.toString()); + } + } else { + tp.setTitle("Interface Cache List"); + tp.setColumnNames("Sno", "PortId", "Mac Address", "Owner", "dpnId", "FixedIPs"); + List vports = ifMgr.getInterfaceCache(); + int count = 1; + for (VirtualPort vport: vports) { + String str = vport.getDeviceOwner(); + tp.addRow(count++, String.valueOf(vport.getIntfUUID().getValue()), vport.getMacAddress(), + (str.startsWith("network:")) ? str.substring(str.lastIndexOf(':') + 1) : "compute", + vport.getDpId(), getPortIpv6Addresses(vport)); + } + session.getConsole().print(tp.toString()); + } + return null; + } +} diff --git a/vpnservice/ipv6service/shell/src/main/resources/org/opendaylight/blueprint/blueprint.xml b/vpnservice/ipv6service/shell/src/main/resources/org/opendaylight/blueprint/blueprint.xml new file mode 100644 index 0000000000..65f0b86abd --- /dev/null +++ b/vpnservice/ipv6service/shell/src/main/resources/org/opendaylight/blueprint/blueprint.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + +