Skip to content

Commit

Permalink
fix #1853 (#1854)
Browse files Browse the repository at this point in the history
fix #1853

SUMMARY
Fix issue #1853
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_deploy_ovf
  • Loading branch information
ihumster authored Oct 8, 2023
1 parent ec6aaa5 commit c67163c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1853.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 7 additions & 5 deletions plugins/modules/vmware_deploy_ovf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ def __init__(self, url):
self.offset = 0

def _parse_url(self, url):
exp1 = r"(?P<url>(?:(?P<scheme>[a-zA-Z]+:\/\/)?(?P<hostname>(?:[-a-zA-Z0-9@%_\+~#=]{1,256}\.){1,256}(?:[-a-zA-Z0-9@%_\+~#=]{1,256})))"
exp2 = r"(?::(?P<port>[[:digit:]]+))?(?P<path>(?:\/[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~%]*)*)"
exp3 = r"(?P<query>(?:(?:\#|\?)[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~]*)*))"
return re.match(exp1 + exp2 + exp3, url)
HTTP_SCHEMA_PATTERN = (
r"(?P<url>(?:(?P<scheme>[a-zA-Z]+:\/\/)?(?P<hostname>(?:[-a-zA-Z0-9@%_\+~#=]{1,256}\.){1,256}(?:[-a-zA-Z0-9@%_\+~#=]{1,256})))"
r"(?::(?P<port>[[:digit:]]+))?(?P<path>(?:\/[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~%]*)*)"
r"(?P<query>(?:(?:\#|\?)[-a-zA-Z0-9!$&'()*+,\\\/:;=@\[\]._~]*)*))"
)
return re.match(HTTP_SCHEMA_PATTERN, url)

def _get_thumbprint(self, hostname):
pem = ssl.get_server_certificate((hostname, 443))
Expand Down Expand Up @@ -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']:
Expand Down

0 comments on commit c67163c

Please sign in to comment.