Skip to content

Commit

Permalink
Merge pull request #51343 from waynew/6922-fix-network-error-errors
Browse files Browse the repository at this point in the history
6922 fix network error errors
  • Loading branch information
dwoz authored Jan 27, 2019
2 parents 1a0f76b + 28f2465 commit 3d4c195
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions salt/modules/debian_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _error_msg_iface(iface, option, expected):
a list of expected values.
'''
msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]'
return msg.format(iface, option, '|'.join(expected))
return msg.format(iface, option, '|'.join(str(e) for e in expected))


def _error_msg_routes(iface, option, expected):
Expand All @@ -181,7 +181,7 @@ def _error_msg_network(option, expected):
a list of expected values.
'''
msg = 'Invalid network setting -- Setting: {0}, Expected: [{1}]'
return msg.format(option, '|'.join(expected))
return msg.format(option, '|'.join(str(e) for e in expected))


def _log_default_network(opt, value):
Expand Down
4 changes: 2 additions & 2 deletions salt/modules/rh_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _error_msg_iface(iface, option, expected):
a list of expected values.
'''
msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]'
return msg.format(iface, option, '|'.join(expected))
return msg.format(iface, option, '|'.join(str(e) for e in expected))


def _error_msg_routes(iface, option, expected):
Expand All @@ -104,7 +104,7 @@ def _error_msg_network(option, expected):
a list of expected values.
'''
msg = 'Invalid network setting -- Setting: {0}, Expected: [{1}]'
return msg.format(option, '|'.join(expected))
return msg.format(option, '|'.join(str(e) for e in expected))


def _log_default_network(opt, value):
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/modules/test_debian_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,18 @@ def test_build_bond(self):
'pkg.install': mock}):
self.assertEqual(debian_ip.build_bond('bond0'), '')

def test_error_message_iface_should_process_non_str_expected(self):
values = [1, True, False, 'no-kaboom']
iface = 'ethtest'
option = 'test'
msg = debian_ip._error_msg_iface(iface, option, values)
self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg)

def test_error_message_network_should_process_non_str_expected(self):
values = [1, True, False, 'no-kaboom']
msg = debian_ip._error_msg_network('fnord', values)
self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg)

def test_build_bond_exception(self):
'''
Test if it create a bond script in /etc/modprobe.d with the passed
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/modules/test_rh_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ class RhipTestCase(TestCase, LoaderModuleMockMixin):
def setup_loader_modules(self):
return {rh_ip: {}}

def test_error_message_iface_should_process_non_str_expected(self):
values = [1, True, False, 'no-kaboom']
iface = 'ethtest'
option = 'test'
msg = rh_ip._error_msg_iface(iface, option, values)
self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg)

def test_error_message_network_should_process_non_str_expected(self):
values = [1, True, False, 'no-kaboom']
msg = rh_ip._error_msg_network('fnord', values)
self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg)

def test_build_bond(self):
'''
Test to create a bond script in /etc/modprobe.d with the passed
Expand Down

0 comments on commit 3d4c195

Please sign in to comment.