API call is broken: /ipam/tenants/{tenant_id}/ip_blocks/{ip_block_id}/ip_addresses

Bug #951499 reported by Tomasz Paszkowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Melange
Invalid
Undecided
Unassigned

Bug Description

ubuntu@vm-builder-1:~$ melange -t default ip_block list
ip_blocks:
- broadcast: 10.222.222.255
    cidr: 10.222.222.0/24
    created_at: '2012-03-05T10:09:01'
    dns1: 8.8.4.4
    dns2: 8.8.4.4
    gateway: 10.222.222.1
    id: d7313456-0015-4fca-93bd-d5b30c06d530
    netmask: 255.255.255.0
    network_id: c8a5df0e-d06f-4d76-b7d8-e73075148e5d
    parent_id: null
    policy_id: null
    tenant_id: default
    type: private
    updated_at: '2012-03-09T21:51:11'

ubuntu@vm-builder-1:~$ telnet 0 9898
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
GET /v1.0/ipam/tenants/default/ip_blocks/d7313456-0015-4fca-93bd-d5b30c06d530/ip_addresses HTTP/1.0

HTTP/1.1 500 Internal Server Error
Content-Length: 195
Content-Type: application/json; charset=UTF-8
Date: Sat, 10 Mar 2012 12:44:45 GMT
Connection: close

{"InternalServerError": {"message": "The server has either erred or is incapable of performing the requested operation.", "code": 500, "detail": "'NoneType' object has no attribute 'tenant_id'"}}Connection closed by foreign host.

2012-03-10 13:44:45 DEBUG [routes.middleware] Matched GET /ipam/tenants/default/ip_blocks/d7313456-0015-4fca-93bd-d5b30c06d530/ip_addresses
2012-03-10 13:44:45 DEBUG [routes.middleware] Route path: '/ipam/tenants/{tenant_id}/ip_blocks/{ip_block_id}/ip_addresses{.format:(json|xml)?}', defaults: {'action': u'index', 'controller': <melange.common.wsgi.Resource object at 0x2d05d90>}
2012-03-10 13:44:45 DEBUG [routes.middleware] Match dict: {'action': u'index', 'tenant_id': u'default', 'controller': <melange.common.wsgi.Resource object at 0x2d05d90>, 'ip_block_id': u'd7313456-0015-4fca-93bd-d5b30c06d530', 'format': None}
2012-03-10 13:44:45 DEBUG [wsgi] Empty body provided in request
2012-03-10 13:44:45 ERROR [melange.wsgi] 'NoneType' object has no attribute 'tenant_id'
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/melange/common/wsgi.py", line 146, in execute_action
    **action_args)
  File "/usr/lib/python2.7/dist-packages/melange/openstack/common/wsgi.py", line 312, in execute_action
    return self.dispatch(self.controller, action, request, **action_args)
  File "/usr/lib/python2.7/dist-packages/melange/openstack/common/wsgi.py", line 321, in dispatch
    return method(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/melange/ipam/service.py", line 148, in index
    return self._paginated_response('ip_addresses', addresses, request)
  File "/usr/lib/python2.7/dist-packages/melange/ipam/service.py", line 72, in _paginated_response
    collection = [element.data() for element in elements]
  File "/usr/lib/python2.7/dist-packages/melange/ipam/models.py", line 681, in data
    data['used_by_tenant'] = iface.tenant_id
AttributeError: 'NoneType' object has no attribute 'tenant_id'

Revision history for this message
Jason Kölker (jason-koelker) wrote :

I cannot reproduce this with master, can you confirm it and provide a reproducible case?

$ curl --stderr /dev/null -H 'Content-type: application/json' -XPOST -d '{"ip_block": {"type": "private", "cidr": "10.1.1.0/24"}}' http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks | python -m json.tool
{
    "ip_block": {
        "broadcast": "10.1.1.255",
        "cidr": "10.1.1.0/24",
        "created_at": "2012-03-21T03:05:01",
        "dns1": "8.8.8.8",
        "dns2": "8.8.4.4",
        "gateway": null,
        "id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
        "netmask": "255.255.255.0",
        "network_id": null,
        "parent_id": null,
        "policy_id": null,
        "tenant_id": "default",
        "type": "private",
        "updated_at": "2012-03-21T03:05:01"
    }
}

$ curl --stderr /dev/null -H 'Content-type: applicatoin/json' -XGET http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
{
    "ip_addresses": []
}

$ curl --stderr /dev/null -XPOST -H 'Content-type: application/json' -d '{"ip_address": {"interface_id": "vifid"}}' http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
{
    "ip_address": {
        "address": "10.1.1.0",
        "created_at": "2012-03-21T03:05:57",
        "id": "d29a173d-de75-4a9e-a62a-ee150851fc58",
        "interface_id": "vifid",
        "ip_block_id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
        "updated_at": "2012-03-21T03:05:57",
        "used_by_device": null,
        "used_by_tenant": "default",
        "version": 4
    }
}

$ curl --stderr /dev/null -H 'Content-type: applicatoin/json' -XGET http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
{
    "ip_addresses": [
        {
            "address": "10.1.1.0",
            "created_at": "2012-03-21T03:05:57",
            "id": "d29a173d-de75-4a9e-a62a-ee150851fc58",
            "interface_id": "vifid",
            "ip_block_id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
            "updated_at": "2012-03-21T03:05:57",
            "used_by_device": null,
            "used_by_tenant": "default",
            "version": 4
        }
    ]
}

Changed in melange:
status: New → Incomplete
Revision history for this message
Tomasz Paszkowski (ss7pro) wrote : Re: [Bug 951499] Re: API call is broken: /ipam/tenants/{tenant_id}/ip_blocks/{ip_block_id}/ip_addresses
Download full text (5.9 KiB)

Yes, with recent master it works.

On Wed, Mar 21, 2012 at 4:10 AM, Jason Kölker <email address hidden> wrote:
> I cannot reproduce this with master, can you confirm it and provide a
> reproducible case?
>
> $ curl --stderr /dev/null -H 'Content-type: application/json' -XPOST -d '{"ip_block": {"type": "private", "cidr": "10.1.1.0/24"}}' http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks | python -m json.tool
> {
>    "ip_block": {
>        "broadcast": "10.1.1.255",
>        "cidr": "10.1.1.0/24",
>        "created_at": "2012-03-21T03:05:01",
>        "dns1": "8.8.8.8",
>        "dns2": "8.8.4.4",
>        "gateway": null,
>        "id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
>        "netmask": "255.255.255.0",
>        "network_id": null,
>        "parent_id": null,
>        "policy_id": null,
>        "tenant_id": "default",
>        "type": "private",
>        "updated_at": "2012-03-21T03:05:01"
>    }
> }
>
> $ curl --stderr /dev/null -H 'Content-type: applicatoin/json' -XGET http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
> {
>    "ip_addresses": []
> }
>
> $ curl --stderr /dev/null -XPOST -H 'Content-type: application/json' -d '{"ip_address": {"interface_id": "vifid"}}' http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
> {
>    "ip_address": {
>        "address": "10.1.1.0",
>        "created_at": "2012-03-21T03:05:57",
>        "id": "d29a173d-de75-4a9e-a62a-ee150851fc58",
>        "interface_id": "vifid",
>        "ip_block_id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
>        "updated_at": "2012-03-21T03:05:57",
>        "used_by_device": null,
>        "used_by_tenant": "default",
>        "version": 4
>    }
> }
>
> $ curl --stderr /dev/null -H 'Content-type: applicatoin/json' -XGET http://localhost:9898/v1.0/ipam/tenants/default/ip_blocks/a78ca80c-242c-401c-854c-a2655ff5c3aa/ip_addresses | python -m json.tool
> {
>    "ip_addresses": [
>        {
>            "address": "10.1.1.0",
>            "created_at": "2012-03-21T03:05:57",
>            "id": "d29a173d-de75-4a9e-a62a-ee150851fc58",
>            "interface_id": "vifid",
>            "ip_block_id": "a78ca80c-242c-401c-854c-a2655ff5c3aa",
>            "updated_at": "2012-03-21T03:05:57",
>            "used_by_device": null,
>            "used_by_tenant": "default",
>            "version": 4
>        }
>    ]
> }
>
>
> ** Changed in: melange
>       Status: New => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/951499
>
> Title:
>  API call is broken:
>  /ipam/tenants/{tenant_id}/ip_blocks/{ip_block_id}/ip_addresses
>
> Status in A network information manager for OpenStack:
>  Incomplete
>
> Bug description:
>  ubuntu@vm-builder-1:~$ melange -t default ip_block list
>  ip_blocks:
>  -   broadcast: 10.222.222.255
>      cidr: 10.222.222.0/24
>      created_at: '2012-03-05T10:09:01'
>      dns1: 8.8.4.4
>      dns2: 8.8.4.4
>      gateway: 10.222.222.1
>      id: d7313456-0015-4fca-93bd-d5b30c06d530
>      netmask: 255.255...

Read more...

Troy Toman (troy-toman)
Changed in melange:
status: Incomplete → Invalid
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.