diff --git a/changelogs/fragments/1853.yml b/changelogs/fragments/1853.yml new file mode 100644 index 000000000..47a8ce77d --- /dev/null +++ b/changelogs/fragments/1853.yml @@ -0,0 +1,2 @@ +bugfixes: + - "vmware_deploy_ovf: fix error in finding networks part of code https://github.com/ansible-collections/community.vmware/issues/1853" diff --git a/plugins/modules/vmware_deploy_ovf.py b/plugins/modules/vmware_deploy_ovf.py index a78cff1ca..cdd934630 100644 --- a/plugins/modules/vmware_deploy_ovf.py +++ b/plugins/modules/vmware_deploy_ovf.py @@ -275,10 +275,12 @@ def __init__(self, url): self.offset = 0 def _parse_url(self, url): - exp1 = r"(?P(?:(?P[a-zA-Z]+:\/\/)?(?P(?:[-a-zA-Z0-9@%_\+~#=]{1,256}\.){1,256}(?:[-a-zA-Z0-9@%_\+~#=]{1,256})))" - exp2 = r"(?::(?P[[:digit:]]+))?(?P(?:\/[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~%]*)*)" - exp3 = r"(?P(?:(?:\#|\?)[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~]*)*))" - return re.match(exp1 + exp2 + exp3, url) + HTTP_SCHEMA_PATTERN = ( + r"(?P(?:(?P[a-zA-Z]+:\/\/)?(?P(?:[-a-zA-Z0-9@%_\+~#=]{1,256}\.){1,256}(?:[-a-zA-Z0-9@%_\+~#=]{1,256})))" + r"(?::(?P[[:digit:]]+))?(?P(?:\/[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~%]*)*)" + r"(?P(?:(?:\#|\?)[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~]*)*))" + ) + return re.match(HTTP_SCHEMA_PATTERN, url) def _get_thumbprint(self, hostname): pem = ssl.get_server_certificate((hostname, 443)) @@ -501,7 +503,7 @@ def get_objects(self): # If we have the same network name defined in multiple clusters, check all networks to get the right one networks = find_all_networks_by_name(self.content, value, datacenter_name=self.datacenter) if not networks: - self.module.fail_json(msg=f"'{self.params[networks]}' could not be located") + self.module.fail_json(msg=f"Network '{value}' could not be located") # Search for the network key of the same network name, that resides in a cluster parameter for network in networks: if self.params['cluster']: