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

snapshot fix for backporting #62559

Merged
merged 8 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self):

self.body = {}
self.query_parameters = {}
self.query_parameters['api-version'] = '2019-03-01'
self.query_parameters['api-version'] = '2019-07-01'
self.header_parameters = {}
self.header_parameters['Content-Type'] = 'application/json; charset=utf-8'

Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_galleryimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def __init__(self):

self.body = {}
self.query_parameters = {}
self.query_parameters['api-version'] = '2019-03-01'
self.query_parameters['api-version'] = '2019-07-01'
self.header_parameters = {}
self.header_parameters['Content-Type'] = 'application/json; charset=utf-8'

Expand Down
23 changes: 14 additions & 9 deletions lib/ansible/modules/cloud/azure/azure_rm_galleryimageversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def __init__(self):
location=dict(
type='str',
updatable=False,
disposition='/'
disposition='/',
comparison='location'
),
publishing_profile=dict(
type='dict',
Expand All @@ -227,7 +228,8 @@ def __init__(self):
options=dict(
name=dict(
type='str',
required=True
required=True,
comparison='location'
),
regional_replica_count=dict(
type='int',
Expand All @@ -244,14 +246,14 @@ def __init__(self):
pattern=('/subscriptions/{subscription_id}/resourceGroups'
'/{resource_group}/providers/Microsoft.Compute'
'/images/{name}'),
disposition='source/managedImage/id'
comparison='ignore'
),
snapshot=dict(
type='raw',
pattern=('/subscriptions/{subscription_id}/resourceGroups'
'/{resource_group}/providers/Microsoft.Compute'
'/snapshots/{name}'),
disposition='source/managedImage/id'
comparison='ignore'
),
replica_count=dict(
type='int',
Expand Down Expand Up @@ -295,7 +297,7 @@ def __init__(self):

self.body = {}
self.query_parameters = {}
self.query_parameters['api-version'] = '2019-03-01'
self.query_parameters['api-version'] = '2019-07-01'
self.header_parameters = {}
self.header_parameters['Content-Type'] = 'application/json; charset=utf-8'

Expand Down Expand Up @@ -363,9 +365,13 @@ def exec_module(self, **kwargs):
if not self.default_compare(modifiers, self.body, old_response, '', self.results):
self.to_do = Actions.Update

# fix leftovers (if empty structures were left)
self.body.get('properties', {}).get('publishingProfile', {}).pop('snapshot', None)
self.body.get('properties', {}).get('publishingProfile', {}).pop('managed_image', None)
# fix for differences between version 2019-03-01 and 2019-07-01
snapshot = self.body.get('properties', {}).get('publishingProfile', {}).pop('snapshot', None)
if snapshot is not None:
self.body['properties'].setdefault('storageProfile', {}).setdefault('osDiskImage', {}).setdefault('source', {})['id'] = snapshot
managed_image = self.body.get('properties', {}).get('publishingProfile', {}).pop('managed_image', None)
if managed_image:
self.body['properties'].setdefault('storageProfile', {}).setdefault('source', {})['id'] = managed_image

if (self.to_do == Actions.Create) or (self.to_do == Actions.Update):
self.log('Need to Create / Update the GalleryImageVersion instance')
Expand Down Expand Up @@ -393,7 +399,6 @@ def exec_module(self, **kwargs):

if response:
self.results["id"] = response["id"]
self.results["old_response"] = response

return self.results

Expand Down
30 changes: 15 additions & 15 deletions test/integration/targets/azure_rm_gallery/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
azure_rm_gallery:
resource_group: "{{ resource_group }}"
name: myGallery{{ rpfx }}
location: West US
location: eastus
description: This is the gallery description.
register: output

Expand All @@ -90,7 +90,7 @@
azure_rm_gallery:
resource_group: "{{ resource_group }}"
name: myGallery{{ rpfx }}
location: West US
location: eastus
description: This is the gallery description.
register: output

Expand All @@ -102,7 +102,7 @@
azure_rm_gallery:
resource_group: "{{ resource_group }}"
name: myGallery{{ rpfx }}
location: West US
location: eastus
description: This is the gallery description - xxx.
register: output

Expand Down Expand Up @@ -130,7 +130,7 @@
resource_group: "{{ resource_group }}"
gallery_name: myGallery{{ rpfx }}
name: myImage
location: West US
location: eastus
os_type: linux
os_state: generalized
identifier:
Expand All @@ -149,7 +149,7 @@
resource_group: "{{ resource_group }}"
gallery_name: myGallery{{ rpfx }}
name: myImage
location: West US
location: eastus
os_type: linux
os_state: generalized
identifier:
Expand All @@ -168,7 +168,7 @@
resource_group: "{{ resource_group }}"
gallery_name: myGallery{{ rpfx }}
name: myImage
location: West US
location: eastus
os_type: linux
os_state: generalized
identifier:
Expand Down Expand Up @@ -205,16 +205,16 @@
gallery_name: myGallery{{ rpfx }}
gallery_image_name: myImage
name: 10.1.3
location: West US
location: eastus
publishing_profile:
end_of_life_date: "2020-10-01t00:00:00+00:00"
exclude_from_latest: yes
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
- name: West US
- name: eastus
regional_replica_count: 1
- name: East US
- name: westus
regional_replica_count: 2
storage_account_type: Standard_ZRS
managed_image:
Expand All @@ -232,16 +232,16 @@
gallery_name: myGallery{{ rpfx }}
gallery_image_name: myImage
name: 10.1.3
location: West US
location: eastus
publishing_profile:
end_of_life_date: "2020-10-01t00:00:00+00:00"
exclude_from_latest: yes
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
- name: West US
- name: eastus
regional_replica_count: 1
- name: East US
- name: westus
regional_replica_count: 2
storage_account_type: Standard_ZRS
managed_image:
Expand All @@ -259,16 +259,16 @@
gallery_name: myGallery{{ rpfx }}
gallery_image_name: myImage
name: 10.1.3
location: West US
location: eastus
publishing_profile:
end_of_life_date: "2021-10-01t00:00:00+00:00"
exclude_from_latest: yes
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
- name: West US
- name: eastus
regional_replica_count: 1
- name: East US
- name: westus
regional_replica_count: 2
storage_account_type: Standard_ZRS
managed_image:
Expand Down