From f457c64bae1e4cca63cd616bfe5e231850838f70 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 18 Sep 2014 15:47:04 -0400 Subject: Update child_members to use a Set Updates the impl_ifcfg.child_members method so that it uses a set instead of an array (this avoids dups). Also fixes an issue with this method which would cause tests to fail intermittently due to ordering differences. Adding each member object regardless solves this (not sure why I had commented out the children.append before) Also fixes an issue in test_cli which causes tests to fail on Debian which doesn't yet support the add_bond method on its ENI provider. This fix was to explicitly set --provider=ifcfg on the failing tests. We should be able to remove these once ENI supports bonding properly. Closes-bug: #1370615 Change-Id: Id9cfa2b2eaab27c93113956f5956facfa2a2aeee --- os_net_config/impl_ifcfg.py | 8 ++++---- os_net_config/tests/test_cli.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'os_net_config') diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index dfbf889..c871296 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -57,13 +57,13 @@ class IfcfgNetConfig(os_net_config.NetConfig): logger.info('Ifcfg net config provider created.') def child_members(self, name): - children = [] + children = set() try: for member in self.member_names[name]: - #children.append(member) - children.extend(self.child_members(member)) + children.add(member) + children.update(self.child_members(member)) except KeyError: - children.append(name) + children.add(name) return children def _add_common(self, base_opt): diff --git a/os_net_config/tests/test_cli.py b/os_net_config/tests/test_cli.py index 505301c..6c13068 100644 --- a/os_net_config/tests/test_cli.py +++ b/os_net_config/tests/test_cli.py @@ -49,8 +49,10 @@ class TestCli(base.TestCase): def test_bond_noop_output(self): bond_yaml = os.path.join(SAMPLE_BASE, 'bond.yaml') bond_json = os.path.join(SAMPLE_BASE, 'bond.json') - stdout_yaml, stderr = self.run_cli('ARG0 -d --noop -c %s' % bond_yaml) - stdout_json, stderr = self.run_cli('ARG0 -d --noop -c %s' % bond_json) + stdout_yaml, stderr = self.run_cli('ARG0 -d --provider=ifcfg --noop ' + '-c %s' % bond_yaml) + stdout_json, stderr = self.run_cli('ARG0 -d --provider=ifcfg --noop ' + '-c %s' % bond_json) self.assertEqual(stdout_yaml, stdout_json) def test_bridge_noop_output(self): -- cgit 1.2.3-korg