Gateway_less_FWD: NameError: global name 'db_dict' is not defined error while deleting allocation pool from virtual-router

Bug #1728024 reported by Chandra Sekhar Reddy Mallam
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juniper Openstack
Status tracked in Trunk
R4.1
Fix Committed
High
Atul Moghe
Trunk
Fix Committed
High
Atul Moghe

Bug Description

Following exception is observed from api server while trying to delete allocation pool from virtual-router.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py", line 3401, in _put_common
    ok, result = stateful_update()
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py", line 3357, in stateful_update
    prop_collection_updates=req_prop_coll_updates)
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py", line 2055, in pre_dbe_update
    db_conn)
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py", line 1955, in _vrouter_check_alloc_pool_delete
    iip_refs = db_dict.get('instance_ip_back_refs')
NameError: global name 'db_dict' is not defined

Build Info
----------
4.1.0.0-27 Mitaka

root@nodei15(controller):/usr/lib/python2.7/dist-packages/vnc_api# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
root@nodei15(controller):/usr/lib/python2.7/dist-packages/vnc_api#

Please see the complete log below:

>>> from vnc_api import vnc_api;from pprint import pprint;vnc_lib = vnc_api.VncApi(api_server_host = '10.204.217.127', auth_host ='10.204.217.127', username = 'admin', password = 'contrail123', tenant_name ='admin')

>>>
>>>
>>>
>>> nodek11_vr = vnc_lib.virtual_router_read(id="cc15ffd5-2008-4060-bc79-0dc3a3b3f6be")
irtual_router_update(nodek11_vr)
>>> project = vnc_lib.project_read(id="bd96af28-cd1e-4bd3-b673-9dbdf41dabb7")
>>>
>>> ipam0 = vnc_api.NetworkIpam('ipam0', project, vnc_api.IpamType("dhcp"),ipam_subnet_method='flat-subnet')
>>> vnc_lib.network_ipam_create(ipam0)
u'fc25a07b-2415-474e-b527-1894a4578d3b'
>>>
>>> sn1_pool_list = []
>>> sn1_pool_list.append(vnc_api.AllocationPoolType(start='11.1.1.16', end='11.1.1.18', vrouter_specific_pool=True))
>>>
>>> ipam0_sn1 = vnc_api.IpamSubnetType(subnet=vnc_api.SubnetType('11.1.1.0', 24), allocation_pools=sn1_pool_list, alloc_unit=1)
>>>
>>> ipam0.set_ipam_subnets(vnc_api.IpamSubnets([ipam0_sn1]))
>>> vnc_lib.network_ipam_update(ipam0)
u'{"network-ipam": {"href": "http://10.204.217.127:8082/network-ipam/fc25a07b-2415-474e-b527-1894a4578d3b", "uuid": "fc25a07b-2415-474e-b527-1894a4578d3b"}}'
>>>
>>> vr_subnet_list = []
>>> vr_subnet_list.append(vnc_api.SubnetType(ip_prefix='11.1.1.0',ip_prefix_len=24))
>>>
>>> vr_pool_list = []
>>> vr_pool_list.append(vnc_api.AllocationPoolType(start='11.1.1.16', end='11.1.1.18', vrouter_specific_pool=True))
>>> vr_ipam_type = vnc_api.VirtualRouterNetworkIpamType(vr_pool_list, vr_subnet_list)
>>>
>>> nodek11_vr.add_network_ipam(ipam0, vr_ipam_type)
>>> vnc_lib.virtual_router_update(nodek11_vr)

>>> pprint(vars(nodek11_vr))
{'_display_name': u'nodek11',
 '_id_perms': permissions = owner = cloud-admin, owner_access = 7, group = admin, group_access = 7, other_access = 7, uuid = uuid_mslong = 14705941449078751328, uuid_lslong = 13580901285228705470, enable = True, created = 2017-10-27T07:53:32.191127, last_modified = 2017-10-27T07:53:32.191127, description = None, user_visible = True, creator = None,
 '_original_network_ipam_refs': [],
 '_pending_field_list_updates': {},
 '_pending_field_map_updates': {},
 '_pending_field_updates': set([]),
 '_pending_ref_updates': set([]),
 '_perms2': owner = cloud-admin, owner_access = 7, global_access = 0, share = [],
 '_server_conn': <vnc_api.vnc_api.VncApi object at 0x7f82c79737d0>,
 '_type': 'virtual-router',
 '_uuid': u'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be',
 '_virtual_router_dpdk_enabled': False,
 '_virtual_router_ip_address': u'10.204.216.231',
 'fq_name': [u'default-global-system-config', u'nodek11'],
 'name': u'nodek11',
 'network_ipam_refs': [{'attr': allocation_pools = [start = 11.1.1.16, end = 11.1.1.18, vrouter_specific_pool = True], subnet = [ip_prefix = 11.1.1.0, ip_prefix_len = 24],
                        'to': [u'default-domain', u'admin', 'ipam0'],
                        'uuid': u'fc25a07b-2415-474e-b527-1894a4578d3b'}],
 'parent_type': u'global-system-config',
 'parent_uuid': u'52bed2b0-d2cf-4353-9fd4-2f1c0919758b'}
>>>

>>> nodek11_vr.del_network_ipam(ipam0)
>>> vnc_lib.virtual_router_update(nodek11_vr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 42, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 614, in _object_update
    'DELETE')
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 42, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 1080, in ref_update
    raise he
cfgm_common.exceptions.HttpError: HTTP Status: 500 Content: <type 'exceptions.NameError'>
Python 2.7.6: /usr/bin/python
Fri Oct 27 16:18:08 2017

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py in _put_common(self=<vnc_cfg_api_server.vnc_cfg_api_server.VncApiServer object>, api_name='ref-update', obj_type='virtual_router', obj_uuid='cc15ffd5-2008-4060-bc79-0dc3a3b3f6be', db_obj_dict={'display_name': 'nodek11', 'fq_name': ['default-global-system-config', 'nodek11'], 'id_perms': {'created': '2017-10-27T07:53:32.191127', 'creator': None, 'description': None, 'enable': True, 'last_modified': '2017-10-27T10:45:22.722247', 'permissions': {'group': 'admin', 'group_access': 7, 'other_access': 7, 'owner': 'cloud-admin', 'owner_access': 7}, 'user_visible': True, 'uuid': {'uuid_lslong': 13580901285228705470L, 'uuid_mslong': 14705941449078751328L}}, 'network_ipam_refs': [{'attr': {'allocation_pools': [{'end': '11.1.1.18', 'start': '11.1.1.16'}], 'subnet': [{'ip_prefix': '11.1.1.0', 'ip_prefix_len': 24}]}, 'to': ['default-domain', 'admin', 'ipam0'], 'uuid': 'fc25a07b-2415-474e-b527-1894a4578d3b'}], 'parent_type': 'global-system-config', 'parent_uuid': '52bed2b0-d2cf-4353-9fd4-2f1c0919758b', 'perms2': {'global_access': 0, 'owner': 'cloud-admin', 'owner_access': 7, 'share': []}, 'uuid': 'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be', 'virtual_router_dpdk_enabled': False, 'virtual_router_ip_address': '10.204.216.231'}, req_obj_dict={'network_ipam_refs': [], 'uuid': 'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be'}, req_prop_coll_updates=None, ref_args={'data': {'attr': None}, 'operation': 'DELETE', 'ref_obj_type': 'network_ipam', 'ref_uuid': 'fc25a07b-2415-474e-b527-1894a4578d3b'}, quota_dict=None)
 3399
 3400 try:
 3401 ok, result = stateful_update()
 3402 except Exception as e:
 3403 ok = False
ok = False
result = 'RWX'
stateful_update = <function stateful_update>

 /usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py in stateful_update()
 3355 (ok, result) = r_class.pre_dbe_update(
 3356 obj_uuid, obj_fq_name, req_obj_dict or {}, self._db_conn,
 3357 prop_collection_updates=req_prop_coll_updates)
 3358 if not ok:
 3359 return (ok, result)
prop_collection_updates undefined
req_prop_coll_updates = None

 /usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py in pre_dbe_update(cls=<class 'vnc_cfg_api_server.vnc_cfg_types.VirtualRouterServer'>, id='cc15ffd5-2008-4060-bc79-0dc3a3b3f6be', fq_name=['default-global-system-config', 'nodek11'], obj_dict={'network_ipam_refs': [], 'uuid': 'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be'}, db_conn=<vnc_cfg_api_server.vnc_db.VncDbClient object>, **kwargs={'prop_collection_updates': None})
 2053 (ok, db_dict) = cls.dbe_read(db_conn, 'virtual_router', id)
 2054 (ok, result) = cls._vrouter_check_alloc_pool_delete(db_dict, obj_dict,
 2055 db_conn)
 2056 if not ok:
 2057 return (False, (400, result))
db_conn = <vnc_cfg_api_server.vnc_db.VncDbClient object>

 /usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py in _vrouter_check_alloc_pool_delete(self=<class 'vnc_cfg_api_server.vnc_cfg_types.VirtualRouterServer'>, db_vr_dict={'display_name': 'nodek11', 'fq_name': ['default-global-system-config', 'nodek11'], 'id_perms': {'created': '2017-10-27T07:53:32.191127', 'creator': None, 'description': None, 'enable': True, 'last_modified': '2017-10-27T10:45:22.722247', 'permissions': {'group': 'admin', 'group_access': 7, 'other_access': 7, 'owner': 'cloud-admin', 'owner_access': 7}, 'user_visible': True, 'uuid': {'uuid_lslong': 13580901285228705470L, 'uuid_mslong': 14705941449078751328L}}, 'network_ipam_refs': [{'attr': {'allocation_pools': [{'end': '11.1.1.18', 'start': '11.1.1.16'}], 'subnet': [{'ip_prefix': '11.1.1.0', 'ip_prefix_len': 24}]}, 'to': ['default-domain', 'admin', 'ipam0'], 'uuid': 'fc25a07b-2415-474e-b527-1894a4578d3b'}], 'parent_type': 'global-system-config', 'parent_uuid': '52bed2b0-d2cf-4353-9fd4-2f1c0919758b', 'perms2': {'global_access': 0, 'owner': 'cloud-admin', 'owner_access': 7, 'share': []}, 'uuid': 'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be', 'virtual_machine_interfaces': [{'to': ['default-global-system-config', 'nodek11', 'vhost0'], 'uuid': 'b368ccfd-1910-4704-aa31-e37bd38db5ac'}], 'virtual_router_dpdk_enabled': False, ...}, req_vr_dict={'network_ipam_refs': [], 'uuid': 'cc15ffd5-2008-4060-bc79-0dc3a3b3f6be'}, db_conn=<vnc_cfg_api_server.vnc_db.VncDbClient object>)
 1953 ipam_refs = req_vr_dict.get('network_ipam_refs')
 1954 if not ipam_refs:
 1955 iip_refs = db_dict.get('instance_ip_back_refs')
 1956 if iip_refs:
 1957 return (False,
iip_refs undefined
db_dict undefined
<type 'exceptions.NameError'>: global name 'db_dict' is not defined
    __class__ = <type 'exceptions.NameError'>
    __delattr__ = <method-wrapper '__delattr__' of exceptions.NameError object>
    __dict__ = {}
    __doc__ = 'Name not found globally.'
    __format__ = <built-in method __format__ of exceptions.NameError object>
    __getattribute__ = <method-wrapper '__getattribute__' of exceptions.NameError object>
    __getitem__ = <method-wrapper '__getitem__' of exceptions.NameError object>
    __getslice__ = <method-wrapper '__getslice__' of exceptions.NameError object>
    __hash__ = <method-wrapper '__hash__' of exceptions.NameError object>
    __init__ = <method-wrapper '__init__' of exceptions.NameError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of exceptions.NameError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of exceptions.NameError object>
    __repr__ = <method-wrapper '__repr__' of exceptions.NameError object>
    __setattr__ = <method-wrapper '__setattr__' of exceptions.NameError object>
    __setstate__ = <built-in method __setstate__ of exceptions.NameError object>
    __sizeof__ = <built-in method __sizeof__ of exceptions.NameError object>
    __str__ = <method-wrapper '__str__' of exceptions.NameError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __unicode__ = <built-in method __unicode__ of exceptions.NameError object>
    args = ("global name 'db_dict' is not defined",)
    message = "global name 'db_dict' is not defined"

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py", line 3401, in _put_common
    ok, result = stateful_update()
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_api_server.py", line 3357, in stateful_update
    prop_collection_updates=req_prop_coll_updates)
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py", line 2055, in pre_dbe_update
    db_conn)
  File "/usr/lib/python2.7/dist-packages/vnc_cfg_api_server/vnc_cfg_types.py", line 1955, in _vrouter_check_alloc_pool_delete
    iip_refs = db_dict.get('instance_ip_back_refs')
NameError: global name 'db_dict' is not defined

Tags: api
Atul Moghe (moghea)
Changed in juniperopenstack:
milestone: r4.1.0.0-fcs → r5.0.0
status: New → In Progress
Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] R4.1

Review in progress for https://review.opencontrail.org/36933
Submitter: Atul Moghe (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] master

Review in progress for https://review.opencontrail.org/36935
Submitter: Atul Moghe (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/36933
Committed: http://github.com/Juniper/contrail-controller/commit/3fe6239a12e630f51ed390548eae614c5657fe99
Submitter: Zuul (<email address hidden>)
Branch: R4.1

commit 3fe6239a12e630f51ed390548eae614c5657fe99
Author: Atul Moghe <email address hidden>
Date: Fri Oct 27 13:14:36 2017 -0700

fix wrong variable name uses in validation method to check alloc-pool
delete
Closes-Bug: #1728024

Change-Id: I06a215982bf38679b30912e05278a4d3338f87f3

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote :

Reviewed: https://review.opencontrail.org/36935
Committed: http://github.com/Juniper/contrail-controller/commit/4f6b1964bceba8182e5149f0226764a46de0cee5
Submitter: Zuul (<email address hidden>)
Branch: master

commit 4f6b1964bceba8182e5149f0226764a46de0cee5
Author: Atul Moghe <email address hidden>
Date: Fri Oct 27 13:14:36 2017 -0700

fix wrong variable name uses in validation method to check alloc-pool
delete
Closes-Bug: #1728024

Change-Id: I06a215982bf38679b30912e05278a4d3338f87f3

Nischal Sheth (nsheth)
information type: Proprietary → Public
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.