yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #05333
[Bug 1221320] Re: "Service VM" - _get_available_networks does extra filtering
** Changed in: nova
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1221320
Title:
"Service VM" - _get_available_networks does extra filtering
Status in OpenStack Compute (Nova):
Fix Released
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
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1221320/+subscriptions