nova network-list ERROR: string indices must be integers, not str

Asked by weihongj on 2013-01-14

I got this error when trying to get network list with nova network-list, the debug output is pasted below.
Refer to , and I check api-paste.ini and nova.conf, auth_host should be correct for me.

Anyone can help to have a look? This may be a configuration issue, but I can not figure out for now.

REQ: curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-novaclient" -d '{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "admin", "password": "secretword"}}}'

connect: (, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost:\r\nContent-Length: 113\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
send: '{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "admin", "password": "secretword"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Vary: X-Auth-Token
header: Content-Type: application/json
header: Content-Length: 2456
header: Date: Mon, 14 Jan 2013 03:33:39 GMT
RESP:{'date': 'Mon, 14 Jan 2013 03:33:39 GMT', 'vary': 'X-Auth-Token', 'content-length': '2456', 'status': '200', 'content-type': 'application/json'} {"access": {"token": {"expires": "2013-01-15T03:33:39Z", "id": "e87a9811790a4baab2764f9231e19595", "tenant": {"enabled": true, "description": "Default Tenant", "name": "openstackDemo", "id": "53740c8a0e964bc798ccc5eed0698f01"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "590792816d5340edbedc49f208eddb00", "publicURL": ""}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "e1f4365f5f014c04bf6d3c8a326104ff", "publicURL": ""}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "f8d4b02461ba425890c5baf3f55cabc0", "publicURL": ""}], "endpoints_links": [], "type": "volume", "name": "volume"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "da2ff145e7ec47318092eaa6623f06da", "publicURL": ""}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "cb0f436025bf4e15b81b6d38bd9dcb5f", "publicURL": ""}], "endpoints_links": [], "type": "object-store", "name": "swift"}, {"endpoints": [{"adminURL": "", "region": "RegionOne", "internalURL": "", "id": "1929ed84589749e0929095233bfad27e", "publicURL": ""}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "admin", "roles_links": [], "id": "8f3eff6d15de4b43b73222705a1cc559", "roles": [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["22ffb0ef3f5d42098e51ee4a997c7d87"]}}}

REQ: curl -i -X GET -H "X-Auth-Project-Id: openstackDemo" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: e87a9811790a4baab2764f9231e19595"

connect: (, 8774)
send: u'GET /v2/53740c8a0e964bc798ccc5eed0698f01/os-networks HTTP/1.1\r\nHost:\r\nx-auth-project-id: openstackDemo\r\nx-auth-token: e87a9811790a4baab2764f9231e19595\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: X-Compute-Request-Id: req-ec29b37d-e3b8-4c7c-a6d0-6a296f911cba
header: Content-Type: application/json
header: Content-Length: 667
header: Date: Mon, 14 Jan 2013 03:33:41 GMT
RESP:{'status': '200', 'content-length': '667', 'content-location': u'', 'x-compute-request-id': 'req-ec29b37d-e3b8-4c7c-a6d0-6a296f911cba', 'date': 'Mon, 14 Jan 2013 03:33:41 GMT', 'content-type': 'application/json'} {"networks": [{"bridge": "br160", "vpn_public_port": 1000, "dhcp_start": "", "bridge_interface": "eth2", "updated_at": null, "id": "f9f7a0aa-6a2a-4f1b-be51-0a0e03f7b2ea", "cidr_v6": null, "deleted_at": null, "gateway": "", "rxtx_base": null, "label": "vlan160network", "priority": null, "project_id": null, "vpn_private_address": "", "deleted": false, "vlan": 160, "broadcast": "", "netmask": "", "injected": false, "cidr": "", "vpn_public_address": null, "multi_host": false, "dns2": null, "created_at": timestamp(1357917372.0), "host": null, "gateway_v6": null, "netmask_v6": null, "dns1": null}]}

DEBUG (shell:535) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/novaclient/", line 532, in main
  File "/usr/lib/python2.6/site-packages/novaclient/", line 467, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.6/site-packages/novaclient/v1_1/", line 490, in do_network_list
    network_list = cs.networks.list()
  File "/usr/lib/python2.6/site-packages/novaclient/v1_1/", line 49, in list
    return self._list("/os-networks", "networks")
  File "/usr/lib/python2.6/site-packages/novaclient/", line 67, in _list
    data = body[response_key]
TypeError: string indices must be integers, not str
ERROR: string indices must be integers, not str

Question information

English Edit question
OpenStack Compute (nova) Edit question
No assignee Edit question
Last query:
Last reply:
Keith Tobin (keith-tobin) said : #1

It seems to be a bug,

The command you execute, gets token from keystone, issues request to get network list, and you get a 200 response with a body full of data. This http body data should be turned in to a dictionary by novaclient code and then at line 67 of the dictionary of body data is used to get the list of networks using the 'network' key.
But in your case it seems the the dictionary is a python list and not a python dictionary, so when we try to use 'network' key to get the network from what should have being a python dictionary we get a error saying 'it a python list and we expected you to use a integer to select a value not a key as would have being used for getting a value from a dictionary'.

The data returned in the response is in the log you posted, I would repost this as a bug to nova client.
Give them all this info and what you posted, also give them version of openstack and if it devstack or own install, OS version and type.

Before doing this make sure that you are using latest version of nova client available on your OS.
With all above I am expecting that you are not doing anything funky and doing a install from packages.
If not post more info here, detailing.

Can you help with this problem?

Provide an answer of your own, or ask weihongj for more information if necessary.

To post a message you must log in.