Add a non interactive mode
Change-Id: I2ebcb1acb43b4316e3dd48e83909d710dbef4e2f Signed-off-by: John DeNisco <jdenisco@cisco.com>
This commit is contained in:

committed by
Dave Barach

parent
ad2ddb1c06
commit
ddecfb3d9f
@ -1,23 +1,14 @@
|
||||
metadata:
|
||||
system_config_file: /vpp/vpp-config/configs/system-config.yaml
|
||||
version: 0.1
|
||||
metadata: {system_config_file: /vpp/vpp-config/configs/system-config.yaml, version: 0.1}
|
||||
nodes:
|
||||
DUT1:
|
||||
cpu:
|
||||
grub_config_file: /vpp/vpp-config/dryrun/default/grub
|
||||
reserve_vpp_main_core: true
|
||||
total_other_cpus: 0
|
||||
total_vpp_cpus: 2
|
||||
cpu: {grub_config_file: /vpp/vpp-config/dryrun/default/grub, reserve_vpp_main_core: false,
|
||||
total_other_cpus: 0, total_vpp_cpus: 0}
|
||||
host: localhost
|
||||
hugepages:
|
||||
hugepage_config_file: /vpp/vpp-config/dryrun/sysctl.d/80-vpp.conf
|
||||
total: '1024'
|
||||
interfaces:
|
||||
tcp:
|
||||
active_open_sessions: 0
|
||||
passive_open_sessions: 0
|
||||
hugepages: {hugepage_config_file: /vpp/vpp-config/dryrun/sysctl.d/80-vpp.conf,
|
||||
total: '1024'}
|
||||
interfaces: {}
|
||||
tcp: {active_open_sessions: 0, passive_open_sessions: 0}
|
||||
type: DUT
|
||||
vpp:
|
||||
startup_config_file: /vpp/vpp-config/dryrun/vpp/startup.conf
|
||||
unix:
|
||||
interactive: false
|
||||
unix: {interactive: false}
|
||||
|
@ -17,14 +17,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import vpp_config as vppcfg
|
||||
import vpp_config as vpp
|
||||
|
||||
# Check for root
|
||||
if not os.geteuid() == 0:
|
||||
sys.exit('\nPlease run the VPP Configuration Utility as root.')
|
||||
|
||||
# Setup
|
||||
vppcfg.autoconfig_setup()
|
||||
|
||||
# Main menu
|
||||
vppcfg.autoconfig_main()
|
||||
vpp.config_main()
|
||||
|
@ -1,7 +1,7 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(name="vpp_config",
|
||||
version="17.10.5",
|
||||
version="17.10.6",
|
||||
author="John DeNisco",
|
||||
author_email="jdenisco@cisco.com",
|
||||
description="VPP Configuration Utility",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,16 @@ MAX_PERCENT_FOR_HUGE_PAGES = 70
|
||||
class AutoConfig(object):
|
||||
"""Auto Configuration Tools"""
|
||||
|
||||
def __init__(self, rootdir, filename):
|
||||
def __init__(self, rootdir, filename, clean=False):
|
||||
"""
|
||||
The Auto Configure class.
|
||||
|
||||
:param rootdir: The root directory for all the auto configuration files
|
||||
:param filename: The autoconfiguration file
|
||||
:param clean: When set initialize the nodes from the auto-config file
|
||||
:type rootdir: str
|
||||
:type filename: str
|
||||
:type clean: bool
|
||||
"""
|
||||
self._autoconfig_filename = rootdir + filename
|
||||
self._rootdir = rootdir
|
||||
@ -52,6 +54,7 @@ class AutoConfig(object):
|
||||
self._nodes = {}
|
||||
self._vpp_devices_node = {}
|
||||
self._hugepage_config = ""
|
||||
self._clean = clean
|
||||
self._loadconfig()
|
||||
|
||||
def get_nodes(self):
|
||||
@ -84,6 +87,7 @@ class AutoConfig(object):
|
||||
if ret != 0:
|
||||
logging.debug(stderr)
|
||||
|
||||
# noinspection PyBroadException
|
||||
@staticmethod
|
||||
def _ask_user_ipv4():
|
||||
"""
|
||||
@ -189,7 +193,7 @@ class AutoConfig(object):
|
||||
raise RuntimeError("Couldn't read the Auto config file {}.".format(self._autoconfig_filename, exc))
|
||||
|
||||
systemfile = self._rootdir + self._metadata['system_config_file']
|
||||
if os.path.isfile(systemfile):
|
||||
if self._clean is False and os.path.isfile(systemfile):
|
||||
with open(systemfile, 'r') as sysstream:
|
||||
try:
|
||||
systopo = yaml.load(sysstream)
|
||||
@ -221,7 +225,7 @@ class AutoConfig(object):
|
||||
# Write the system config file
|
||||
filename = self._rootdir + self._metadata['system_config_file']
|
||||
with open(filename, 'w') as yamlfile:
|
||||
yaml.dump(ydata, yamlfile, default_flow_style=False)
|
||||
yaml.dump(ydata, yamlfile)
|
||||
|
||||
def _update_auto_config(self):
|
||||
"""
|
||||
@ -252,8 +256,8 @@ class AutoConfig(object):
|
||||
interface = item[1]
|
||||
|
||||
node['interfaces'][port] = {}
|
||||
node['interfaces'][port]['pci_address'] = \
|
||||
interface['pci_address']
|
||||
addr = '{}'.format(interface['pci_address'])
|
||||
node['interfaces'][port]['pci_address'] = addr
|
||||
if 'mac_address' in interface:
|
||||
node['interfaces'][port]['mac_address'] = \
|
||||
interface['mac_address']
|
||||
@ -281,7 +285,7 @@ class AutoConfig(object):
|
||||
|
||||
# Write the auto config config file
|
||||
with open(self._autoconfig_filename, 'w') as yamlfile:
|
||||
yaml.dump(ydata, yamlfile, default_flow_style=False)
|
||||
yaml.dump(ydata, yamlfile)
|
||||
|
||||
def apply_huge_pages(self):
|
||||
"""
|
||||
@ -327,7 +331,10 @@ class AutoConfig(object):
|
||||
|
||||
# Get main core
|
||||
cpu = '\n'
|
||||
if 'vpp_main_core' in node['cpu']:
|
||||
vpp_main_core = node['cpu']['vpp_main_core']
|
||||
else:
|
||||
vpp_main_core = 0
|
||||
if vpp_main_core is not 0:
|
||||
cpu += ' main-core {}\n'.format(vpp_main_core)
|
||||
|
||||
@ -696,7 +703,10 @@ class AutoConfig(object):
|
||||
# Get the isolated CPUs
|
||||
other_workers = node['cpu']['other_workers']
|
||||
vpp_workers = node['cpu']['vpp_workers']
|
||||
if 'vpp_main_core' in node['cpu']:
|
||||
vpp_main_core = node['cpu']['vpp_main_core']
|
||||
else:
|
||||
vpp_main_core = 0
|
||||
all_workers = []
|
||||
if other_workers is not None:
|
||||
all_workers = [other_workers]
|
||||
@ -943,10 +953,12 @@ other than VPP? [0-{}][0]? '.format(str(max_other_cores))
|
||||
node['cpu']['reserve_vpp_main_core'] = reserve_vpp_main_core
|
||||
node['cpu']['vpp_main_core'] = 0
|
||||
|
||||
def modify_cpu(self):
|
||||
def modify_cpu(self, ask_questions=True):
|
||||
"""
|
||||
Modify the cpu configuration, asking for the user for the values.
|
||||
|
||||
:param ask_questions: When true ask the user for config parameters
|
||||
|
||||
"""
|
||||
|
||||
# Get the CPU layout
|
||||
@ -990,9 +1002,11 @@ other than VPP? [0-{}][0]? '.format(str(max_other_cores))
|
||||
node['cpu']['cpus_per_node'] = cpus_per_node
|
||||
|
||||
# Ask the user some questions
|
||||
if ask_questions:
|
||||
self._modify_cpu_questions(node, total_cpus, numa_nodes)
|
||||
|
||||
# Populate the interfaces with the numa node
|
||||
if 'interfaces' in node:
|
||||
ikeys = node['interfaces'].keys()
|
||||
VPPUtil.get_interfaces_numa_node(node, *tuple(ikeys))
|
||||
|
||||
@ -1060,6 +1074,33 @@ other than VPP? [0-{}][0]? '.format(str(max_other_cores))
|
||||
dpdk_devices[dvid] = device
|
||||
del other_devices[dvid]
|
||||
|
||||
def update_interfaces_config(self):
|
||||
"""
|
||||
Modify the interfaces directly from the config file.
|
||||
|
||||
"""
|
||||
|
||||
for i in self._nodes.items():
|
||||
node = i[1]
|
||||
devices = node['devices']
|
||||
all_devices = devices['other_devices']
|
||||
all_devices.update(devices['dpdk_devices'])
|
||||
all_devices.update(devices['kernel_devices'])
|
||||
|
||||
current_ifcs = {}
|
||||
interfaces = {}
|
||||
if 'interfaces' in node:
|
||||
current_ifcs = node['interfaces']
|
||||
if current_ifcs:
|
||||
for ifc in current_ifcs.values():
|
||||
dvid = ifc['pci_address']
|
||||
if dvid in all_devices:
|
||||
VppPCIUtil.vpp_create_interface(interfaces, dvid,
|
||||
all_devices[dvid])
|
||||
node['interfaces'] = interfaces
|
||||
|
||||
self.updateconfig()
|
||||
|
||||
def modify_devices(self):
|
||||
"""
|
||||
Modify the devices configuration, asking for the user for the values.
|
||||
|
Reference in New Issue
Block a user