Failed to execute nova list network if using qpid

Bug #1089430 reported by hill
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Zhi Yan Liu

Bug Description

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

 ## Appearance:
 1. Setup OpenStack cloud.
 2. Create networks
 3. List all network by nova CLI but meet the error:
 [root@firstbox ~]# nova network-list
 ERROR: string indices must be integers, not str

 ## Environment:
 OpenStack: ibm-folsom
 QPidd: 0.18
 qpid-python: 0.18

 ## Analysis:
 1. From the nova CLI verbose message, I found all the datetime type
 filed in the nova-api response body are all wrong, as below log, this
 situation cased nova client (nova-pythonclient) can not parse that
 payload data into python dictionary structure by the json parser library
 (novaclient/client.py:195, novaclient/base.py:67), then the nova client
 raise "string indices must be integers, not str" exception message to
 end user since "body" object is not a vaild dictionary object.

   RESP:{'status': '200', 'content-length': '682', 'content-location':
 u'http://10.0.0.1:8774/v1.1/cea4fe6aa31c4e85bfcd4025ad56e950/os-networks',
 'x-compute-request-id': 'req-0bce27d9-e05f-404b-a224-dffe75b27aa9',
 'date': 'Wed, 12 Dec 2012 10:19:11 GMT', 'content-type':
 'application/json'} {"networks": [{"bridge": "demonetbr0",
 "vpn_public_port": null, "dhcp_start": "172.0.0.2", "bridge_interface":
 null, "updated_at": timestamp(1355125471.0), "id":
 "491de13b-0cf0-403a-8d5b-9dd41185d3d9", "cidr_v6": null, "deleted_at":
 null, "gateway": "172.0.0.1", "rxtx_base": null, "label": "demonet",
 "priority": null, "project_id": null, "vpn_private_address": null,
 "deleted": false, "vlan": null, "broadcast": "172.0.0.255", "netmask":
 "255.255.255.0", "injected": false, "cidr": "172.0.0.0/24",
        "vpn_public_address": null, "multi_host": false, "dns2": null,
 "created_at": timestamp(1355124124.0), "host": "firstbox", "gateway_v6":
 null, "netmask_v6": null, "dns1": "8.8.4.4"}]}

Changed in nova:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Russell Bryant (russellb)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/17948

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/17948
Committed: http://github.com/openstack/nova/commit/1259395061005b70a123408b9e1cdd5bb76d9b62
Submitter: Jenkins
Branch: master

commit 1259395061005b70a123408b9e1cdd5bb76d9b62
Author: Russell Bryant <email address hidden>
Date: Wed Dec 12 10:29:13 2012 -0500

    Ensure datetimes can be properly serialized.

    The nova-network manager was returning db models from methods invoked
    via rpc.call(). These db models include non-primitive types that can
    not be properly serialized (namely datetime objects). Use
    to_primitive() to ensure that the data gets serialized properly.

    Fix bug 1089430.

    Change-Id: I019504cf68b2d420437c550b596eda8a12fe6618

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
hill (yuyuehill) wrote :

    It can fix the nova network list problem , but i got nova network-show failed for the same problem.

    This makes me worry since we don't have the test cases to verify this. And there are a lot of places that need to handle

    since it happens whey across rpc call. I may keep finding the similar issues on other api calls when i using

   qpid with openstack.

  any idea to solve this ?

Revision history for this message
Michael Fork (mjfork) wrote :

While this did work for network-list, network-show also fails.

# nova network-show a230db28-789b-4936-939a-eab06ac73924
ERROR: string indices must be integers, not str

Changed in nova:
status: Fix Committed → New
status: New → Confirmed
Revision history for this message
Yaguang Tang (heut2008) wrote :

@Michael

I tested that with the latest trunk code, nova network-show works well, can you try to test it again?

Zhi Yan Liu (lzy-dev)
Changed in nova:
assignee: Russell Bryant (russellb) → Zhi Yan Liu (lzy-dev)
status: Confirmed → In Progress
Revision history for this message
Qiu Yu (unicell) wrote :

Following patch should fix the network-show issue

diff --git a/nova/network/manager.py b/nova/network/manager.py
index b6b2e41..80bffde 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -1775,7 +1775,7 @@ class NetworkManager(manager.SchedulerDependentManager):
     @wrap_check_policy
     def get_network(self, context, network_uuid):
         network = self.db.network_get_by_uuid(context.elevated(), network_uuid)
- return dict(network.iteritems())
+ return jsonutils.to_primitive(network)

     @wrap_check_policy
     def get_all_networks(self, context):

Revision history for this message
Zhi Yan Liu (lzy-dev) wrote :

Yes, that is what i did and I have verified in my environment.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/18610

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/folsom)

Fix proposed to branch: stable/folsom
Review: https://review.openstack.org/18613

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: stable/folsom
Review: https://review.openstack.org/18616

Zhi Yan Liu (lzy-dev)
Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/18610
Committed: http://github.com/openstack/nova/commit/e12a6f61bb3d9ce2ebad4ea3aa97dc6455f692cc
Submitter: Jenkins
Branch: master

commit e12a6f61bb3d9ce2ebad4ea3aa97dc6455f692cc
Author: zhiyanliu <email address hidden>
Date: Mon Dec 24 11:22:45 2012 +0800

    Ensure datetimes can be properly serialized.

    The nova-network manager was returning db models from methods invoked
    via rpc.call(). These db models include non-primitive types that can
    not be properly serialized (namely datetime objects). Use
    to_primitive() to ensure that the data gets serialized properly.

    Fix bug: #1089430

    Change-Id: I0519e88444b8fcc3af5e43170ea07dd966ccef05
    Signed-off-by: zhiyanliu <email address hidden>

Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-2 → 2013.1
Sean Dague (sdague)
no longer affects: nova/folsom
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.