-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Compute] sig image-version: add --data-snapshot-luns #12303
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2983,7 +2983,7 @@ def create_gallery_image(cmd, resource_group_name, gallery_name, gallery_image_n | |
| def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_name, gallery_image_version, | ||
| location=None, target_regions=None, storage_account_type=None, | ||
| end_of_life_date=None, exclude_from_latest=None, replica_count=None, tags=None, | ||
| os_snapshot=None, data_snapshots=None, managed_image=None): | ||
| os_snapshot=None, data_snapshots=None, managed_image=None, data_snapshot_luns=None): | ||
| from msrestazure.tools import resource_id, is_valid_resource_id | ||
| ImageVersionPublishingProfile, GalleryArtifactSource, ManagedArtifact, ImageVersion, TargetRegion = cmd.get_models( | ||
| 'GalleryImageVersionPublishingProfile', 'GalleryArtifactSource', 'ManagedArtifact', 'GalleryImageVersion', | ||
|
|
@@ -3020,10 +3020,17 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n | |
| source = GalleryArtifactVersionSource(id=managed_image) | ||
| if os_snapshot is not None: | ||
| os_disk_image = GalleryOSDiskImage(source=GalleryArtifactVersionSource(id=os_snapshot)) | ||
| if data_snapshot_luns and not data_snapshots: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious, is there general way in CLI to force parameters combination?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we have, otherwise, we don't need so many validation code. This is a common code pattern in Azure CLI. |
||
| raise CLIError('usage error: --data-snapshot-luns must be used together with --data-snapshots') | ||
| if data_snapshots: | ||
| if data_snapshot_luns and len(data_snapshots) != len(data_snapshot_luns): | ||
| raise CLIError('usage error: Length of --data-snapshots and --data-snapshot-luns should be equal.') | ||
arrownj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if not data_snapshot_luns: | ||
| data_snapshot_luns = [i for i in range(len(data_snapshots))] | ||
| data_disk_images = [] | ||
| for i, s in enumerate(data_snapshots): | ||
| data_disk_images.append(GalleryDataDiskImage(source=GalleryArtifactVersionSource(id=s), lun=i)) | ||
| data_disk_images.append(GalleryDataDiskImage(source=GalleryArtifactVersionSource(id=s), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if data_snapshot_luns None?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assign luns 0, 1, 2, ..., n - 1 |
||
| lun=data_snapshot_luns[i])) | ||
| storage_profile = GalleryImageVersionStorageProfile(source=source, os_disk_image=os_disk_image, | ||
| data_disk_images=data_disk_images) | ||
| image_version = ImageVersion(publishing_profile=profile, location=location, tags=(tags or {}), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use the full name of "LUN" for readability, add more description and add the constraints that it should contain the same number of arguments as
--data-snapshots.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to align with
data_snapshotson meaning, should it bedata_snapshots_luns?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add full name of LUN in help.
There is a validation in custom function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I treat "data-snapshot-lun" as an entity, then I add a "s" to represent plural form. I think both names are reasonable.