Show container network.
As the network detach feature has merged, but there is no way for user to find the container network easily. This patch add the network info to the container show for user to find the container network easily. Partially-Implements: blueprint network-rest-api Change-Id: I401cb91769b49e5451d4a52452bf30149fc82bee
This commit is contained in:
parent
354b27eb15
commit
244fadc116
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user