Restore OVSIntPort interfaces after OVS restarts

There are 2 cases when OVS is restarted
1. Package Upgrade
2. OVS restart invoked by Puppet

Closes-Bug: 1737182
Change-Id: I69f5f80d1e359be72773e2622e1d3e90922d8b3b
This commit is contained in:
Sergii Golovatiuk 2017-12-12 17:14:35 +01:00
parent f57c9ef8de
commit a0a1984cd3
1 changed files with 30 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import json
import logging
import os
import platform
import re
import socket
import subprocess
import sys
@ -1385,6 +1386,27 @@ def _run_yum_update(instack_env):
LOG.info('yum-update completed successfully')
def _get_ovs_interfaces():
interfaces = glob.glob('/etc/sysconfig/network-scripts/ifcfg-*')
pattern = "OVSIntPort"
ovs_interfaces = []
for interface in interfaces:
with open(interface, "r") as text:
for line in text:
if re.findall(pattern, line):
# FIXME (holser). It might be better to get interface from
# DEVICE rather than name of file.
ovs_interfaces.append(interface.split('-')[-1])
return ovs_interfaces
def _run_restore_ovs_interfaces(interfaces):
for interface in interfaces:
LOG.info('Running restart OVS interface %s', interface)
_run_command(['sudo', 'ifup', interface])
LOG.info('Restart OVS interface %s completed successfully', interface)
def _run_orc(instack_env):
args = ['sudo', 'os-refresh-config']
LOG.info('Running os-refresh-config')
@ -1851,6 +1873,7 @@ def install(instack_root, upgrade=False):
_validate_configuration()
instack_env = _generate_environment(instack_root)
_generate_init_data(instack_env)
ovs_interfaces = _get_ovs_interfaces()
if upgrade:
# We didn't complete the M->N upgrades correctly with a
# `nova-manage db online_data_migrations` command before. This
@ -1869,10 +1892,17 @@ def install(instack_root, upgrade=False):
_die_tuskar_die()
if CONF.undercloud_update_packages:
_run_yum_clean_all(instack_env)
if ovs_interfaces:
_run_restore_ovs_interfaces(ovs_interfaces)
_run_yum_update(instack_env)
_handle_upgrade_fact(upgrade)
_run_instack(instack_env)
_run_orc(instack_env)
# FIXME (holser). The RC of issue is in OVS flow restore. Once
# 'systemctl reload openvswitch' is fixed ovs port restoration can be
# removed.
if ovs_interfaces:
_run_restore_ovs_interfaces(ovs_interfaces)
_post_config(instack_env, upgrade)
_run_command(['sudo', 'rm', '-f', '/tmp/svc-map-services'], None, 'rm')
if upgrade and CONF.enable_validations: # Run post-upgrade validations