From a3d1889229ba849c16dfd0c7ba1ea98ef418ceaa Mon Sep 17 00:00:00 2001 From: Anna Khmelnitsky Date: Fri, 13 May 2022 21:27:34 +0000 Subject: [PATCH] Include object scope into policy search When data source searches for objects, it needs to search for LM or GM objects only. This change adds path verification to each search - /infra for Local Manager and /global-infra for Global Manager. --- nsxt/policy_search.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nsxt/policy_search.go b/nsxt/policy_search.go index a1e017723..02758f5bb 100644 --- a/nsxt/policy_search.go +++ b/nsxt/policy_search.go @@ -162,6 +162,9 @@ func searchGMPolicyResources(connector *client.RestConnector, query string) ([]* var cursor *string total := 0 + // Make sure local objects are not found (path needs to start with global-infra) + query = query + " AND path:\\/global-infra*" + for { searchResponse, err := client.List(query, cursor, nil, nil, nil, nil) if err != nil { @@ -185,6 +188,9 @@ func searchLMPolicyResources(connector *client.RestConnector, query string) ([]* var cursor *string total := 0 + // Make sure global objects are not found (path needs to start with infra) + query = query + " AND path:\\/infra*" + for { searchResponse, err := client.List(query, cursor, nil, nil, nil, nil) if err != nil {