Apply sriov/FEC configuration during SX upgrade

During the SX we also need to apply the sriov/FEC manifest in order to
configure the FEC devices. This needs to be done before the sysinv agent
starts to maintain the host configuration.

Closes-Bug: 1929301
Change-Id: I99bd891bf43fd5912d0297861fce819fe6ce678f
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
This commit is contained in:
David Sullivan 2021-05-22 19:04:01 -05:00
parent 2264816a11
commit c6f0967086
1 changed files with 20 additions and 3 deletions

View File

@ -826,7 +826,7 @@ def migrate_hiera_data(from_release, to_release, role=None):
yaml.dump(static_config, yaml_file, default_flow_style=False)
def apply_sriov_config(db_credentials):
def apply_sriov_config(db_credentials, hostname):
# If controller-1 has any FEC devices or sriov vfs configured, apply the
# sriov runtime manifest. We can't apply it from controller-0 during the
# host-unlock process as controller-1 is running the new release.
@ -839,7 +839,7 @@ def apply_sriov_config(db_credentials):
conn = psycopg2.connect(connection_string)
cur = conn.cursor()
cur.execute(
"select id, mgmt_ip from i_host where hostname='controller-1';")
"select id, mgmt_ip from i_host where hostname=%s;", (hostname,))
host = cur.fetchone()
host_id = host[0]
mgmt_ip = host[1]
@ -1033,7 +1033,7 @@ def upgrade_controller(from_release, to_release):
LOG.info("Failed to update hiera configuration")
raise
apply_sriov_config(db_credentials)
apply_sriov_config(db_credentials, utils.CONTROLLER_1_HOSTNAME)
# Remove /etc/kubernetes/admin.conf after it is used to generate
# the hiera data
@ -1433,9 +1433,26 @@ def upgrade_controller_simplex(backup_file):
utils.execute_migration_scripts(
from_release, to_release, utils.ACTION_MIGRATE)
hostname = 'controller-0'
LOG.info("Generating config for %s" % hostname)
try:
cutils.create_system_config()
cutils.create_host_config(hostname)
except Exception as e:
LOG.exception(e)
LOG.info("Failed to update hiera configuration")
raise
# Runtime manifests may modify platform.conf, so we'll back it up
temp_platform_conf = PLATFORM_CONF_FILE + ".backup"
shutil.copy(PLATFORM_CONF_FILE, temp_platform_conf)
apply_sriov_config(db_credentials, hostname)
archive.close()
shutil.rmtree(staging_dir, ignore_errors=True)
# Restore platform.conf
shutil.move(temp_platform_conf, PLATFORM_CONF_FILE)
# Restore sysinv.conf
shutil.move("/etc/sysinv/sysinv-temp.conf", "/etc/sysinv/sysinv.conf")
# Restore fm.conf