This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 908514 - nova network-list throws ERROR: string indices must be integers, not str
nova network-list throws ERROR: string indices must be integers, not str
Status: CLOSED DUPLICATE of bug 893449
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-nova (Show other bugs)
2.0 (Folsom)
Unspecified Unspecified
unspecified Severity medium
: snapshot4
: 2.1
Assigned To: Brent Eagles
Yaniv Kaul
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-06 16:54 EST by james labocki
Modified: 2013-07-03 23:01 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-12 12:36:55 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description james labocki 2013-02-06 16:54:05 EST
[root@rhc-05 _base(keystone_admin)]$ nova --debug network-list

REQ: curl -i http://10.16.46.104:35357/v2.0/tokens -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "User-Agent: python-novaclient" -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "redhat"}}}'

connect: (10.16.46.104, 35357)
send: 'POST /v2.0/tokens HTTP/1.1\r\nHost: 10.16.46.104:35357\r\nContent-Length: 101\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": "admin", "passwordCredentials": {"username": "admin", "password": "redhat"}}}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Vary: X-Auth-Token
header: Content-Type: application/json
header: Content-Length: 2076
header: Date: Wed, 06 Feb 2013 21:42:20 GMT
RESP:{'date': 'Wed, 06 Feb 2013 21:42:20 GMT', 'vary': 'X-Auth-Token', 'content-length': '2076', 'status': '200', 'content-type': 'application/json'} {"access": {"token": {"expires": "2013-02-07T21:42:20Z", "id": "181b17d790d4423e9e860702f99e7331", "tenant": {"enabled": true, "description": "admin tenant", "name": "admin", "id": "8bfcec85f1f145ffb65e0935c637e904"}}, "serviceCatalog": [{"endpoints": [{"adminURL": "http://10.16.46.104:8776/v1/8bfcec85f1f145ffb65e0935c637e904", "region": "RegionOne", "internalURL": "http://10.16.46.104:8776/v1/8bfcec85f1f145ffb65e0935c637e904", "id": "a748e8a24be4422ba3b72e8d616f62b7", "publicURL": "http://10.16.46.104:8776/v1/8bfcec85f1f145ffb65e0935c637e904"}], "endpoints_links": [], "type": "volume", "name": "cinder"}, {"endpoints": [{"adminURL": "http://10.16.46.104:9292/v1", "region": "RegionOne", "internalURL": "http://10.16.46.104:9292/v1", "id": "f511bc03f0aa498c90505807e345380c", "publicURL": "http://10.16.46.104:9292/v1"}], "endpoints_links": [], "type": "image", "name": "glance"}, {"endpoints": [{"adminURL": "http://10.16.46.104:8774/v2/8bfcec85f1f145ffb65e0935c637e904", "region": "RegionOne", "internalURL": "http://10.16.46.104:8774/v2/8bfcec85f1f145ffb65e0935c637e904", "id": "0cc8f90610804ed4a9d0f95937d534db", "publicURL": "http://10.16.46.104:8774/v2/8bfcec85f1f145ffb65e0935c637e904"}], "endpoints_links": [], "type": "compute", "name": "nova"}, {"endpoints": [{"adminURL": "http://10.16.46.104:8773/services/Admin", "region": "RegionOne", "internalURL": "http://10.16.46.104:8773/services/Cloud", "id": "a5b65ea3147e413c9f156c247c64ce69", "publicURL": "http://10.16.46.104:8773/services/Cloud"}], "endpoints_links": [], "type": "ec2", "name": "nova_ec2"}, {"endpoints": [{"adminURL": "http://10.16.46.104:35357/v2.0", "region": "RegionOne", "internalURL": "http://10.16.46.104:5000/v2.0", "id": "e3935a9425e8467783b3258d94d47ba5", "publicURL": "http://10.16.46.104:5000/v2.0"}], "endpoints_links": [], "type": "identity", "name": "keystone"}], "user": {"username": "admin", "roles_links": [], "id": "ed10da39d1c94dfda2da736f0a6ae077", "roles": [{"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["267ea6ae676d4e929c982ea0c3f7e66e"]}}}


REQ: curl -i http://10.16.46.104:8774/v2/8bfcec85f1f145ffb65e0935c637e904/os-networks -X GET -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: 181b17d790d4423e9e860702f99e7331"

connect: (10.16.46.104, 8774)
send: u'GET /v2/8bfcec85f1f145ffb65e0935c637e904/os-networks HTTP/1.1\r\nHost: 10.16.46.104:8774\r\nx-auth-project-id: admin\r\nx-auth-token: 181b17d790d4423e9e860702f99e7331\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-e8740faf-e07c-45ca-bced-e079b4d7a30f
header: Content-Type: application/json
header: Content-Length: 716
header: Date: Wed, 06 Feb 2013 21:42:21 GMT
RESP:{'status': '200', 'content-length': '716', 'content-location': u'http://10.16.46.104:8774/v2/8bfcec85f1f145ffb65e0935c637e904/os-networks', 'x-compute-request-id': 'req-e8740faf-e07c-45ca-bced-e079b4d7a30f', 'date': 'Wed, 06 Feb 2013 21:42:21 GMT', 'content-type': 'application/json'} {"networks": [{"bridge": "br100", "vpn_public_port": null, "dhcp_start": "192.168.32.2", "bridge_interface": "eth1", "updated_at": timestamp(1360195493.0), "id": "d9987180-c24d-4ab6-aabf-e0e27408c0da", "cidr_v6": null, "deleted_at": null, "gateway": "192.168.32.1", "rxtx_base": null, "label": "novanetwork", "priority": null, "project_id": null, "vpn_private_address": null, "deleted": false, "vlan": null, "broadcast": "192.168.32.255", "netmask": "255.255.255.0", "injected": false, "cidr": "192.168.32.0/24", "vpn_public_address": null, "multi_host": false, "dns2": null, "created_at": timestamp(1360095293.0), "host": "rhc-05.lab.eng.bos.redhat.com", "gateway_v6": null, "netmask_v6": null, "dns1": "8.8.4.4"}]}

DEBUG (shell:543) string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/novaclient/shell.py", line 540, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/usr/lib/python2.6/site-packages/novaclient/shell.py", line 476, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.6/site-packages/novaclient/v1_1/shell.py", line 501, 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
Comment 1 Jon Thomas 2013-02-06 17:14:28 EST
https://bugs.launchpad.net/nova/+bug/1089430

f17 python-nova-2012.2-1.fc18.noarch patch seems to work:

--- /usr/lib/python2.7/site-packages/nova/network/manager.py	2013-02-06 17:08:48.913959580 -0500
+++ manager.py	2013-02-06 17:07:24.534146273 -0500
@@ -1761,8 +1761,8 @@ class NetworkManager(manager.SchedulerDe
             networks = self.db.network_get_all(context)
         except exception.NoNetworksFound:
             return []
-        return [jsonutils.to_primitive(network) for network in networks]
-	
+        return [dict(network.iteritems()) for network in networks]
+
     @wrap_check_policy
     def disassociate_network(self, context, network_uuid):
         network = self.get_network(context, network_uuid)
@@ -1772,12 +1772,12 @@ class NetworkManager(manager.SchedulerDe
     def get_fixed_ip(self, context, id):
         """Return a fixed ip"""
         fixed = self.db.fixed_ip_get(context, id)
-        return jsonutils.to_primitive(fixed)
-	
+        return dict(fixed.iteritems())
+
     @wrap_check_policy
     def get_fixed_ip_by_address(self, context, address):
         fixed = self.db.fixed_ip_get_by_address(context, address)
-        return jsonutils.to_primitive(fixed)
+        return dict(fixed.iteritems())
 
     def get_vif_by_mac_address(self, context, mac_address):
         """Returns the vifs record for the mac_address"""
Comment 2 Jon Thomas 2013-02-06 17:16:07 EST
bah, nm last patch for f17. This is the correct one.

--- manager.py	2013-02-06 17:07:24.534146273 -0500
+++ /usr/lib/python2.7/site-packages/nova/network/manager.py	2013-02-06 17:08:48.913959580 -0500
@@ -1761,8 +1761,8 @@ class NetworkManager(manager.SchedulerDe
             networks = self.db.network_get_all(context)
         except exception.NoNetworksFound:
             return []
-        return [dict(network.iteritems()) for network in networks]
-
+        return [jsonutils.to_primitive(network) for network in networks]
+	
     @wrap_check_policy
     def disassociate_network(self, context, network_uuid):
         network = self.get_network(context, network_uuid)
@@ -1772,12 +1772,12 @@ class NetworkManager(manager.SchedulerDe
     def get_fixed_ip(self, context, id):
         """Return a fixed ip"""
         fixed = self.db.fixed_ip_get(context, id)
-        return dict(fixed.iteritems())
-
+        return jsonutils.to_primitive(fixed)
+	
     @wrap_check_policy
     def get_fixed_ip_by_address(self, context, address):
         fixed = self.db.fixed_ip_get_by_address(context, address)
-        return dict(fixed.iteritems())
+        return jsonutils.to_primitive(fixed)
 
     def get_vif_by_mac_address(self, context, mac_address):
         """Returns the vifs record for the mac_address"""
Comment 4 Jon Thomas 2013-02-06 17:35:06 EST
fyi: looks like the patch is already in python-nova-2012.2.2-9 and I can't repro it on that version.

bug was reported on 2.2-8 and python-nova-2012.2-1
Comment 5 Brent Eagles 2013-02-12 12:36:55 EST
This bug is a duplicate of 893449 and a fix appears to have been brought in by fpercoco with commit c0045668. References:

Upstream: https://review.openstack.org/#/c/18616/
https://code.engineering.redhat.com/gerrit/2357

Reviewed and tested by Padraig.

*** This bug has been marked as a duplicate of bug 893449 ***

Note You need to log in before you can comment on or make changes to this bug.