NSXv: return subnet edges only when requested
Returning the connected edges (or advanced service providers) for a subnet has a heavy performance impact - therefore we should return that data only when requested explicitly. Change-Id: I276d82617414a3e8301d9fcd9a26d05876496616
This commit is contained in:
parent
d695df69c2
commit
255ef764eb
@ -669,7 +669,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
if not context.is_admin:
|
if not context.is_admin:
|
||||||
return subnet
|
return subnet
|
||||||
elif not fields or as_providers.ADV_SERVICE_PROVIDERS in fields:
|
elif fields and as_providers.ADV_SERVICE_PROVIDERS in fields:
|
||||||
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
||||||
self._get_subnet_as_providers(context, subnet))
|
self._get_subnet_as_providers(context, subnet))
|
||||||
return subnet
|
return subnet
|
||||||
@ -680,16 +680,14 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
fields, sorts, limit,
|
fields, sorts, limit,
|
||||||
marker, page_reverse)
|
marker, page_reverse)
|
||||||
|
|
||||||
if not context.is_admin:
|
if not context.is_admin or (not filters and not fields):
|
||||||
return subnets
|
return subnets
|
||||||
|
|
||||||
new_subnets = []
|
new_subnets = []
|
||||||
if (not fields
|
if ((fields and as_providers.ADV_SERVICE_PROVIDERS in fields)
|
||||||
or as_providers.ADV_SERVICE_PROVIDERS in fields
|
|
||||||
or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))):
|
or (filters and filters.get(as_providers.ADV_SERVICE_PROVIDERS))):
|
||||||
|
|
||||||
# We only deal metadata provider field when:
|
# We only deal metadata provider field when:
|
||||||
# - All fields are retrieved
|
|
||||||
# - adv_service_provider is explicitly retrieved
|
# - adv_service_provider is explicitly retrieved
|
||||||
# - adv_service_provider is used in a filter
|
# - adv_service_provider is used in a filter
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
@ -700,8 +698,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
if md_filter is None or len(set(as_provider) & set(md_filter)):
|
if md_filter is None or len(set(as_provider) & set(md_filter)):
|
||||||
# Include metadata_providers only if requested in results
|
# Include metadata_providers only if requested in results
|
||||||
if (not fields
|
if fields and as_providers.ADV_SERVICE_PROVIDERS in fields:
|
||||||
or as_providers.ADV_SERVICE_PROVIDERS in fields):
|
|
||||||
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
subnet[as_providers.ADV_SERVICE_PROVIDERS] = (
|
||||||
as_provider)
|
as_provider)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user