openstack output as json end with shell line

Bug #1674213 reported by Noam Angel on 2017-03-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Triaged
Wishlist
Unassigned

Bug Description

When I choose to get the output as a json, the end of the print stuck with the shell line.

for example:

stack@qa-cloud-openstack6-controller1:~/devstack$ openstack server show 1f963466-d7b2-4e58-8ab6-9f9bbbe3a702 -f json
{
  "OS-EXT-STS:task_state": null,
  "addresses": "test_networking_network=192.168.2.4, 10.209.86.57",
  "image": "mellanox-rhel-7.2-OFED-last_release (6df27f81-8f57-4303-b0c1-5736bf735dfc)",
  "OS-EXT-STS:vm_state": "active",
  "OS-EXT-SRV-ATTR:instance_name": "instance-00000028",
  "OS-SRV-USG:launched_at": "2017-03-19T13:22:44.000000",
  "flavor": "m1.small (2)",
  "id": "1f963466-d7b2-4e58-8ab6-9f9bbbe3a702",
  "security_groups": "name='default'",
  "volumes_attached": "",
  "user_id": "b970d8f569bc4ef1896c491aaf816a23",
  "OS-DCF:diskConfig": "MANUAL",
  "accessIPv4": "",
  "accessIPv6": "",
  "progress": 0,
  "OS-EXT-STS:power_state": "Running",
  "OS-EXT-AZ:availability_zone": "nova",
  "config_drive": "",
  "status": "ACTIVE",
  "updated": "2017-03-19T13:22:45Z",
  "hostId": "b54d2d9522e70e7de788f578787dfa7bba5dd1e5caf7c479dcbc43b8",
  "OS-EXT-SRV-ATTR:host": "qa-cloud-openstack6-compute1",
  "OS-SRV-USG:terminated_at": null,
  "key_name": "test_networking_key",
  "properties": "",
  "project_id": "88fe1414d4704cdca464e521b104339e",
  "OS-EXT-SRV-ATTR:hypervisor_hostname": "qa-cloud-openstack6-compute1",
  "name": "test_networking_vm_2",
  "created": "2017-03-19T13:22:38Z"
}stack@qa-cloud-openstack6-controller1:~/devstack$

you can see above that json closing bracket is in same line as shell.
this happen to all commands I use.

openstack --version
openstack 3.9.0
OS Ubuntu 16.04.2 LTS

Noam Angel (noama) on 2017-03-20
description: updated
Rui Chen (kiwik-chenrui) wrote :

In most scenario "-f json" output format is used for machine readable, the program or shell consume the result, not read it directly in console for human, the use case like:

python
subprocess.Popen("openstack server list -f json")
Note: See openstackclient functional tests, it's a good reference for "-f json"

or
bash
#openstack server list -f json > output.json

Dean Troyer (dtroyer) wrote :

Most tools that handle text files are able to deal with no trailing newline at the end of the file, and in some places it is considered unnecessary. For shell output obviously it would be nice to have, and is probably safe to add.

Changed in python-openstackclient:
importance: Undecided → Wishlist
status: New → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers