Add network-list to OSC

This change adds network list support to the python-openstackclient project
for the network-list command.

The zun command network-list is now:
    openstack appcontainer network list

Change-Id: I613ccff042e50a44cbbae074c706dc6e07867593
This commit is contained in:
caishan 2018-03-15 18:29:06 -07:00
parent f6946c4305
commit 58653c63fe
2 changed files with 25 additions and 0 deletions

View File

@ -63,6 +63,7 @@ openstack.container.v1 =
appcontainer_host_show = zunclient.osc.v1.hosts:ShowHost
appcontainer_network_detach = zunclient.osc.v1.containers:NetworkDetach
appcontainer_network_attach = zunclient.osc.v1.containers:NetworkAttach
appcontainer_network_list = zunclient.osc.v1.containers:NetworkList
appcontainer_image_search = zunclient.osc.v1.images:SearchImage
appcontainer_remove_security_group = zunclient.osc.v1.containers:RemoveSecurityGroup
appcontainer_image_show = zunclient.osc.v1.images:ShowImage

View File

@ -1148,3 +1148,27 @@ class RebuildContainer(command.Command):
except Exception as e:
print("rebuild container %(container)s failed: %(e)s" %
{'container': container, 'e': e})
class NetworkList(command.Lister):
"""List networks on a container"""
log = logging.getLogger(__name__ + ".ListNetworks")
def get_parser(self, prog_name):
parser = super(NetworkList, self).get_parser(prog_name)
parser.add_argument(
'container',
metavar='<container>',
help='ID or name of the container to list networks.'
)
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
opts = {}
opts['container'] = parsed_args.container
opts = zun_utils.remove_null_parms(**opts)
networks = client.containers.network_list(**opts)
columns = ('net_id', 'subnet_id', 'port_id', 'version', 'ip_address')
return (columns, (utils.get_item_properties(network, columns)
for network in networks))