list ports with specific fixed ip

Bug #1532982 reported by Mohammad Banikazemi
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kuryr
Fix Released
Critical
vikas choudhary

Bug Description

The list ports operation when the fixed_ips is/are specified does not work.

--------------------------------------------------------------------------------
ERROR in utils [/home/openstack/latest/kuryr/kuryr/utils.py:69]:
Unexpected error happened: Invalid input for operation: '{'subnet_id': u'cd8ff74b-d8dd-4c29-a7b0-8982e8d0d2df', 'ip_address': '10.0.3.5'}' is not of the form <key>=[value].
--------------------------------------------------------------------------------
Unexpected error happened: Invalid input for operation: '{'subnet_id': u'cd8ff74b-d8dd-4c29-a7b0-8982e8d0d2df', 'ip_address': '10.0.3.5'}' is not of the form <key>=[value].
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/openstack/latest/kuryr/kuryr/controllers.py", line 585, in network_driver_create_endpoint
    interface_cidrv6, interface_mac)
  File "/home/openstack/latest/kuryr/kuryr/controllers.py", line 290, in _create_or_update_port
    filtered_ports = app.neutron.list_ports(fixed_ips=fixed_ips)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 99, in with_params
    ret = self.function(instance, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 313, in list_ports
    **_params)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1335, in list
    for r in self._pagination(collection, path, **params):
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1348, in _pagination
    res = self.get(path, params=params)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1321, in get
    headers=headers, params=params)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1298, in retry_request
    headers=headers, params=params)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1252, in do_request
    self._handle_fault_response(status_code, replybody)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 1217, in _handle_fault_response
    exception_handler_v20(status_code, des_error_body)
  File "/usr/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 67, in exception_handler_v20
    status_code=status_code)
BadRequest: Invalid input for operation: '{'subnet_id': u'cd8ff74b-d8dd-4c29-a7b0-8982e8d0d2df', 'ip_address': '10.0.3.5'}' is not of the form <key>=[value].
127.0.0.1 - - [11/Jan/2016 22:46:36] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 400 -

Revision history for this message
vikas choudhary (choudharyvikas16) wrote :
Changed in kuryr:
assignee: nobody → vikas choudhary (choudharyvikas16)
Changed in kuryr:
status: New → In Progress
Revision history for this message
Mohammad Banikazemi (mb-s) wrote :

Looks like list ports expects params as something in this form:
[u'subnet_id=5692970e-df7d-458d-9c21-b33a117ab488', u'ip_address=10.0.2.4']

Something like the following works.

z= [] # this can be a list or a set; either way works
for s in fixed_ips:
    for k,v in s.iteritems():
 z.append('%s=%s' % (k,v))

nets = neutron.list_ports(fixed_ips=z)

Not sure if there is a cleaner way of doing this.

For cases where there are multiple fixed_ip entries, something like the following works for me to get the port id:

first = True
for s in fixed_ips:
    z = []
    y = set()
    for k,v in s.iteritems():
        z.append('%s=%s' % (k,v))
    nets = neutron.list_ports(fixed_ips=z)

    if nets.get('ports'): # there can be at most 1 such port
        y.add(nets['ports'][0]['id'])
    if first:
        yy = y
    else:
        yy &= y

Let's check the neutron and neutron client code and see if there is a better solution.

Revision history for this message
vikas choudhary (choudharyvikas16) wrote :

For multiple subnet-ip pairs(for example v4 and v6 ) , neutron is accepting input in following form:

{'fixed_ips': ['subnet_id=f0663ca3-540c-4d36-9823-22f773874de5', 'ip_address=50.0.0.2', 'subnet_id=6607a230-f3eb-4937-b09f-9dd659211139', 'ip_address=fdfa:8456:1afa:0:f816:3eff:fe67:885e']}

Changed in kuryr:
importance: High → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kuryr (master)

Reviewed: https://review.openstack.org/266083
Committed: https://git.openstack.org/cgit/openstack/kuryr/commit/?id=5d106ebab9e03a871f531dace963c13db9e9a2de
Submitter: Jenkins
Branch: master

commit 5d106ebab9e03a871f531dace963c13db9e9a2de
Author: Vikas Choudhary <email address hidden>
Date: Tue Jan 12 05:38:13 2016 +0530

    Fix /NetworkDriver.CreateEndpoint, port updation API not working

    Pass input arguments to neutron port listing API and port updation
    APIs, which are used in /NetworkDriver.CreateEndpoint, in correct
    format. list_ports API expects 'fixed-ips' filter in the following
    format:
            ['subnet_id=<value>', 'ip_address=<value>']
    Similarly, pass input arguments to update_port API in the expected
    format.

    Change-Id: I28885ca2d8f552f9b25cb4c26ac70cfc1b110e9f
    Closes-Bug: #1533001
    Closes-Bug: #1532982

Changed in kuryr:
status: In Progress → Fix Released
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.