Fix inspection for 18.10, requirements 58/16058/2
authorjdenisco <jdenisco@cisco.com>
Tue, 20 Nov 2018 16:25:17 +0000 (11:25 -0500)
committerDave Barach <openvpp@barachs.net>
Tue, 20 Nov 2018 17:24:29 +0000 (17:24 +0000)
Change-Id: I1ecc278f43afff184a26f6f18fe22a49d8916eb1
Signed-off-by: jdenisco <jdenisco@cisco.com>
extras/vpp_config/setup.py
extras/vpp_config/vpp_config.py
extras/vpp_config/vpplib/AutoConfig.py
extras/vpp_config/vpplib/VPPUtil.py
extras/vpp_config/vpplib/VppPCIUtil.py

index 99d0ee2..b3a049c 100644 (file)
@@ -1,7 +1,7 @@
 from setuptools import setup
 
 setup(name="vpp_config",
-      version="18.01.11",
+      version="18.10.3",
       author="John DeNisco",
       author_email="jdenisco@cisco.com",
       description="VPP Configuration Utility",
@@ -9,7 +9,7 @@ setup(name="vpp_config",
       keywords="vppconfig",
       url = 'https://wiki.fd.io/view/VPP',
       py_modules=['vpp_config'],
-      install_requires=['pyyaml','netaddr'],
+      install_requires=['pyyaml','netaddr', 'requests'],
       packages=['vpplib'],
       scripts=['scripts/vpp-config'],
       data_files=[('vpp/vpp-config/scripts', ['scripts/dpdk-devbind.py']),
index 1182b24..75423b8 100755 (executable)
@@ -549,7 +549,7 @@ def autoconfig_main_menu():
 
     main_menu_text = '\nWhat would you like to do?\n\n\
 1) Show basic system information\n\
-2) Dry Run (Will save the configuration files in {}/vpp/vpp-config/dryrun for inspection)\n\
+2) Dry Run (Saves the configuration files in {}/vpp/vpp-config/dryrun.\n\
 3) Full configuration (WARNING: This will change the system configuration)\n\
 4) List/Install/Uninstall VPP.\n\
 q) Quit'.format(rootdir, rootdir)
index c36cdd5..2664a6a 100644 (file)
@@ -1048,10 +1048,11 @@ class AutoConfig(object):
                     if answer == 'y':
                         if 'unused' in device and len(device['unused']) != 0 and device['unused'][0] != '':
                             driver = device['unused'][0]
-                            VppPCIUtil.bind_vpp_device(node, driver, dvid)
-                        else:
-                            logging.debug('Could not bind device {}'.format(dvid))
-                        vppd[dvid] = device
+                            ret = VppPCIUtil.bind_vpp_device(node, driver, dvid)
+                            if ret:
+                                logging.debug('Could not bind device {}'.format(dvid))
+                            else:
+                                vppd[dvid] = device
                 for dit in vppd.items():
                     dvid = dit[0]
                     device = dit[1]
@@ -1081,11 +1082,12 @@ class AutoConfig(object):
                     if 'unused' in device and len(device['unused']) != 0 and device['unused'][0] != '':
                         driver = device['unused'][0]
                         logging.debug('Binding device {} to driver {}'.format(dvid, driver))
-                        VppPCIUtil.bind_vpp_device(node, driver, dvid)
-                    else:
-                        logging.debug('Could not bind device {}'.format(dvid))
-                    dpdk_devices[dvid] = device
-                    del other_devices[dvid]
+                        ret = VppPCIUtil.bind_vpp_device(node, driver, dvid)
+                        if ret:
+                            logging.debug('Could not bind device {}'.format(dvid))
+                        else:
+                            dpdk_devices[dvid] = device
+                            del other_devices[dvid]
 
     def update_interfaces_config(self):
         """
@@ -1162,11 +1164,12 @@ class AutoConfig(object):
                         if 'unused' in device and len(device['unused']) != 0 and device['unused'][0] != '':
                             driver = device['unused'][0]
                             logging.debug('Binding device {} to driver {}'.format(dvid, driver))
-                            VppPCIUtil.bind_vpp_device(node, driver, dvid)
-                        else:
-                            logging.debug('Could not bind device {}'.format(dvid))
-                        dpdk_devices[dvid] = device
-                        del kernel_devices[dvid]
+                            ret = VppPCIUtil.bind_vpp_device(node, driver, dvid)
+                            if ret:
+                                logging.debug('Could not bind device {}'.format(dvid))
+                            else:
+                                dpdk_devices[dvid] = device
+                                del kernel_devices[dvid]
 
             dlen = len(dpdk_devices)
             if dlen > 0:
@@ -1191,11 +1194,12 @@ class AutoConfig(object):
                         if 'unused' in device and len(device['unused']) != 0 and device['unused'][0] != '':
                             driver = device['unused'][0]
                             logging.debug('Binding device {} to driver {}'.format(dvid, driver))
-                            VppPCIUtil.bind_vpp_device(node, driver, dvid)
-                        else:
-                            logging.debug('Could not bind device {}'.format(dvid))
-                        kernel_devices[dvid] = device
-                        del dpdk_devices[dvid]
+                            ret = VppPCIUtil.bind_vpp_device(node, driver, dvid)
+                            if ret:
+                                logging.debug('Could not bind device {}'.format(dvid))
+                            else:
+                                kernel_devices[dvid] = device
+                                del dpdk_devices[dvid]
 
             interfaces = {}
             for dit in dpdk_devices.items():
@@ -1386,6 +1390,14 @@ class AutoConfig(object):
         else:
             print ("\nNo devices bound to DPDK drivers")
 
+        other_devs = vpp.get_other_devices()
+        if len(other_devs):
+            print ("\nDevices not bound to Kernel or DPDK drivers:")
+            vpp.show_vpp_devices(other_devs, show_interfaces=True,
+                                 show_header=False)
+        else:
+            print ("\nNo devices not bound to Kernel or DPDK drivers")
+
         vpputl = VPPUtil()
         interfaces = vpputl.get_hardware(node)
         if interfaces == {}:
@@ -1397,17 +1409,17 @@ class AutoConfig(object):
             print ("None")
             return
 
-        print "{:30} {:6} {:4} {:7} {:4} {:7}". \
-            format('Name', 'Socket', 'RXQs',
+        print "{:30} {:4} {:4} {:7} {:4} {:7}". \
+            format('Name', 'Numa', 'RXQs',
                    'RXDescs', 'TXQs', 'TXDescs')
         for intf in sorted(interfaces.items()):
             name = intf[0]
             value = intf[1]
             if name == 'local0':
                 continue
-            socket = rx_qs = rx_ds = tx_qs = tx_ds = ''
-            if 'cpu socket' in value:
-                socket = int(value['cpu socket'])
+            numa = rx_qs = rx_ds = tx_qs = tx_ds = ''
+            if 'numa' in value:
+                numa = int(value['numa'])
             if 'rx queues' in value:
                 rx_qs = int(value['rx queues'])
             if 'rx descs' in value:
@@ -1417,8 +1429,8 @@ class AutoConfig(object):
             if 'tx descs' in value:
                 tx_ds = int(value['tx descs'])
 
-            print ("{:30} {:>6} {:>4} {:>7} {:>4} {:>7}".
-                   format(name, socket, rx_qs, rx_ds, tx_qs, tx_ds))
+            print ("{:30} {:>4} {:>4} {:>7} {:>4} {:>7}".
+                   format(name, numa, rx_qs, rx_ds, tx_qs, tx_ds))
 
     @staticmethod
     def hugepage_info(node):
index 336097d..89e2d74 100644 (file)
@@ -138,7 +138,9 @@ class VPPUtil(object):
         # When using release
         reps += 'release/ubuntu {} main ./\n'.format(ubuntu_version)
         # When using master
-        # reps += 'master/ubuntu {} main/ ./\n'.format(ubuntu_version)
+        # reps += 'master/ubuntu {} main ./\n'.format(ubuntu_version)
+        # When using 1807
+        # reps += '1807/ubuntu {} main ./\n'.format(ubuntu_version)
 
         with open(sfile, 'w') as sfd:
             sfd.write(reps)
@@ -146,8 +148,8 @@ class VPPUtil(object):
 
         # Add the key
         key = requests.get('https://packagecloud.io/fdio/{}/gpgkey'.format('release'))
-        # cmd = 'curl -L https://packagecloud.io/fdio/{}/gpgkey | apt-key add -'.format(fdio_release)
-        # cmd = 'curl -L https://packagecloud.io/fdio/{}/gpgkey | apt-key add -'.format('mastert')
+        # key = requests.get('https://packagecloud.io/fdio/{}/gpgkey'.format('master'))
+        # key = requests.get('https://packagecloud.io/fdio/{}/gpgkey'.format('1807'))
         cmd = 'echo "{}" | apt-key add -'.format(key.content)
         (ret, stdout, stderr) = self.exec_command(cmd)
         if ret != 0:
@@ -541,19 +543,25 @@ class VPPUtil(object):
                 interfaces[name]['carrier'] = spl[1]
 
             # Socket
-            rfall = re.findall(r'cpu socket', line)
+            rfall = re.findall(r'numa \d+', line)
             if rfall:
-                spl = line.split('cpu socket ')
-                interfaces[name]['cpu socket'] = spl[1]
+                spl = rfall[0].split()
+                interfaces[name]['numa'] = rfall[0].split()[1]
 
             # Queues and Descriptors
-            rfall = re.findall(r'rx queues', line)
+            rfall = re.findall(r'rx\: queues \d+', line)
             if rfall:
-                spl = line.split(',')
-                interfaces[name]['rx queues'] = spl[0].lstrip(' ').split(' ')[2]
-                interfaces[name]['rx descs'] = spl[1].split(' ')[3]
-                interfaces[name]['tx queues'] = spl[2].split(' ')[3]
-                interfaces[name]['tx descs'] = spl[3].split(' ')[3]
+                interfaces[name]['rx queues'] = rfall[0].split()[2]
+                rdesc = re.findall(r'desc \d+', line)
+                if rdesc:
+                    interfaces[name]['rx descs'] = rdesc[0].split()[1]
+
+            rfall = re.findall(r'tx\: queues \d+', line)
+            if rfall:
+                interfaces[name]['tx queues'] = rfall[0].split()[2]
+                rdesc = re.findall(r'desc \d+', line)
+                if rdesc:
+                    interfaces[name]['tx descs'] = rdesc[0].split()[1]
 
         return interfaces
 
index 591dfab..fe64c9d 100644 (file)
@@ -14,6 +14,7 @@
 """VPP PCI Utility libraries"""
 
 import re
+import logging
 
 from vpplib.VPPUtil import VPPUtil
 
@@ -318,6 +319,7 @@ class VppPCIUtil(object):
         :type node: dict
         :type driver: string
         :type device_id: string
+        :returns ret: Command return code
         """
 
         rootdir = node['rootdir']
@@ -325,5 +327,9 @@ class VppPCIUtil(object):
         cmd = dpdk_script + ' -b ' + driver + ' ' + device_id
         (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
         if ret != 0:
-            raise RuntimeError('{} failed on node {} {} {}'.format(
+            logging.error('{} failed on node {}'.format(
                 cmd, node['host'], stdout, stderr))
+            logging.error('{} {}'.format(
+                stdout, stderr))
+
+        return ret