neutron port-list -f csv outputs poorly formatted JSON strings.

Bug #1263551 reported by Tim Spriggs
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-neutronclient
Fix Released
Medium
Ilya Shakhat

Bug Description

I have two IPs attached to a port. One IPv4 address and one IPv6 address:

$ neutron port-list -f table | grep '..relevant lines..'
| f59ec695-d52d-40b0-9d7c-1d8ebe315305 | | fa:16:3e:7d:99:3a | {"subnet_id": "1bb2eda5-5860-4864-84a3-4e31e3a0f130", "ip_address": "192.168.2.102"} |
| | | | {"subnet_id": "81aa0d62-4b8d-4494-98c8-50b434b067d8", "ip_address": "2607:f088:0:2::1338"} |

$ neutron port-list -f csv | grep '..relevant lines..'
"f59ec695-d52d-40b0-9d7c-1d8ebe315305","","fa:16:3e:7d:99:3a","{""subnet_id"": ""1bb2eda5-5860-4864-84a3-4e31e3a0f130"", ""ip_address"": ""192.168.2.102""}
{""subnet_id"": ""81aa0d62-4b8d-4494-98c8-50b434b067d8"", ""ip_address"": ""2607:f088:0:2::1338""}"

Running this through a CSV filter:

$VAR1 = '10fd0850-7799-4ac7-ae54-09ecb3ac8b8f';
$VAR2 = '';
$VAR3 = 'fa:16:3e:37:ac:cc';
$VAR4 = '{"subnet_id": "1bb2eda5-5860-4864-84a3-4e31e3a0f130", "ip_address": "192.168.2.104"}
{"subnet_id": "81aa0d62-4b8d-4494-98c8-50b434b067d8", "ip_address": "2607:f088:0:2::133a"}';

Finally, attempting to parse the JSON string ($VAR4) in perl:

garbage after JSON object, at character offset 85 (before "{"subnet_id": "81aa0...") at ./neutron_ports line 48, <$NEUTRON_PORTS> line 15.

Indeed, this isn't perl's fault. Putting the string through http://jsonlint.com/ comes up with a similar error.

The two strings need to be contained in a larger structure: [{...},{...}]
instead of just concatenated together: {...}{...}

Or the output specification needs to be changed.

Package/version information:
# dpkg -l | awk '/neutron/ {print $3 " " $2}'
1:2013.2-0ubuntu1 neutron-common
1:2013.2-0ubuntu1 neutron-dhcp-agent
1:2013.2-0ubuntu1 neutron-metadata-agent
1:2013.2-0ubuntu1 neutron-plugin-linuxbridge
1:2013.2-0ubuntu1 neutron-plugin-linuxbridge-agent
1:2013.2-0ubuntu1 neutron-plugin-openvswitch
1:2013.2-0ubuntu1 neutron-server
1:2013.2-0ubuntu1 python-neutron
1:2.3.0-0ubuntu1 python-neutronclient

Changed in neutron:
importance: Undecided → Medium
affects: neutron → python-neutronclient
Changed in python-neutronclient:
status: New → Confirmed
Changed in python-neutronclient:
assignee: nobody → Cedric Brandily (cbrandily)
Changed in python-neutronclient:
status: Confirmed → In Progress
Changed in python-neutronclient:
status: In Progress → Confirmed
assignee: Cedric Brandily (cbrandily) → nobody
Changed in python-neutronclient:
assignee: nobody → Akhila C (chetlapalle-akhila-b)
Changed in python-neutronclient:
assignee: Akhila C (chetlapalle-akhila-b) → nobody
assignee: nobody → tcs_openstack_group (tcs-openstack-group)
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/99929

Changed in python-neutronclient:
assignee: tcs_openstack_group (tcs-openstack-group) → Jyotsna (jyotsna-priya1)
status: Confirmed → In Progress
Kyle Mestery (mestery)
Changed in python-neutronclient:
milestone: none → 2.3.9
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-neutronclient (master)

Reviewed: https://review.openstack.org/99929
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=5d2bafa56fae2d273579c5d73f4686ee9d404a26
Submitter: Jenkins
Branch: master

commit 5d2bafa56fae2d273579c5d73f4686ee9d404a26
Author: Jyotsna <email address hidden>
Date: Fri Jun 13 18:11:17 2014 +0530

    neutron port-list -f csv outputs poorly formatted
    JSON strings

    After the change, the attached subnets are displayed
    as a list of dictionaries in one line only for csv
    option.
    It does not modify the output for tabular format.

    Closes-Bug: #1263551

    Change-Id: Ia34062562f0471bc926f9fc0bbed2d5dc4352dc0

Changed in python-neutronclient:
status: In Progress → Fix Committed
Kyle Mestery (mestery)
Changed in python-neutronclient:
milestone: 2.3.9 → 2.3.10
Revision history for this message
Ilya Shakhat (shakhat) wrote :

The committed fix does not change the behavior:
 * https://review.openstack.org/#/c/99929/8/neutronclient/neutron/v2_0/__init__.py -- lines 666-673 are added after return statement making the code unreachable
 * https://review.openstack.org/#/c/99929/8/neutronclient/neutron/v2_0/port.py -- line 36 refers to function utils.dumps which does not exist.
Thus re-opening the bug.

Changed in python-neutronclient:
status: Fix Committed → Confirmed
assignee: Jyotsna (jyotsna-priya1) → Ilya Shakhat (shakhat)
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/146863

Changed in python-neutronclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-neutronclient (master)

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

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

Reviewed: https://review.openstack.org/146863
Committed: https://git.openstack.org/cgit/openstack/python-neutronclient/commit/?id=57adb7f340577c0d27b377be449cb65edeb8508a
Submitter: Jenkins
Branch: master

commit 57adb7f340577c0d27b377be449cb65edeb8508a
Author: Ilya Shakhat <email address hidden>
Date: Tue Jan 13 16:44:01 2015 +0300

    Fix CSV formatting of fixed_ips field in port-list command

    With this patch fixed_ips field is printed in JSON format.
    The patch corrects https://review.openstack.org/#/c/99929/

    Closes bug 1263551

    Change-Id: I10842b96a443396abf0b268a699cce85b98c5a72

Changed in python-neutronclient:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-neutronclient (master)

Change abandoned by Cedric Brandily (<email address hidden>) on branch: master
Review: https://review.openstack.org/154822
Reason: corrected by https://review.openstack.org/146863

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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