From 53f6f3bcb6bf0cb90481ab5ed77b715401464900 Mon Sep 17 00:00:00 2001 From: Sun Austin Date: Tue, 30 Oct 2018 14:08:00 +0800 Subject: [PATCH] Update config to set values as string, rather than unicode A prior update config for python2/3 compatibility resulted in config values being set as unicode rather than strings. This ended up breaking patching on IPv6 systems, as the lib, if_nametoindex function used by patching in configuration of its multicast addresses does not properly handle unicode. As a result, the patching daemons were unable to communicate with each other. This update to tsconfig/config casts the values as str() to restore it to the previous behaviour. Closes-Bug:1800195 Change-Id: Ie7ac29728e81d2e5fcb80cde34d723c1480566d0 Signed-off-by: Sun Austin --- cgcs-patch/cgcs-patch/cgcs_patch/config.py | 4 +- tsconfig/tsconfig/tsconfig/tsconfig.py | 43 +++++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/config.py b/cgcs-patch/cgcs-patch/cgcs_patch/config.py index bb43933f..3e2e183b 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/config.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/config.py @@ -67,7 +67,7 @@ def read_config(): config.readfp(ini_fp) try: - value = config.get('platform_conf', 'nodetype') + value = str(config.get('platform_conf', 'nodetype')) global nodetype nodetype = value @@ -112,7 +112,7 @@ def get_mgmt_iface(): config.readfp(ini_fp) try: - value = config.get('platform_conf', 'management_interface') + value = str(config.get('platform_conf', 'management_interface')) global nodetype mgmt_if = value diff --git a/tsconfig/tsconfig/tsconfig/tsconfig.py b/tsconfig/tsconfig/tsconfig/tsconfig.py index cc90ce8d..dd855939 100644 --- a/tsconfig/tsconfig/tsconfig/tsconfig.py +++ b/tsconfig/tsconfig/tsconfig/tsconfig.py @@ -61,7 +61,7 @@ def _load(): config.readfp(ini_fp) try: - value = config.get('build_info', 'SW_VERSION') + value = str(config.get('build_info', 'SW_VERSION')) SW_VERSION = value.strip('"') except configparser.Error: @@ -77,75 +77,76 @@ def _load(): config.readfp(ini_fp) try: - value = config.get('platform_conf', 'nodetype') + value = str(config.get('platform_conf', 'nodetype')) nodetype = value - value = config.get('platform_conf', 'subfunction') + value = str(config.get('platform_conf', 'subfunction')) subfunctions = value.split(",") global region_config if config.has_option('platform_conf', 'region_config'): - region_config = config.get('platform_conf', 'region_config') + region_config = str(config.get('platform_conf', 'region_config')) global region_1_name if config.has_option('platform_conf', 'region_1_name'): - region_1_name = config.get('platform_conf', 'region_1_name') + region_1_name = str(config.get('platform_conf', 'region_1_name')) global region_2_name if config.has_option('platform_conf', 'region_2_name'): - region_2_name = config.get('platform_conf', 'region_2_name') + region_2_name = str(config.get('platform_conf', 'region_2_name')) global vswitch_type if config.has_option('platform_conf', 'vswitch_type'): - vswitch_type = config.get('platform_conf', 'vswitch_type') + vswitch_type = str(config.get('platform_conf', 'vswitch_type')) global management_interface if config.has_option('platform_conf', 'management_interface'): - management_interface = config.get('platform_conf', - 'management_interface') + management_interface = str(config.get('platform_conf', + 'management_interface')) global oam_interface if config.has_option('platform_conf', 'oam_interface'): - oam_interface = config.get('platform_conf', 'oam_interface') + oam_interface = str(config.get('platform_conf', 'oam_interface')) global infrastructure_interface if config.has_option('platform_conf', 'infrastructure_interface'): - infrastructure_interface = config.get('platform_conf', - 'infrastructure_interface') + infrastructure_interface = str(config.get('platform_conf', + 'infrastructure_interface')) global sdn_enabled if config.has_option('platform_conf', 'sdn_enabled'): - sdn_enabled = config.get('platform_conf', 'sdn_enabled') + sdn_enabled = str(config.get('platform_conf', 'sdn_enabled')) global host_uuid if config.has_option('platform_conf', 'UUID'): - host_uuid = config.get('platform_conf', 'UUID') + host_uuid = str(config.get('platform_conf', 'UUID')) global install_uuid if config.has_option('platform_conf', 'INSTALL_UUID'): - install_uuid = config.get('platform_conf', 'INSTALL_UUID') + install_uuid = str(config.get('platform_conf', 'INSTALL_UUID')) global system_type if config.has_option('platform_conf', 'system_type'): - system_type = config.get('platform_conf', 'system_type') + system_type = str(config.get('platform_conf', 'system_type')) global system_mode if config.has_option('platform_conf', 'system_mode'): - system_mode = config.get('platform_conf', 'system_mode') + system_mode = str(config.get('platform_conf', 'system_mode')) global security_profile if config.has_option('platform_conf', 'security_profile'): - security_profile = config.get('platform_conf', 'security_profile') + security_profile = str(config.get('platform_conf', + 'security_profile')) global distributed_cloud_role if config.has_option('platform_conf', 'distributed_cloud_role'): - distributed_cloud_role = config.get('platform_conf', - 'distributed_cloud_role') + distributed_cloud_role = str(config.get('platform_conf', + 'distributed_cloud_role')) global security_feature if config.has_option('platform_conf', 'security_feature'): - security_feature = config.get('platform_conf', 'security_feature') + security_feature = str(config.get('platform_conf', 'security_feature')) except configparser.Error: logging.exception("Failed to read platform.conf")