azure_rm_virtualmachine: Fix VHD URI valid schemes in extract_names_from_blob_uri (#64507)

When a VM has been provisioned with unmanaged disks (VHD), the URI
schemes used for those disks are kept untouched. Unfortunately, the regexp that
parses the URI only accepts 'https' leading the module to fail if one
uses for instance 'http'.

Please note that the official Azure API documentation uses 'http' and
not 'https' as URI scheme.

Resolves #64506

Testing Done: Using an ARM template, provision a VM with one OS and one
data disk with 'http' as VHD URI scheme. Then use the
azure_rm_virtualmachine module to delete the VM. Finally check that the
module does not fail anymore and that the unmanaged disks are correctly
deleted from the storage account.
This commit is contained in:
mmallet 2019-11-27 08:55:06 +01:00 committed by Zim Kalinowski
parent 7c65ad11e2
commit 8df03a6f6e

View file

@ -790,7 +790,7 @@ AZURE_ENUM_MODULES = ['azure.mgmt.compute.models']
def extract_names_from_blob_uri(blob_uri, storage_suffix): def extract_names_from_blob_uri(blob_uri, storage_suffix):
# HACK: ditch this once python SDK supports get by URI # HACK: ditch this once python SDK supports get by URI
m = re.match(r'^https://(?P<accountname>[^.]+)\.blob\.{0}/' m = re.match(r'^https?://(?P<accountname>[^.]+)\.blob\.{0}/'
r'(?P<containername>[^/]+)/(?P<blobname>.+)$'.format(storage_suffix), blob_uri) r'(?P<containername>[^/]+)/(?P<blobname>.+)$'.format(storage_suffix), blob_uri)
if not m: if not m:
raise Exception("unable to parse blob uri '%s'" % blob_uri) raise Exception("unable to parse blob uri '%s'" % blob_uri)