From fce5a9218f20fb685ea1f58279be610eac8fbed3 Mon Sep 17 00:00:00 2001 From: Jeroen van Renen Date: Wed, 1 Feb 2023 12:52:30 +0100 Subject: [PATCH] solution for issue: Create external network fails #777 --- pyvcloud/vcd/platform.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyvcloud/vcd/platform.py b/pyvcloud/vcd/platform.py index 3064bfea3..5f3c2af86 100644 --- a/pyvcloud/vcd/platform.py +++ b/pyvcloud/vcd/platform.py @@ -122,7 +122,7 @@ def create_external_network(self, """ vc_record = self.get_vcenter(vim_server_name) vc_href = vc_record.get('href') - pg_morefs = self.get_port_group_morefs(port_group_names) + pg_morefs = self.get_port_group_morefs(port_group_names, vim_server_name) vmw_external_network = E_VMEXT.VMWExternalNetwork(name=name) if description is not None: vmw_external_network.append(E.Description(description)) @@ -165,7 +165,7 @@ def create_external_network(self, media_type=EntityType.EXTERNAL_NETWORK.value, contents=vmw_external_network) - def get_port_group_morefs(self, port_group_names): + def get_port_group_morefs(self, port_group_names, vim_server_name): """Fetches moref and type for a given list of port group names. :return: list of tuples containing port group moref and type. @@ -175,9 +175,11 @@ def get_port_group_morefs(self, port_group_names): :raises: EntityNotFoundException: if any port group names cannot be found. """ + query_filter = 'vcName==%s' % urllib.parse.quote(vim_server_name) query = self.client.get_typed_query( ResourceType.PORT_GROUP.value, - query_result_format=QueryResultFormat.RECORDS) + query_result_format=QueryResultFormat.RECORDS, + qfilter=query_filter) records = list(query.execute()) port_groups = {} for record in records: