def autoconfig_dryrun(ask_questions=True): """ Execute the dryrun function. :param ask_questions: When true ask the user for paraameters :type ask_questions: bool """ vutil = VPPUtil() pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) == 0: print "\nVPP is not installed, please install VPP." return acfg = AutoConfig(rootdir, VPP_AUTO_CONFIGURATION_FILE, clean=True) # Stop VPP on each node nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] VPPUtil.stop(node) # Discover acfg.discover() # Check the system resources nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] if not acfg.min_system_resources(node): return # Modify the devices if ask_questions: acfg.modify_devices() else: acfg.update_interfaces_config() # Modify CPU acfg.modify_cpu(ask_questions) # Calculate the cpu parameters acfg.calculate_cpu_parameters() # Acquire TCP stack parameters if ask_questions: acfg.acquire_tcp_params() # Apply the startup acfg.apply_vpp_startup() # Apply the grub configuration acfg.apply_grub_cmdline() # Huge Pages if ask_questions: acfg.modify_huge_pages() acfg.apply_huge_pages()
def autoconfig_apply(ask_questions=True): """ Apply the configuration. Show the diff of the dryrun file and the actual configuration file Copy the files from the dryrun directory to the actual file. Peform the system function :param ask_questions: When true ask the user questions :type ask_questions: bool """ vutil = VPPUtil() pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) == 0: print "\nVPP is not installed, Install VPP with option 4." return acfg = AutoConfig(rootdir, VPP_AUTO_CONFIGURATION_FILE) if ask_questions: print "\nWe are now going to configure your system(s).\n" answer = autoconfig_yn("Are you sure you want to do this [Y/n]? ", 'y') if answer == 'n': return nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] # Check the system resources if not acfg.min_system_resources(node): return # Stop VPP VPPUtil.stop(node) # Huge Pages ret = autoconfig_hugepage_apply(node, ask_questions) if ret != 0: return # VPP ret = autoconfig_vpp_apply(node, ask_questions) if ret != 0: return # Grub ret = autoconfig_grub_apply(node, ask_questions) if ret != 0: # We can still start VPP, even if we haven't configured grub VPPUtil.start(node) return # Everything is configured start vpp VPPUtil.start(node)
def autoconfig_apply(): """ Apply the configuration. Show the diff of the dryrun file and the actual configuration file Copy the files from the dryrun directory to the actual file. Peform the system function """ vutil = VPPUtil() pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) == 0: print "\nVPP is not installed, Install VPP with option 4." return acfg = AutoConfig(rootdir, VPP_AUTO_CONFIGURATION_FILE) print "\nWe are now going to configure your system(s).\n" answer = autoconfig_yn("Are you sure you want to do this [Y/n]? ", 'y') if answer == 'n': return nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] # Check the system resources if not acfg.min_system_resources(node): return # Huge Pages ret = autoconfig_hugepage_apply(node) if ret != 0: return # VPP ret = autoconfig_vpp_apply(node) if ret != 0: return # Grub ret = autoconfig_grub_apply(node) if ret != 0: return # Everything is configured start vpp cmd = "service vpp start" (ret, stdout, stderr) = VPPUtil.exec_command(cmd) if ret != 0: raise RuntimeError('{} failed on node {} {} {}'.format( cmd, node['host'], stdout, stderr))
def autoconfig_install(): """ Install or Uninstall VPP. """ # Since these commands will take a while, we # want to see the progress logger = logging.getLogger() acfg = AutoConfig(rootdir, VPP_AUTO_CONFIGURATION_FILE) vutil = VPPUtil() nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) > 0: print("\nThese packages are installed on node {}".format( node['host'])) print("{:25} {}".format("Name", "Version")) for pkg in pkgs: try: print("{:25} {}".format(pkg['name'], pkg['version'])) except KeyError: print("{}".format(pkg['name'])) question = "\nDo you want to uninstall these " question += "packages [y/N]? " answer = autoconfig_yn(question, 'n') if answer == 'y': logger.setLevel(logging.INFO) vutil.uninstall_vpp(node) else: print("\nThere are no VPP packages on node {}.".format( node['host'])) question = "Do you want to install VPP [Y/n]? " answer = autoconfig_yn(question, 'y') if answer == 'y': question = "Do you want to install the release version [Y/n]? " answer = autoconfig_yn(question, 'y') if answer == 'y': branch = 'release' else: branch = 'master' logger.setLevel(logging.INFO) vutil.install_vpp(node, branch) # Set the logging level back logger.setLevel(logging.ERROR)
def autoconfig_dryrun(): """ Execute the dryrun function. """ vutil = VPPUtil() pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) == 0: print "\nVPP is not installed, install VPP with option 4." return acfg = AutoConfig(rootdir, VPP_AUTO_CONFIGURATION_FILE) # Stop VPP on each node nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] VPPUtil.stop(node) # Discover acfg.discover() # Check the system resources nodes = acfg.get_nodes() for i in nodes.items(): node = i[1] if not acfg.min_system_resources(node): return # Modify the devices acfg.modify_devices() # Modify CPU acfg.modify_cpu() # Calculate the cpu parameters acfg.calculate_cpu_parameters() # Acquire TCP stack parameters acfg.acquire_tcp_params() # Apply the startup acfg.apply_vpp_startup() # Apply the grub configuration acfg.apply_grub_cmdline() # Huge Pages acfg.modify_huge_pages() acfg.apply_huge_pages()
def autoconfig_basic_test(): """ The auto configuration basic test menu """ vutil = VPPUtil() pkgs = vutil.get_installed_vpp_pkgs() if len(pkgs) == 0: print "\nVPP is not installed, install VPP with option 4." return answer = '' while answer != 'q': answer = autoconfig_basic_test_menu() if answer == '1': autoconfig_ipv4_setup() elif answer == '2': autoconfig_create_iperf_vm() elif answer == '9' or answer == 'q': return else: autoconfig_not_implemented()
def device_info(node): """ Show the device information. """ if 'cpu' in node and 'total_mbufs' in node['cpu']: total_mbufs = node['cpu']['total_mbufs'] if total_mbufs is not 0: print "Total Number of Buffers: {}".format(total_mbufs) vpp = VppPCIUtil(node) vpp.get_all_devices() linkup_devs = vpp.get_link_up_devices() if len(linkup_devs): print("\nDevices with link up (can not be used with VPP):") vpp.show_vpp_devices(linkup_devs, show_header=False) # for dev in linkup_devs: # print (" " + dev) kernel_devs = vpp.get_kernel_devices() if len(kernel_devs): print("\nDevices bound to kernel drivers:") vpp.show_vpp_devices(kernel_devs, show_header=False) else: print("\nNo devices bound to kernel drivers") dpdk_devs = vpp.get_dpdk_devices() if len(dpdk_devs): print("\nDevices bound to DPDK drivers:") vpp.show_vpp_devices(dpdk_devs, show_interfaces=True, show_header=False) else: print("\nNo devices bound to DPDK drivers") vpputl = VPPUtil() interfaces = vpputl.get_hardware(node) if interfaces == {}: return print("\nDevices in use by VPP:") if len(interfaces.items()) < 2: print("None") return print "{:30} {:6} {:4} {:7} {:4} {:7}". \ format('Name', 'Socket', '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']) if 'rx queues' in value: rx_qs = int(value['rx queues']) if 'rx descs' in value: rx_ds = int(value['rx descs']) if 'tx queues' in value: tx_qs = int(value['tx queues']) 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))