"Service VM" - _get_available_networks does extra filtering

Bug #1221320 reported by Avishay Balderman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Critical
Gary Kotton

Bug Description

Bug in Nova – the code filters the result by tenant_id although neutron will also do so by itself. In Neutron, if the credentials are for an Admin, than the filter is elevated to return the lits of all networks which is extactly what we would like to get for Service VMs.

Original Function:
https://github.com/openstack/nova/blob/master/nova/network/neutronv2/api.py#L118
Proposed Fix:
    def _get_available_networks(self, context, project_id,
                                net_ids=None):
        """Return a network list available for the tenant.
        The list contains networks owned by the tenant and public networks.
        If net_ids specified, it returns all network that the user
        Is eligible to see also filtered by networks with requested IDs only.
        """
        neutron = neutronv2.get_client(context)

        # If user has specified to attach an instance only to specific
        # networks, add them to **search_opts
        # This usually happens when creating a VM and specifying
        # that it should connect to specific networks.
        # In this case we rely on neutron to do the correct filtering by tenant
        # if it is a non-admin tenant.
        # If it is an admin-tenant, neutron will elevate and return all networks
        # which then get filtered by net_ids
        if net_ids:
            search_opts = {'id': net_ids}
            nets = neutron.list_networks(**search_opts).get('networks', [])
        else:
            # (1) Retrieve non-public network list owned by the tenant.
            search_opts = {'shared': False, 'tenant_id': project_id}
            nets = neutron.list_networks(**search_opts).get('networks', [])
            # (2) Retrieve public network list.
            search_opts = {'shared': True}
            nets += neutron.list_networks(**search_opts).get('networks', [])

        _ensure_requested_network_ordering(
            lambda x: x['id'],
            nets,
            net_ids)

        return nets

Revision history for this message
Avishay Balderman (avishayb) wrote :

This bug is a "show stopper" for Radware LBaaS driver

Changed in nova:
importance: Undecided → High
importance: High → Critical
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/45691

Changed in nova:
assignee: nobody → Gary Kotton (garyk)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/45691
Committed: http://github.com/openstack/nova/commit/8d985b826b459335ab89fef69c132470af066daf
Submitter: Jenkins
Branch: master

commit 8d985b826b459335ab89fef69c132470af066daf
Author: Gary Kotton <email address hidden>
Date: Mon Sep 9 04:59:27 2013 -0700

    Only return requested network ID's

    Only return the requested network ID's and not all of the
    public networks. This will also include 'shared' networks.

    Fixes bug 1221320

    Change-Id: I21ba4586c6e431b0dd1a87a9e5e493fae1b08357

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → havana-rc1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: havana-rc1 → 2013.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.