-
Notifications
You must be signed in to change notification settings - Fork 330
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
Allow creating gallery image versions from storage accounts #1466
Allow creating gallery image versions from storage accounts #1466
Conversation
os_disk: | ||
resource_group: myResourceGroup | ||
storage_account: myStorageAccount | ||
uri: "https://myStorageAccount.blob.core.windows.net/myContainer/myImage.vhd" |
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 realized after writing this that we could construct the URI by accepting two additional arguments, the container_name
and blob_name
, but I'm not sure if folks would prefer that two dropping the URI in there.
@@ -561,7 +586,7 @@ def exec_module(self, **kwargs): | |||
elif isinstance(kwargs[key]['os_disk']['source'], dict): | |||
if kwargs[key]['os_disk']['source'].get('id') is not None: | |||
self.body['properties']['storageProfile']['osDiskImage']['source']['id'] = kwargs[key]['os_disk']['source'].get('id') | |||
if kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ | |||
elif kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ |
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 think this was a bug, I'm happy to pull it out into a separate commit/PR if folks would prefer that.
- Reference to os disk snapshot. | ||
- Could be resource ID. | ||
- Could be a dictionary containing I(resource_group) and I(name). | ||
- Could be a dictionary containing I(resource_group), I(storage_account), and I(uri) if the snapshot is stored as a PageBlob in a storage account container. |
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.
line too long
@@ -561,7 +586,7 @@ def exec_module(self, **kwargs): | |||
elif isinstance(kwargs[key]['os_disk']['source'], dict): | |||
if kwargs[key]['os_disk']['source'].get('id') is not None: | |||
self.body['properties']['storageProfile']['osDiskImage']['source']['id'] = kwargs[key]['os_disk']['source'].get('id') | |||
if kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ | |||
elif kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ | |||
kwargs[key]['os_disk']['source'].get('name') is not None: |
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.
continuation line over-indented for visual indent
@@ -570,6 +595,18 @@ def exec_module(self, **kwargs): | |||
resource_group + | |||
'/providers/Microsoft.Compute/snapshots/' + | |||
kwargs[key]['os_disk']['source'].get('name')) | |||
elif kwargs[key]['os_disk']['source'].get('uri') is not None and \ | |||
kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ |
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.
continuation line over-indented for visual indent
@@ -570,6 +595,18 @@ def exec_module(self, **kwargs): | |||
resource_group + | |||
'/providers/Microsoft.Compute/snapshots/' + | |||
kwargs[key]['os_disk']['source'].get('name')) | |||
elif kwargs[key]['os_disk']['source'].get('uri') is not None and \ | |||
kwargs[key]['os_disk']['source'].get('resource_group') is not None and \ | |||
kwargs[key]['os_disk']['source'].get('storage_account') is not None: |
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.
continuation line over-indented for visual indent
self.subscription_id + | ||
'/resourceGroups/' + | ||
resource_group + | ||
'/providers/Microsoft.Storage/storageAccounts/' + |
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.
line too long
Hi, thanks for the review! I attempted to address the style comments. If it's still not looking right, is there a style guide for the project I should follow, or a linter? I did my best to follow the existing style of the file. |
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.
Update test case! Thank you very much!
- name: East US | ||
regional_replica_count: 1 | ||
storage_account_type: Standard_LRS | ||
storage_profile: |
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.
Parameter definition sequence: storage_profile -> os_disk -> source -> uri
os_disk_image: | ||
disk_encryption_set_id: "{{ des_results.state.id }}" | ||
storage_account_type: Standard_ZRS | ||
storage_profile: |
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.
Parameter definition sequence: storage_profile -> os_disk -> source -> uri
383 storage_profile:
384 os_disk:
385 source:
386 resource_group: "{{ resource_group }}"
387 storage_account: '{{ vms_output.vms[0].storage_account_name }}'
388 uri: 'https://{{ vms_output.vms[0].storage_account_name }}.blob.core.windows.net/{{ vms_output.vms[0].stor age_container_name }}/{{ vms_output.vms[0].storage_blob_name }}'
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.
@jeremycline The output variable on line 377 should be the one obtained by the VM on line 108. But lines 108 through 380 also register other output variables. So should pay attention to 120, 377, 378 this variable value acquisition! Thank you very much!
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.
Ah I see, it's being shadowed. My Ansible is very rusty, sorry. I think I've fixed it.
I think this should be ready for a re-review (time permitting, of course). We're using this in some automation in Fedora so I'd love it to be in the next release if possible. Thanks! |
Hi @Fred-sun, Just wanted to check in if there's anything I can do to help move this along - we've been carrying this patch to upload Fedora images nightly for a couple months and it's been working fine, for what it's worth. |
@jeremycline Ok, I will finish the PR review today. Thank you! |
@jeremycline Is the location of your test case improperly arranged? It is between line 307 and 387. Should we create a new name of galleryimageversion? |
@jeremycline In addition, after the completion of the test, please delete the newly created galleryimage, otherwise there will be problems when deleting the gallery. Thank you! |
It's possible to upload a VHD into a container in a storage account and then use that to import an image version. This adds a third way to specify an `os_disk` in the galleryimageversion plugin to support that approach.
There's no functional change.
Add the missing "source" intermediate key in the example and test case, and ensure the VM information isn't shadowed by later steps.
69afaab
to
2644113
Compare
This also removes the image version at the end so the gallery can be deleted.
2644113
to
c3be294
Compare
Thanks for the review! I've given the image version a different name and ensured it's deleted with the other image version. |
@jeremycline Thanks for your update! I will recheck it and push for merged! |
SUMMARY
It's possible to upload a VHD into a container in a storage account and then use that to import an image version. This adds a third way to specify an
os_disk
in the galleryimageversion plugin to support that approach.ISSUE TYPE
COMPONENT NAME
galleryimageversion