failed to list subnets with id only

Bug #1036425 reported by yong sheng gong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Critical
yong sheng gong

Bug Description

quantum subnet-list -- --name mysubnet1 --fields id failed due to the policy check:
on server side:
Traceback (most recent call last):
  File "/root/test/git/quantum/quantum/api/v2/resource.py", line 95, in resource
    result = method(request=request, **args)
  File "/root/test/git/quantum/quantum/api/v2/base.py", line 200, in index
    return self._items(request, True)
  File "/root/test/git/quantum/quantum/api/v2/base.py", line 178, in _items
    plugin=self._plugin)]
  File "/root/test/git/quantum/quantum/policy.py", line 165, in check
    real_target = _build_target(action, target, plugin, context)
  File "/root/test/git/quantum/quantum/policy.py", line 88, in _build_target
    data = f(context, target[parent_id], fields=['tenant_id'])
KeyError: 'network_id'

It seems the policy is wanting the tenant_id which the returned subnet does not have since it just returns id field.

Changed in quantum:
importance: Undecided → Critical
Changed in quantum:
assignee: nobody → yong sheng gong (gongysh)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

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

Changed in quantum:
status: New → In Progress
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

This worked for me:
index 20ddd66..8a52766 100644
--- a/quantum/api/v2/attributes.py
+++ b/quantum/api/v2/attributes.py
@@ -185,6 +185,7 @@ RESOURCE_ATTRIBUTE_MAP = {
         'name': {'allow_post': True, 'allow_put': True, 'default': '',
                  'is_visible': True},
         'network_id': {'allow_post': True, 'allow_put': False,
+ 'required_by_policy': True,
                        'validate': {'type:regex': UUID_PATTERN},
                        'is_visible': True},
         'admin_state_up': {'allow_post': True, 'allow_put': True,
@@ -228,6 +229,7 @@ RESOURCE_ATTRIBUTE_MAP = {
                        'validate': {'type:values': [4, 6]},
                        'is_visible': True},
         'network_id': {'allow_post': True, 'allow_put': False,
+ 'required_by_policy': True,
                        'validate': {'type:regex': UUID_PATTERN},
                        'is_visible': True},
         'cidr': {'allow_post': True, 'allow_put': False,

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

Reviewed: https://review.openstack.org/11312
Committed: http://github.com/openstack/quantum/commit/de58aec76bd5b70d21768a5e6b2fe9ff1ac307d9
Submitter: Jenkins
Branch: master

commit de58aec76bd5b70d21768a5e6b2fe9ff1ac307d9
Author: Yong Sheng Gong <email address hidden>
Date: Tue Aug 14 07:27:22 2012 +0800

    deal with parent_id not in target.

    bug 1036425

    If we filter the fields of the requested resource, we have no parent_id in the target, which we must be tolerant with.

    Change-Id: Ieb591d9208f16a0d3e05bda00bf45ae7aca846a5

Changed in quantum:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in quantum:
milestone: none → folsom-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in quantum:
milestone: folsom-3 → 2012.2
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.