From 59da779c41e35aa74bb025a2f15100f0175391e4 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 22 Mar 2019 12:59:28 -0700 Subject: [PATCH] Bug fixes for GCP modules (#54253) --- .../modules/cloud/google/gcp_compute_image.py | 8 +++--- .../cloud/google/gcp_compute_instance.py | 14 +++------- .../gcp_compute_instance_group_manager.py | 26 ++----------------- .../google/gcp_compute_instance_template.py | 14 +++------- .../gcp_compute_interconnect_attachment.py | 4 +-- .../cloud/google/gcp_compute_region_disk.py | 8 +++--- 6 files changed, 20 insertions(+), 54 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image.py b/lib/ansible/modules/cloud/google/gcp_compute_image.py index 4a8f9eb00a..fc6baa19e2 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_image.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_image.py @@ -730,10 +730,10 @@ class ImageImageencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) class ImageRawdisk(object): @@ -764,10 +764,10 @@ class ImageSourcediskencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) if __name__ == '__main__': diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance.py b/lib/ansible/modules/cloud/google/gcp_compute_instance.py index 1687eb9c85..e5790c2d8d 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance.py @@ -1298,14 +1298,10 @@ class InstanceDiskencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict( - {u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key'), u'sha256': self.request.get('sha256')} - ) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key')}) def from_response(self): - return remove_nones_from_dict( - {u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey'), u'sha256': self.request.get(u'sha256')} - ) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey')}) class InstanceInitializeparams(object): @@ -1348,10 +1344,10 @@ class InstanceSourceimageencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) class InstanceGuestacceleratorsArray(object): @@ -1406,7 +1402,6 @@ class InstanceNetworkinterfacesArray(object): { u'accessConfigs': InstanceAccessconfigsArray(item.get('access_configs', []), self.module).to_request(), u'aliasIpRanges': InstanceAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), - u'name': item.get('name'), u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'), u'networkIP': item.get('network_ip'), u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'), @@ -1418,7 +1413,6 @@ class InstanceNetworkinterfacesArray(object): { u'accessConfigs': InstanceAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), u'aliasIpRanges': InstanceAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), - u'name': item.get(u'name'), u'network': item.get(u'network'), u'networkIP': item.get(u'networkIP'), u'subnetwork': item.get(u'subnetwork'), diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py index 2c9ef40210..6153fc3a1f 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py @@ -537,32 +537,10 @@ class InstanceGroupManagerCurrentactions(object): self.request = {} def to_request(self): - return remove_nones_from_dict( - { - u'abandoning': self.request.get('abandoning'), - u'creating': self.request.get('creating'), - u'creatingWithoutRetries': self.request.get('creating_without_retries'), - u'deleting': self.request.get('deleting'), - u'none': self.request.get('none'), - u'recreating': self.request.get('recreating'), - u'refreshing': self.request.get('refreshing'), - u'restarting': self.request.get('restarting'), - } - ) + return remove_nones_from_dict({}) def from_response(self): - return remove_nones_from_dict( - { - u'abandoning': self.request.get(u'abandoning'), - u'creating': self.request.get(u'creating'), - u'creatingWithoutRetries': self.request.get(u'creatingWithoutRetries'), - u'deleting': self.request.get(u'deleting'), - u'none': self.request.get(u'none'), - u'recreating': self.request.get(u'recreating'), - u'refreshing': self.request.get(u'refreshing'), - u'restarting': self.request.get(u'restarting'), - } - ) + return remove_nones_from_dict({}) class InstanceGroupManagerNamedportsArray(object): diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py index eebdfa5540..68ffdabbce 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py @@ -1237,14 +1237,10 @@ class InstanceTemplateDiskencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict( - {u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key'), u'sha256': self.request.get('sha256')} - ) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key')}) def from_response(self): - return remove_nones_from_dict( - {u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey'), u'sha256': self.request.get(u'sha256')} - ) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey')}) class InstanceTemplateInitializeparams(object): @@ -1291,10 +1287,10 @@ class InstanceTemplateSourceimageencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) class InstanceTemplateGuestacceleratorsArray(object): @@ -1349,7 +1345,6 @@ class InstanceTemplateNetworkinterfacesArray(object): { u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get('access_configs', []), self.module).to_request(), u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), - u'name': item.get('name'), u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'), u'networkIP': item.get('network_ip'), u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'), @@ -1361,7 +1356,6 @@ class InstanceTemplateNetworkinterfacesArray(object): { u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), - u'name': item.get(u'name'), u'network': item.get(u'network'), u'networkIP': item.get(u'networkIP'), u'subnetwork': item.get(u'subnetwork'), diff --git a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py b/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py index 025755127b..3ce52d4707 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py @@ -484,10 +484,10 @@ class InterconnectAttachmentPrivateinterconnectinfo(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'tag8021q': self.request.get('tag8021q')}) + return remove_nones_from_dict({}) def from_response(self): - return remove_nones_from_dict({u'tag8021q': self.request.get(u'tag8021q')}) + return remove_nones_from_dict({}) if __name__ == '__main__': diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py b/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py index cd2500b12f..f789eaca29 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py @@ -585,10 +585,10 @@ class RegionDiskDiskencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) class RegionDiskSourcesnapshotencryptionkey(object): @@ -600,10 +600,10 @@ class RegionDiskSourcesnapshotencryptionkey(object): self.request = {} def to_request(self): - return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')}) def from_response(self): - return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) + return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')}) if __name__ == '__main__':