Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required option when importing a disk image #877

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion plugins/modules/azure_rm_manageddisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
- empty
- import
- copy
storage_account_id:
description:
- The full path to the storage account the image is to be imported from.
- Required when I(create_option=import).
valeriopoggi marked this conversation as resolved.
Show resolved Hide resolved
source_uri:
description:
- URI to a valid VHD file to be used or the resource ID of the managed disk to copy.
Expand Down Expand Up @@ -139,6 +143,7 @@
resource_group: myResourceGroup
create_option: import
source_uri: https://storageaccountname.blob.core.windows.net/containername/blob-name.vhd
storage_account_id: /subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/storageaccountname
valeriopoggi marked this conversation as resolved.
Show resolved Hide resolved
os_type: windows
storage_account_type: Premium_LRS

Expand Down Expand Up @@ -197,6 +202,11 @@
- Create option of the disk.
type: str
sample: copy
storage_account_id:
description:
- The full path to the storage account the image is to be imported from
type: str
sample: /subscriptions/<uuid>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>
source_uri:
description:
- URI to a valid VHD file to be used or the resource ID of the managed disk to copy.
Expand Down Expand Up @@ -285,6 +295,9 @@ def __init__(self):
type='str',
choices=['empty', 'import', 'copy']
),
storage_account_id=dict(
valeriopoggi marked this conversation as resolved.
Show resolved Hide resolved
type='str'
),
source_uri=dict(
type='str',
aliases=['source_resource_uri']
Expand Down Expand Up @@ -312,7 +325,7 @@ def __init__(self):
)
)
required_if = [
('create_option', 'import', ['source_uri']),
('create_option', 'import', ['source_uri', 'storage_account_id']),
('create_option', 'copy', ['source_uri']),
('create_option', 'empty', ['disk_size_gb'])
]
Expand All @@ -325,6 +338,7 @@ def __init__(self):
self.location = None
self.storage_account_type = None
self.create_option = None
self.storage_account_id = None
self.source_uri = None
self.os_type = None
self.disk_size_gb = None
Expand Down Expand Up @@ -455,6 +469,7 @@ def generate_managed_disk_property(self):
if self.create_option == 'import':
creation_data['create_option'] = self.compute_models.DiskCreateOption.import_enum
creation_data['source_uri'] = self.source_uri
creation_data['source_account_id'] = self.storage_account_id
elif self.create_option == 'copy':
creation_data['create_option'] = self.compute_models.DiskCreateOption.copy
creation_data['source_resource_id'] = self.source_uri
Expand Down