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 https://lists.launchpad.net/openstack/msg09940.html , 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 http://192.168.88.17:5000/v2.0/tokens -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: (192.168.88.17, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: 192.168.88.17:5000\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": "http://192.168.88.17:8774/v2/53740c8a0e964bc798ccc5eed0698f01", "region": "RegionOne", "internalURL": "http://192.168.88.17:8774/v2/53740c8a0e964bc798ccc5eed0698f01", "id": "590792816d5340edbedc49f208eddb00", "publicURL": "http://192.168.88.17:8774/v2/53740c8a0e964bc798ccc5eed0698f01"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://192.168.88.17:9292/v1", "region": "RegionOne", "internalURL": "http://192.168.88.17:9292/v1", "id": "e1f4365f5f014c04bf6d3c8a326104ff", "publicURL": "http://192.168.88.17:9292/v1"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://192.168.88.17:8776/v1/53740c8a0e964bc798ccc5eed0698f01", "region": "RegionOne", "internalURL": "http://192.168.88.17:8776/v1/53740c8a0e964bc798ccc5eed0698f01", "id": "f8d4b02461ba425890c5baf3f55cabc0", "publicURL": "http://192.168.88.17:8776/v1/53740c8a0e964bc798ccc5eed0698f01"}], "endpoints_links": [], "type": "volume", "name": "volume"}, {"endpoints": [{"adminURL": "http://192.168.88.17:8773/services/Admin", "region": "RegionOne", "internalURL": "http://192.168.88.17:8773/services/Cloud", "id": "da2ff145e7ec47318092eaa6623f06da", "publicURL": "http://192.168.88.17:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "ec2"}, {"endpoints": [{"adminURL": "http://192.168.88.17:8888/v1", "region": "RegionOne", "internalURL": "http://192.168.88.17:8888/v1/AUTH_53740c8a0e964bc798ccc5eed0698f01", "id": "cb0f436025bf4e15b81b6d38bd9dcb5f", "publicURL": "http://192.168.88.17:8888/v1/AUTH_53740c8a0e964bc798ccc5eed0698f01"}], "endpoints_links": [], "type": "object-store", "name": "swift"}, {"endpoints": [{"adminURL": "http://192.168.88.17:35357/v2.0", "region": "RegionOne", "internalURL": "http://192.168.88.17:5000/v2.0", "id": "1929ed84589749e0929095233bfad27e", "publicURL": "http://192.168.88.17:5000/v2.0"}], "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 http://192.168.88.17:8774/v2/53740c8a0e964bc798ccc5eed0698f01/os-networks -X GET -H "X-Auth-Project-Id: openstackDemo" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: e87a9811790a4baab2764f9231e19595"

connect: (192.168.88.17, 8774)
send: u'GET /v2/53740c8a0e964bc798ccc5eed0698f01/os-networks HTTP/1.1\r\nHost: 192.168.88.17:8774\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'http://192.168.88.17:8774/v2/53740c8a0e964bc798ccc5eed0698f01/os-networks', '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": "10.160.0.3", "bridge_interface": "eth2", "updated_at": null, "id": "f9f7a0aa-6a2a-4f1b-be51-0a0e03f7b2ea", "cidr_v6": null, "deleted_at": null, "gateway": "10.160.0.1", "rxtx_base": null, "label": "vlan160network", "priority": null, "project_id": null, "vpn_private_address": "10.160.0.2", "deleted": false, "vlan": 160, "broadcast": "10.160.255.255", "netmask": "255.255.0.0", "injected": false, "cidr": "10.160.0.0/16", "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/shell.py", line 532, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.6/site-packages/novaclient/shell.py", line 467, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.6/site-packages/novaclient/v1_1/shell.py", line 490, in do_network_list
    network_list = cs.networks.list()
  File "/usr/lib/python2.6/site-packages/novaclient/v1_1/networks.py", line 49, in list
    return self._list("/os-networks", "networks")
  File "/usr/lib/python2.6/site-packages/novaclient/base.py", 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

Language:
English Edit question
Status:
Answered
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Last query:
2013-01-14
Last reply:
2013-01-15
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 base.py 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.