aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-10-18 16:17:42 -0400
committerTim Rozet <trozet@redhat.com>2017-10-19 13:27:54 +0000
commita6c3f2a2c853ca489cceff959a52d7f75bf4ffe0 (patch)
treed693e3aece18ef0c0d59106c00670f18d5b35fef
parent015505a597760e0dc451ce889e27421cc6eb1d99 (diff)
Avoid overwriting VPP startup scriptstable/euphrates
Currently we overwrite the entire VPP startup script if the content changes, this can cause content from other sources to be lost. This patch appends startup CLIs lines to startup script. Change-Id: Ifa3b18aa6370c79ad6ad3ce983f1648ff0d1d79d Signed-off-by: Feng Pan <fpan@redhat.com> (cherry picked from commit 91096196953f9619ab8435713a39f795a473f876)
-rw-r--r--os_net_config/utils.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/os_net_config/utils.py b/os_net_config/utils.py
index 95f17c6..f60a89d 100644
--- a/os_net_config/utils.py
+++ b/os_net_config/utils.py
@@ -479,7 +479,7 @@ def update_vpp_mapping(vpp_interfaces):
:param vpp_interfaces: List of VPP interface objects
"""
- vpp_start_cli = ""
+ cli_list = []
for vpp_int in vpp_interfaces:
if not vpp_int.pci_dev:
@@ -505,10 +505,11 @@ def update_vpp_mapping(vpp_interfaces):
% (vpp_int.name, vpp_int.pci_dev))
# Generate content of startup script for VPP
+ cli_list.append('set interface state %s up' % vpp_name)
for address in vpp_int.addresses:
- vpp_start_cli += 'set interface state %s up\n' % vpp_name
- vpp_start_cli += 'set interface ip address %s %s/%s\n' \
- % (vpp_name, address.ip, address.prefixlen)
+ cli_list.append('set interface ip address %s %s/%s\n'
+ % (vpp_name, address.ip,
+ address.prefixlen))
logger.info('Updating mapping for vpp interface %s:'
'pci_dev: %s mac address: %s uio driver: %s'
@@ -518,10 +519,16 @@ def update_vpp_mapping(vpp_interfaces):
vpp_int.uio_driver)
write_hiera(HIERADATA_FILE, {vpp_int.name: vpp_name})
- # Enable VPP service to make the VPP interface configuration
- # persistent.
- processutils.execute('systemctl', 'enable', 'vpp')
+ vpp_start_cli = get_file_data(_VPP_EXEC_FILE)
+ for cli_line in cli_list:
+ if not re.search(r'^\s*%s\s*$' % cli_line,
+ vpp_start_cli, re.MULTILINE):
+ vpp_start_cli += cli_line + '\n'
if diff(_VPP_EXEC_FILE, vpp_start_cli):
write_config(_VPP_EXEC_FILE, vpp_start_cli)
restart_vpp(vpp_interfaces)
+
+ # Enable VPP service to make the VPP interface configuration
+ # persistent.
+ processutils.execute('systemctl', 'enable', 'vpp')