no easy way for CLI to show both network name + subnet cidr

Bug #1074415 reported by dan wendlandt
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-neutronclient
Fix Released
Undecided
Akihiro Motoki

Bug Description

the two most common things one would probably want to see when listing networks is the network name, and the cidr's for the network's subnets.

unfortunately, neither net-list no net-show do this. and when you do subnet-list, you see the cidr, but not the network name.

dan wendlandt (danwent)
tags: added: low-hanging-fruit
Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

As I see, there are three changes in Quantum CLI output:
- show cird in the "quantum net-list" output
- show cird in the "quantum net-show" output
- show network name in the "quantum subnet-show" output

Dan, please confirm that I'm not wrong.

Changed in python-quantumclient:
assignee: nobody → Ivan kolodyazhny (e0ne)
Revision history for this message
dan wendlandt (danwent) wrote :

Hi Ivan,

Those are three options for solving the problem I mention. I'd like Yong and Mark to chime in with their thoughts about how to best address this, as they work more actively on the CLI than I do.

Revision history for this message
yong sheng gong (gongysh) wrote :

to show cird in quantum net-list is most wanted by me. It is useful to compare all the networks.
:
+--------------------------------------+--------------+--------------------------------------+
| id | name | subnets |
+--------------------------------------+--------------+--------------------------------------+
| 723c5d8e-6e66-4f7c-ad89-8ed58468fe30 | privatenet2 | {"id": "5d1a4f3d-2264-4011-98cd-772513b2a1f9",
                                                                                                              "cidr": "10.0.1.0/24"} |

We will have to fetch subnets for each network after fetching networks on the CLI command side.

Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

Does it mean that we won't to change Quantum API? It this case CLI tools will generage N*M request to server where:
N - number of networks
M - number of subnetworks.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

In most cases, we just need to call one list_networks() and one list_subnets() even if cidr information is displayed in net-list result. Ideally list_networks() returns associated subnet information if some verbose or detail flag is set.

Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

Akihiro,
you're right, we need only two api calls. I'll prepare fix for this issue and should I create bluprint for Quantum API for update list_networks() method to return detaile or not information?

Ivan Kolodyazhny (e0ne)
Changed in python-quantumclient:
status: New → Confirmed
Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

This functionality is very important for me to, so I try to implement it asap.

In the current version python quantum client returns subnets list for network as a list type. In a new use-case we need to have a dict. I tried to change CLI, but horizon also use this and need to be changed.

Dan,
please confirm that we need these changes in python-quantumclient. I ready to implement it and horizon/etc changes if it needs.

Revision history for this message
yong sheng gong (gongysh) wrote :

I would like to user list_networks and then list_subnets with subnetids listed in list_networks to fix it. This way, there is no need to modify the API, although I don't think we need to make big change.

Revision history for this message
dan wendlandt (danwent) wrote :

yong, can you give example output of what you're describing? i'm not sure I follow.

Revision history for this message
yong sheng gong (gongysh) wrote :

The output of the result is described at #3.
list_networks is a function of quantum client class. It will have a list of networks and the related subnet ids.
and then we use these subnets ids to call client class's list_subnets to pull the subnets with that ids.
after that, cli command quantum net-list compose the subnets with networks and the have that output at #3.

another way is to change API to return subnets instead of a list of subnet ids of network in GET /networks.
But it will break compatibility.

So I prefer to the two-invocation one.

Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

Young,
lets check that we are on the same page. I'm not talking about Quantum Server API changes. I'm talking about Quantum Client response format changes.

E.g. list_networks is a function of quantum client class, https://github.com/openstack/python-quantumclient/blob/master/quantumclient/v2_0/client.py#L243

If this method returns subnets for network as a dictionary (E.g. {'networks':[{'id':'network_1_id', 'subnets':[{'id':'subnet_id', 'cidr':'subnet_cidr']}}]}) all quantum client users, at least horizon, should be changed.

I could dump subnets info to a string but I'm think it's a bad idea and very unuseful

Revision history for this message
yong sheng gong (gongysh) wrote :

In fact, the methods in this class is a thin wrapper for API access. So to change it means to change API on server side.
So I don't know if u don't change API, how do u do it in list_networks() only.

Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

>> I would like to user list_networks and then list_subnets with subnetids listed in list_networks to fix it.
I just added list_subnets invoke to the list_networks method. so server API is not changed

Revision history for this message
Akihiro Motoki (amotoki) wrote :

Ivan,

I prefer to keeping quantum client class a thin wrapper. It means that each method should just call a single API operation.
If you add list_subnets call to list_networks(), we could not get a raw API response of network_list.

In addition your proposed change break horizon implementation since Horizon quantum api does similar thing you proposed.
(See horizon/openstack_dashboard/api/quantum.py network_list() if you want to know more detail.)
Note that I will update Horizon implementation in G-1 to follow your change if this change is accepted.

Now there are several design options:
(a) Change list_networks() (in the quantum client class) (affects to CLI and libary) <-- your proposal
(b) Add a new method like list_networks_with_subnets() to the client class (no affect to existing system)
(c) Change ListNetwork (described below) (affects to CLI only)

[detail of ListNetwork change]
it is better to change get_data() method of ListNetwork class since it is a CLI-specific change.
Unfortunately get_data of ListCommand is not so extensible.
My idea is (1) to add get_additional_data(data) method (that returns just 'data' passed as an argument) to ListCommand, (2) change get_data method in ListCommand to call get_additional_data() just after obj_lister, and (3) define get_additional_data() method in ListNetwork class to call list_subnets() and modify the response of list_networks().

Revision history for this message
Ivan Kolodyazhny (e0ne) wrote :

Akihiro,
Thanks for your detailed response.

(b) Add a new method like list_networks_with_subnets() to the client class (no affect to existing system) -- in this case we need to implement three new commands wich are very similar to exists

(c) Change ListNetwork (described below) -- looks good but does it really affects only to CLI if i change list_networks() response? I can add some CLI-only param to show detailed data for list_networks() to show subnets data for CLI only.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-quantumclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/19409

Changed in python-quantumclient:
assignee: Ivan Kolodyazhny (e0ne) → Akihiro Motoki (amotoki)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-quantumclient (master)

Reviewed: https://review.openstack.org/19409
Committed: http://github.com/openstack/python-quantumclient/commit/ab5399e64daf742a5b857d7532dc554a6102c7c7
Submitter: Jenkins
Branch: master

commit ab5399e64daf742a5b857d7532dc554a6102c7c7
Author: Akihiro MOTOKI <email address hidden>
Date: Thu Jan 10 03:22:14 2013 +0900

    Display subnet cidr information in net-list

    Fixes bug 1074415

    This commit introduces extend_list() in ListCommand class. This method
    can be used to update a retrieved list (e.g., add additional information
    or convert some field to more human-readable value).

    Change-Id: Icf5ab616ab4d9add16c921e1944ba37b376b2ab2

Changed in python-quantumclient:
status: In Progress → Fix Committed
Changed in python-quantumclient:
milestone: none → 2.1
Akihiro Motoki (amotoki)
Changed in python-quantumclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.