TypeError: string indices must be integers, not str

Asked by neo0

Here're the detail:

# nova --debug list

connect: (172.17.2.203, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: 172.17.2.203:5000\r\nContent-Length: 104\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n{"auth": {"tenantName": "ubuntu", "passwordCredentials": {"username": "admin", "password": "password"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Vary: X-Auth-Token
header: Date: Tue, 08 May 2012 04:16:19 GMT
header: Transfer-Encoding: chunked
connect: (172.17.2.203, 8774)
send: u'GET /v1.1/89156f3dde194102ab82cd62a7464f7b/servers/detail HTTP/1.1\r\nHost: 172.17.2.203:8774\r\nx-auth-project-id: ubuntu\r\nx-auth-token: 5b8549b438524402ae588e9f68061f0d\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 503 Service Unavailable\r\n'
header: Content-Length: 100
header: Content-Type: text/plain; charset=UTF-8
header: Date: Tue, 08 May 2012 04:16:19 GMT
DEBUG (shell:416) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 413, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 364, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/shell.py", line 520, in do_list
    utils.print_list(cs.servers.list(search_opts=search_opts), columns,
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/servers.py", line 279, in list
    return self._list("/servers%s%s" % (detail, query_string), "servers")
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 76, in _list
    data = body[response_key]
TypeError: string indices must be integers, not str
ERROR: string indices must be integers, not str

Here's my nova.conf

--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/run/lock/nova
--allow_admin_api=true
--use_deprecated_auth=false
--auth_strategy=keystone
--scheduler_driver=nova.scheduler.simple.SimpleScheduler
--s3_host=172.17.2.203
--ec2_host=172.17.2.203
--rabbit_host=172.17.2.203
--cc_host=172.17.2.203
--nova_url=http://172.17.2.203:8774/v1.1/
--routing_source_ip=172.17.2.203
--glance_api_servers=172.17.2.203:9292
--image_service=nova.image.glance.GlanceImageService
--sql_connection=mysql://nova:nova@172.17.2.203/nova_db
--keystone_ec2_url=http://172.17.2.203:5000/v2.0/ec2tokens
--api_paste_config=/etc/nova/api-paste.ini
--libvirt_type=kvm
--libvirt_use_virtio_for_bridges=true
--start_guests_on_host_boot=true
--resume_guests_state_on_host_boot=true
# vnc specific configuration
--novnc_enabled=true
--novncproxy_base_url=http://172.17.2.203:6080/vnc_auto.html
--vncserver_proxyclient_address=172.17.2.203
--vncserver_listen=172.17.2.203
# network specific settings
--network_manager=nova.network.manager.FlatDHCPManager
--public_interface=eth0
--flat_network_bridge=br100
--fixed_range=10.0.0.0/27
--floating_range=172.17.2.203/27
--network_size=32
--flat_network_dhcp_start=10.0.0.3
--flat_injected=False
--force_dhcp_release
--iscsi_helper=tgtadm
--connection_type=libvirt
--root_helper=sudo nova-rootwrap
--verbose

Keystone and glance work well.

Here the keystone endpoint:

keystone endpoint-list
+----------------------------------+-----------+------------------------------------------------+------------------------------------------------+---------------------------------------------+
| id | region | publicurl | internalurl | adminurl |
+----------------------------------+-----------+------------------------------------------------+------------------------------------------------+---------------------------------------------+
| 4f863419b75d43bcbb3ce121d56a8032 | RegionOne | https://172.17.2.203:443/v1/AUTH_%(tenant_id)s | https://172.17.2.203:443/v1/AUTH_%(tenant_id)s | https://172.17.2.203:443/v1 |
| 59e563d654c748fda12415363c9f8494 | RegionOne | http://172.17.2.203:5000/v2.0 | http://172.17.2.203:5000/v2.0 | http://172.17.2.203:35357/v2.0 |
| 73b604bb3e554d47aed7d41491a4466b | RegionOne | http://172.17.2.203:8774/v1.1/%(tenant_id)s | http://172.17.2.203:8774/v1.1/%(tenant_id)s | http://172.17.2.203:8774/v1.1/%(tenant_id)s |
| 7416b69f4f854560a5e6a23a1428b775 | RegionOne | http://172.17.2.203:9292/v1 | http://172.17.2.203:9292/v1 | http://172.17.2.203:9292/v1

Please help me!
Thank you!

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
neo0
Solved:
Last query:
Last reply:
Revision history for this message
Gary Leong (gwleong) said :
#1

I'm having the same problem. Is the nova-client not compatible with the existing api? I followed the instructions

http://docs.openstack.org/trunk/openstack-compute/install/content/ch_installing-openstack-overview.html

Has anybody gone through the guide from end to end?

Thanks in advance!

Revision history for this message
John Garbutt (johngarbutt) said :
#2

Can you give some information from the nova-api log and the nova-compute log?

It looks like there are two issue. First is the issue in nova that is causing a 503 error. Then the second issue is that the error is not being handled by nova-client properly (maybe it is trying to parse 503 as success?)

Once we get the log, it is worth raise a nova-client bug.

Revision history for this message
Gary Leong (gwleong) said :
#3

Hi John, Thanks for the response. There are no logs when I run nova image-list. I go to

cd /var/log/nova
tail -f *

The only logs that show are the periodic jobs run by nova.

Here is the openrc file and the output of the command when you debug:

root@openstack01:~# cat openrc
export OS_USERNAME=adminUser
export OS_TENANT_NAME=openstackDemo
export OS_PASSWORD=pass90123
export OS_AUTH_URL=http://192.168.206.130:5000/v2.0/
export OS_REGION_NAME=RegionOne

root@openstack01:~# nova --debug image-list
connect: (192.168.206.130, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: 192.168.206.130:5000\r\nContent-Length: 117\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "adminUser", "password": "pass90123"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Vary: X-Auth-Token
header: Date: Tue, 15 May 2012 17:16:38 GMT
header: Transfer-Encoding: chunked
connect: (192.168.206.130, 8774)
send: u'GET /v2/b1894ce6216149c79a5a86d772539981/images/detail HTTP/1.1\r\nHost: 192.168.206.130:8774\r\nx-auth-project-id: openstackDemo\r\nx-auth-token: 161aed201e9a4c1a9766a1c2e16b05e4\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 503 Service Unavailable\r\n'
header: Content-Length: 100
header: Content-Type: text/plain; charset=UTF-8
header: Date: Tue, 15 May 2012 17:16:38 GMT
DEBUG (shell:416) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 413, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 364, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/shell.py", line 350, in do_image_list
    image_list = cs.images.list()
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/images.py", line 47, in list
    return self._list("/images/detail", "images")
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 76, in _list
    data = body[response_key]
TypeError: string indices must be integers, not str
ERROR: string indices must be integers, not str

I'm basically going through the guide. I'm using the packages provided by the repo in the guide. Maybe the packages have changed and they are no longer internally consistent. It seems the api part isn't working for me. I tried not to deviate from the guides recommendation outside of the size of the machine. I'm using Ubuntu 12.04, kvm, and the exact recommended controller IP. I just want to test openstack. It looks to me lie there is an issue with expected integers, but it is yielding strings.

I'm also hitting the machine from itself. I'm running the nova-client on the nova-controller.

Any suggestions would be welcomed. Thanks!

Revision history for this message
Gary Leong (gwleong) said :
#4

Also, here are the services running:

root@openstack01:~# pgrep -l nova
6144 nova-api
6157 nova-compute
6167 nova-network
6183 nova-scheduler
6194 nova-xvpvncprox
6212 nova-volume
6223 nova-cert
6295 nova-consoleaut

root@openstack01:~# nova-manage service list
2012-05-15 10:26:47 DEBUG nova.utils [req-1c58b482-afa3-4faf-a646-156c264aca3a None None] backend <module 'nova.db.sqlalchemy.api' from '/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/api.pyc'> from (pid=14319) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
Binary Host Zone Status State Updated_At
nova-volume openstack01 nova enabled :-) 2012-05-15 17:26:47
nova-scheduler openstack01 nova enabled :-) 2012-05-15 17:26:47
nova-compute openstack01 nova enabled :-) 2012-05-15 17:26:46
nova-network openstack01 nova enabled :-) 2012-05-15 17:26:47
nova-cert openstack01 nova enabled :-) 2012-05-15 17:26:47

~

Revision history for this message
Gary Leong (gwleong) said :
#5

These are the ports that are opened:

root@openstack01:/etc/nova# netstat -an --inet -p | grep python
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 1714/python
tcp 0 0 0.0.0.0:35357 0.0.0.0:* LISTEN 2093/python
tcp 0 0 0.0.0.0:6081 0.0.0.0:* LISTEN 15441/python
tcp 0 0 0.0.0.0:8773 0.0.0.0:* LISTEN 15391/python
tcp 0 0 0.0.0.0:8774 0.0.0.0:* LISTEN 15391/python
tcp 0 0 0.0.0.0:8775 0.0.0.0:* LISTEN 15391/python
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 1701/python
tcp 0 0 0.0.0.0:8776 0.0.0.0:* LISTEN 15391/python
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 2093/python
tcp 0 0 192.168.206.130:47050 192.168.206.130:3306 ESTABLISHED 15425/python
tcp 0 0 127.0.0.1:56367 127.0.0.1:5672 ESTABLISHED 6295/python
tcp 0 0 127.0.0.1:56382 127.0.0.1:5672 ESTABLISHED 15404/python
tcp 0 0 192.168.206.130:47088 192.168.206.130:3306 ESTABLISHED 2093/python
tcp 0 0 192.168.206.130:47058 192.168.206.130:3306 ESTABLISHED 15414/python
tcp 0 0 127.0.0.1:56366 127.0.0.1:5672 ESTABLISHED 15414/python
tcp 0 0 127.0.0.1:56368 127.0.0.1:5672 ESTABLISHED 15470/python
tcp 0 0 127.0.0.1:56363 127.0.0.1:5672 ESTABLISHED 15425/python
tcp 0 0 192.168.206.130:47091 192.168.206.130:3306 ESTABLISHED 2093/python
tcp 0 0 127.0.0.1:56365 127.0.0.1:5672 ESTABLISHED 15404/python
tcp 0 0 192.168.206.130:47049 192.168.206.130:3306 ESTABLISHED 15470/python
tcp 0 0 192.168.206.130:47052 192.168.206.130:3306 ESTABLISHED 15404/python
tcp 0 0 192.168.206.130:47086 192.168.206.130:3306 ESTABLISHED 2093/python
tcp 0 0 192.168.206.130:47054 192.168.206.130:3306 ESTABLISHED 15454/python
tcp 0 0 192.168.206.130:47087 192.168.206.130:3306 ESTABLISHED 2093/python
tcp 0 0 127.0.0.1:56364 127.0.0.1:5672 ESTABLISHED 15454/python

Revision history for this message
Armando Migliaccio (armando-migliaccio) said :
#6

Check that your service users can authenticate against keystone.

Revision history for this message
neo0 (tungns-inf) said :
#7

I fixed my problem, it's my fault with wrong keystone endpoints for nova-compute and nova-volume. I post a note here with all the step I used to config my machine. Please check: http://nphilo.blogspot.com/2012/05/install-openstack-essex-on-ubuntu-1204.html

Revision history for this message
chandan dutta chowdhury (chandanc) said :
#8

I am seeing the exact same problem, I don't see any nova-api log for this request.

root@bng-vhost47-dcbg:~# nova --debug list
connect: (bng-vhost47-dcbg, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: bng-vhost47-dcbg:5000\r\nContent-Length: 115\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "adminUser", "password": "password"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Vary: X-Auth-Token
header: Date: Fri, 18 May 2012 05:13:59 GMT
header: Transfer-Encoding: chunked
connect: (bng-vhost47-dcbg, 8774)
send: u'GET /v2/a0357089de414875aa3cf18a9e0969fb/servers/detail HTTP/1.1\r\nHost: bng-vhost47-dcbg:8774\r\nx-auth-project-id: openstackDemo\r\nx-auth-token: 732f4b2ce65a4be1a17ed73e39e2a572\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 503 Service Unavailable\r\n'
header: Content-Length: 100
header: Content-Type: text/plain; charset=UTF-8
header: Date: Fri, 18 May 2012 05:13:59 GMT
DEBUG (shell:416) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 413, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 364, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/shell.py", line 522, in do_list
    utils.print_list(cs.servers.list(search_opts=search_opts), columns,
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/servers.py", line 279, in list
    return self._list("/servers%s%s" % (detail, query_string), "servers")
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 76, in _list
    data = body[response_key]
TypeError: string indices must be integers, not str
ERROR: string indices must be integers, not str

I tried connecting to the service using curl (see 3 different urls), looks like anything going to http://bng-vhost47-dcbg:8774/v2 is being rejected, strangely i don't get any nova-api log while accessing urls with /v2/...

 curl -k -D - -H "X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572" -X 'GET' -v http://bng-vhost47-dcbg:8774/v2/a0357089de414875aa3cf18a9e0969fb/images/
* About to connect() to bng-vhost47-dcbg port 8774 (#0)
* Trying 127.0.1.1... connected
> GET /v2/a0357089de414875aa3cf18a9e0969fb/images/ HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: bng-vhost47-dcbg:8774
> Accept: */*
> X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572
>
< HTTP/1.1 503 Service Unavailable
HTTP/1.1 503 Service Unavailable
< Content-Length: 212
Content-Length: 212
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Date: Fri, 18 May 2012 05:22:12 GMT
Date: Fri, 18 May 2012 05:22:12 GMT

<
<html>
 <head>
  <title>503 Service Unavailable</title>
 </head>
 <body>
  <h1>503 Service Unavailable</h1>
  The server is currently unavailable. Please try again at a later time.<br /><br />

 </body>
* Connection #0 to host bng-vhost47-dcbg left intact
* Closing connection #0

</html>root@bng-vhost47-dcbg:~# curl -k -D - -H "X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572" -X 'GET' -v http://bng-vhost47-dcbg:8774/v2
* About to connect() to bng-vhost47-dcbg port 8774 (#0)
* Trying 127.0.1.1... connected
> GET /v2 HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: bng-vhost47-dcbg:8774
> Accept: */*
> X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572
>
< HTTP/1.1 503 Service Unavailable
HTTP/1.1 503 Service Unavailable
< Content-Length: 212
Content-Length: 212
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Date: Fri, 18 May 2012 05:23:36 GMT
Date: Fri, 18 May 2012 05:23:36 GMT

<
<html>
 <head>
  <title>503 Service Unavailable</title>
 </head>
 <body>
  <h1>503 Service Unavailable</h1>
  The server is currently unavailable. Please try again at a later time.<br /><br />

 </body>
* Connection #0 to host bng-vhost47-dcbg left intact
* Closing connection #0
</html>root@bng-vhost47-dcbg:~# curl -k -D - -H "X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572" -X 'GET' -v http://bng-vhost47-dcbg:8774/
* About to connect() to bng-vhost47-dcbg port 8774 (#0)
* Trying 127.0.1.1... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: bng-vhost47-dcbg:8774
> Accept: */*
> X-Auth-Token: 732f4b2ce65a4be1a17ed73e39e2a572
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: application/json
Content-Type: application/json
< Content-Length: 158
Content-Length: 158
< Date: Fri, 18 May 2012 05:23:38 GMT
Date: Fri, 18 May 2012 05:23:38 GMT

<
* Connection #0 to host bng-vhost47-dcbg left intact
* Closing connection #0

Revision history for this message
hudaver (cetin01) said :
#9

I am seeing the exact same problem, I don't see any nova-api log for this request.

root@bng-vhost47-dcbg:~# nova --debug list
connect: (bng-vhost47-dcbg, 5000)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: bng-vhost47-dcbg:5000\r\nContent-Length: 115\r\ncontent-type: application/json\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "adminUser", "password": "password"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Vary: X-Auth-Token
header: Date: Fri, 18 May 2012 05:13:59 GMT
header: Transfer-Encoding: chunked
connect: (bng-vhost47-dcbg, 8774)
send: u'GET /v2/a0357089de414875aa3cf18a9e0969fb/servers/detail HTTP/1.1\r\nHost: bng-vhost47-dcbg:8774\r\nx-auth-project-id: openstackDemo\r\nx-auth-token: 732f4b2ce65a4be1a17ed73e39e2a572\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: python-novaclient\r\n\r\n'
reply: 'HTTP/1.1 503 Service Unavailable\r\n'
header: Content-Length: 100
header: Content-Type: text/plain; charset=UTF-8
https://bigdata-world.net
header: Date: Fri, 18 May 2012 05:13:59 GMT
DEBUG (shell:416) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 413, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 364, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/shell.py", line 522, in do_list
    utils.print_list(cs.servers.list(search_opts=search_opts), columns,
  File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/servers.py", line 279, in list
    return self._list("/servers%s%s" % (detail, query_string), "servers")
  File "/usr/lib/python2.7/dist-packages/novaclient/base.py", line 76, in _list
    data = body[response_key]
TypeError: string indices must be integers, not str
ERROR: string indices must be integers, not str