summaryrefslogtreecommitdiff
path: root/openstackclient/network/v2
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-02-10 11:49:15 +0800
committerTang Chen <chen.tang@easystack.cn>2016-02-17 17:04:43 +0800
commitddc97c6dc5bc36d678515aeb9f7b3f9e85bd70d0 (patch)
treee0adec887bccc7d3bcad6952035b389adf899859 /openstackclient/network/v2
parent0a3ba91d53524cd0aa3a411f1f964594c8445cd3 (diff)
downloadpython-openstackclient-ddc97c6dc5bc36d678515aeb9f7b3f9e85bd70d0.tar.gz
Support "network list" command in nova network
"network list" command is not implemented in nova network. This patch implements it. The Network object in novaclient is quite different from the one in sdk. And the output of "network list" using Nova network is also quite different from using Neutron. It is like this: # openstack network list +--------------------------------------+---------+-------------+ | ID | Name | Subnet | +--------------------------------------+---------+-------------+ | 96a98ec4-31f6-45f6-99e6-9384569b3bb5 | private | 10.0.0.0/24 | +--------------------------------------+---------+-------------+ --long and --external options have not been implemented because the attrs in Network object in novaclient is too much different. This patch also introduces a new FakeNetwork class in compute/v2/fake.py to fake nova network. Change-Id: Id1fdf81fb2fa8b39f2c76b7bae37ac4fecafd0f7 Depends-On: I1b59264cd40aaf1062f4e8db233ccb7fd0e95f0e partial-Bug: 1543672
Diffstat (limited to 'openstackclient/network/v2')
-rw-r--r--openstackclient/network/v2/network.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py
index 636c333e..ed251173 100644
--- a/openstackclient/network/v2/network.py
+++ b/openstackclient/network/v2/network.py
@@ -168,11 +168,10 @@ class DeleteNetwork(common.NetworkAndComputeCommand):
client.networks.delete(network.id)
-class ListNetwork(command.Lister):
+class ListNetwork(common.NetworkAndComputeLister):
"""List networks"""
- def get_parser(self, prog_name):
- parser = super(ListNetwork, self).get_parser(prog_name)
+ def update_parser_common(self, parser):
parser.add_argument(
'--external',
action='store_true',
@@ -187,9 +186,7 @@ class ListNetwork(command.Lister):
)
return parser
- def take_action(self, parsed_args):
- client = self.app.client_manager.network
-
+ def take_action_network(self, client, parsed_args):
if parsed_args.long:
columns = (
'id',
@@ -231,7 +228,29 @@ class ListNetwork(command.Lister):
args = {'router:external': True}
else:
args = {}
+
data = client.networks(**args)
+
+ return (column_headers,
+ (utils.get_item_properties(
+ s, columns,
+ formatters=_formatters,
+ ) for s in data))
+
+ def take_action_compute(self, client, parsed_args):
+ columns = (
+ 'id',
+ 'label',
+ 'cidr',
+ )
+ column_headers = (
+ 'ID',
+ 'Name',
+ 'Subnet',
+ )
+
+ data = client.networks.list()
+
return (column_headers,
(utils.get_item_properties(
s, columns,