diff --git a/zunclient/common/utils.py b/zunclient/common/utils.py index a8179248..90259fbe 100644 --- a/zunclient/common/utils.py +++ b/zunclient/common/utils.py @@ -162,15 +162,19 @@ def check_container_status(container, status): def format_container_addresses(container): addresses = getattr(container, 'addresses', {}) output = [] + networks = [] try: for address_name, address_list in addresses.items(): for a in address_list: output.append(a['addr']) + networks.append(address_name) except Exception: pass setattr(container, 'addresses', ', '.join(output)) + setattr(container, 'networks', ', '.join(networks)) container._info['addresses'] = ', '.join(output) + container._info['networks'] = ', '.join(networks) def list_containers(containers): diff --git a/zunclient/tests/unit/v1/test_containers_shell.py b/zunclient/tests/unit/v1/test_containers_shell.py index 2ccd42c0..831fbce9 100644 --- a/zunclient/tests/unit/v1/test_containers_shell.py +++ b/zunclient/tests/unit/v1/test_containers_shell.py @@ -54,7 +54,8 @@ class ShellTest(shell_test_base.TestCommandLineArgument): fake_container._info = {} fake_container.addresses = {'private': [{'addr': '10.0.0.1'}]} containers_shell._show_container(fake_container) - mock_print_dict.assert_called_once_with({'addresses': '10.0.0.1'}) + mock_print_dict.assert_called_once_with({'networks': 'private', + 'addresses': '10.0.0.1'}) @mock.patch('zunclient.common.cliutils.print_list') def test_list_container(self, mock_print_list):