Python client output indistinguishable between "None" string and NoneType

Bug #1266414 reported by Shrirang Phadke
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Won't Fix
Low
Shrirang Phadke
Python client library for Sahara
Fix Released
Undecided
pritesh
python-keystoneclient
Invalid
Low
Shrirang Phadke
python-neutronclient
Won't Fix
Undecided
Unassigned
python-novaclient
Fix Released
Low
Shrirang Phadke

Bug Description

If "None" string is set as value of any resource attribute (Instance Name, Volume Name, Project Name) then it is hard to distinguish between "None" string and NoneType as attribute value.

Both are listed ambigously as: http://i.imgur.com/3sFNaEP.jpg

Amazon uses hyphen '-' to denote NoneType values. I am trying to get this fix in python-cinderclient (https://review.openstack.org/#/c/64665/)

Same fix might also be applied to other python clients

Changed in python-novaclient:
assignee: nobody → Shrirang Phadke (shrirangphadke)
Changed in python-keystoneclient:
assignee: nobody → Shrirang Phadke (shrirangphadke)
Changed in python-glanceclient:
assignee: nobody → Shrirang Phadke (shrirangphadke)
Changed in python-neutronclient:
assignee: nobody → Shrirang Phadke (shrirangphadke)
Changed in python-novaclient:
status: New → In Progress
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

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

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

Reviewed: https://review.openstack.org/65680
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=1627908b182ca9afd54ce695c820cd56d70a44df
Submitter: Jenkins
Branch: master

commit 1627908b182ca9afd54ce695c820cd56d70a44df
Author: Shrirang Phadke <email address hidden>
Date: Tue Jan 7 22:08:28 2014 +0530

    Fixes ambiguous cli output between "None" and NoneType

    Print hyphen(-) in python client output when attribute value is not
    set(NoneType) so that it is distinguishable between "None" string
    and NoneType value.

    Change-Id: I5ec0f39f13aca45fa95ddb59472c20207c63bf91
    Closes-Bug: #1266414

Changed in python-novaclient:
status: In Progress → Fix Committed
Revision history for this message
Marcos Lobo (marcos-fermin-lobo) wrote :

In the case of python-keystoneclient I think that it's not necessary because now, on functions like print_list there is this code:

....
if field in formatters:
                row.append(formatters[field](o))
            else:
                field_name = field.lower().replace(' ', '_')
                data = getattr(o, field_name, '')
                if data is None:
                    data = ''
                row.append(data)
....

if data is None then data equals to empty string. It is necessary to change it to equals to hyphen string?. I'm not sure.

Revision history for this message
Rohan (kanaderohan) wrote :

Since the python-novaclient will now be showing hyphen "-" for NoneType data. IMO , we should keep this behavior consistent across other python-clients.

Also, hyphen "-" makes it easier to identify that the value is NoneType instead of a blank string "".
It is not a major change to the code, hence i think we should go ahead with displaying hyphen "-" instead of NoneType in all official clients.

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

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

Changed in python-glanceclient:
status: New → In Progress
Feilong Wang (flwang)
Changed in python-glanceclient:
importance: Undecided → Low
Dolph Mathews (dolph)
Changed in python-keystoneclient:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
melanie witt (melwitt) wrote :

novaclient 2.16.0 released on 2/26/2014

Changed in python-novaclient:
status: Fix Committed → Fix Released
pritesh (pritesh)
Changed in python-saharaclient:
assignee: nobody → pritesh (pritesh)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-saharaclient (master)

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

Changed in python-saharaclient:
status: New → In Progress
Revision history for this message
Dolph Mathews (dolph) wrote :

"Amazon uses hyphen" isn't a justification: why should we use a hyphen instead of "None"?

Why would we care less about disambiguating between '-' and null value versus 'None' and a null value?

tags: added: user-experience
Revision history for this message
pritesh (pritesh) wrote :

@Dolph: its not about amazon vs openstack, its about getting your scripts working for both without any special cases.

Revision history for this message
Dolph Mathews (dolph) wrote :

I hope you're not writing bash scripts against both :( Use the python APIs, not the human interface.

Revision history for this message
pritesh (pritesh) wrote :

@Dolph: I am not, its just that i am trying to keep interface consistent across nova, sahara, etc.

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

Reviewed: https://review.openstack.org/102955
Committed: https://git.openstack.org/cgit/openstack/python-saharaclient/commit/?id=22a413bcd7391f6df11cf8ee0e340babb6f339ad
Submitter: Jenkins
Branch: master

commit 22a413bcd7391f6df11cf8ee0e340babb6f339ad
Author: Shrirang Phadke <email address hidden>
Date: Tue Jan 7 22:08:28 2014 +0530

    Fixes ambiguous cli output between "None" and NoneType

    Print hyphen(-) in python client output when attribute value is not
    set(NoneType) so that it is distinguishable between "None" string
    and NoneType value.

    Cherry-Pick: I5ec0f39f13aca45fa95ddb59472c20207c63bf91
    Change-Id: I8a907e7453df711605d28bb97492f747adc282e0
    Closes-Bug: #1266414

Changed in python-saharaclient:
status: In Progress → Fix Committed
tags: removed: izeltech
Changed in python-saharaclient:
status: Fix Committed → Fix Released
milestone: none → 0.7.1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

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

Changed in python-neutronclient:
assignee: Shrirang Phadke (shrirangphadke) → Amandeep (rattenpal-amandeep)
status: New → In Progress
Revision history for this message
Steve Martinelli (stevemar) wrote :

for keystoneclient we have deprecated the CLI in favor of OpenStackClient which does not print "None" or a hyphen "-", but rather uses prettytable and cliff, which uses a whitespace ' '.

the result is very nice for scripting with awk and grep, but scripters can also use smarter functions like -c and -v to get the value of a specific column

Changed in python-keystoneclient:
status: Triaged → Invalid
Revision history for this message
Akihiro Motoki (amotoki) wrote :

In neutronclient, we don't change the current behavior because:

* it is backward-incompatible. If a user parses an output, changing an empty string to '-' breaks their script.
* If we use a hyphen instead, then we cannot distinguish '-' from None. It just changes a problem.

In a case of cliff-based client such as neutronclient or openstackclient, we can select an output option (table, json, yaml).
If you need detail values with their type, we can use JSON formatter.

Changed in python-neutronclient:
status: In Progress → Won't Fix
assignee: Amandeep (rattenpal-amandeep) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-neutronclient (master)

Change abandoned by Akihiro Motoki (<email address hidden>) on branch: master
Review: https://review.openstack.org/156489
Reason: There is no reply from the author over 8 weeks, and we have many objections on this change.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-glanceclient (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/340103

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-saharaclient (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/340113

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-saharaclient (master)

Change abandoned by PanFengyun (<email address hidden>) on branch: master
Review: https://review.openstack.org/340113

Ian Cordasco (icordasc)
Changed in python-glanceclient:
status: In Progress → Won't Fix
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.