Skip to content

Commit

Permalink
Made Changes to be Python 3.7 compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi committed Sep 1, 2022
1 parent 978afb5 commit 17d44c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 10 additions & 2 deletions scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ class FeatureHandler(object):
self._feature_state_table._del(feature_name)
return

feature = Feature(feature_name, feature_cfg, self._device_config | self._device_running_config)
device_config = {}
device_config.update(self._device_config)
device_config.update(self._device_running_config)

feature = Feature(feature_name, feature_cfg, device_config)
self._cached_config.setdefault(feature_name, Feature(feature_name, {}))

# Change auto-restart configuration first.
Expand Down Expand Up @@ -239,8 +243,12 @@ class FeatureHandler(object):
if not feature_name:
syslog.syslog(syslog.LOG_WARNING, "Feature is None")
continue

device_config = {}
device_config.update(self._device_config)
device_config.update(self._device_running_config)

feature = Feature(feature_name, feature_table[feature_name], self._device_config | self._device_running_config)
feature = Feature(feature_name, feature_table[feature_name], device_config)

self._cached_config.setdefault(feature_name, feature)
self.update_systemd_config(feature)
Expand Down
7 changes: 5 additions & 2 deletions tests/hostcfgd/hostcfgd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ def test_sync_state_field(self, test_scenario_name, config_data, fs):

device_config = {}
device_config['DEVICE_METADATA'] = MockConfigDb.CONFIG_DB['DEVICE_METADATA']
device_config.update(config_data['device_runtime_metadata'])

feature_handler = hostcfgd.FeatureHandler(MockConfigDb(), feature_state_table_mock, device_config)

feature_table = MockConfigDb.CONFIG_DB['FEATURE']
feature_handler.sync_state_field(feature_table)

feature_systemd_name_map = {}
for feature_name in feature_table.keys():
feature = hostcfgd.Feature(feature_name, feature_table[feature_name], device_config | config_data['device_runtime_metadata'])
feature = hostcfgd.Feature(feature_name, feature_table[feature_name], device_config)
feature_names, _ = feature_handler.get_multiasic_feature_instances(feature)
feature_systemd_name_map[feature_name] = feature_names

Expand Down Expand Up @@ -188,14 +190,15 @@ def test_handler(self, test_scenario_name, config_data, fs):

device_config = {}
device_config['DEVICE_METADATA'] = MockConfigDb.CONFIG_DB['DEVICE_METADATA']
device_config.update(config_data['device_runtime_metadata'])
feature_handler = hostcfgd.FeatureHandler(MockConfigDb(), feature_state_table_mock, device_config)

feature_table = MockConfigDb.CONFIG_DB['FEATURE']

feature_systemd_name_map = {}
for feature_name, feature_config in feature_table.items():
feature_handler.handler(feature_name, 'SET', feature_config)
feature = hostcfgd.Feature(feature_name, feature_table[feature_name], device_config | config_data['device_runtime_metadata'])
feature = hostcfgd.Feature(feature_name, feature_table[feature_name], device_config)
feature_names, _ = feature_handler.get_multiasic_feature_instances(feature)
feature_systemd_name_map[feature_name] = feature_names

Expand Down

0 comments on commit 17d44c2

Please sign in to comment.