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
This commit is contained in:
Dan Prince 2014-09-18 15:47:04 -04:00
parent 7b968a875d
commit f457c64bae
2 changed files with 8 additions and 6 deletions

View File

@ -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):

View File

@ -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):