From 152a94bfaf9f7ce6448d957d9d5c10aba5b37c5c Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 25 Nov 2019 16:19:49 -0800 Subject: [PATCH] Bug fixes for GCP modules (#64825) --- .../cloud/google/gcp_compute_subnetwork.py | 21 +++---------------- .../google/gcp_compute_subnetwork_info.py | 5 ----- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py index e18bd4f9aac..e6a6ce4da9e 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py @@ -99,12 +99,6 @@ options: }}"' required: true type: dict - enable_flow_logs: - description: - - Whether to enable flow logging for this subnetwork. - required: false - type: bool - version_added: '2.8' secondary_ip_ranges: description: - An array of configurations for secondary IP ranges for VM instances contained @@ -263,11 +257,6 @@ network: - Only networks that are in the distributed mode can have subnetworks. returned: success type: dict -enableFlowLogs: - description: - - Whether to enable flow logging for this subnetwork. - returned: success - type: bool fingerprint: description: - Fingerprint of this resource. This field is used internally during updates of @@ -333,7 +322,6 @@ def main(): ip_cidr_range=dict(required=True, type='str'), name=dict(required=True, type='str'), network=dict(required=True, type='dict'), - enable_flow_logs=dict(type='bool'), secondary_ip_ranges=dict( type='list', elements='dict', options=dict(range_name=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str')) ), @@ -386,8 +374,8 @@ def update(module, link, kind, fetch): def update_fields(module, request, response): if response.get('ipCidrRange') != request.get('ipCidrRange'): ip_cidr_range_update(module, request, response) - if response.get('enableFlowLogs') != request.get('enableFlowLogs') or response.get('secondaryIpRanges') != request.get('secondaryIpRanges'): - enable_flow_logs_update(module, request, response) + if response.get('secondaryIpRanges') != request.get('secondaryIpRanges'): + fingerprint_update(module, request, response) if response.get('privateIpGoogleAccess') != request.get('privateIpGoogleAccess'): private_ip_google_access_update(module, request, response) @@ -400,12 +388,11 @@ def ip_cidr_range_update(module, request, response): ) -def enable_flow_logs_update(module, request, response): +def fingerprint_update(module, request, response): auth = GcpSession(module, 'compute') auth.patch( ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}"]).format(**module.params), { - u'enableFlowLogs': module.params.get('enable_flow_logs'), u'fingerprint': response.get('fingerprint'), u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(), }, @@ -434,7 +421,6 @@ def resource_to_request(module): u'ipCidrRange': module.params.get('ip_cidr_range'), u'name': module.params.get('name'), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), - u'enableFlowLogs': module.params.get('enable_flow_logs'), u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(), u'privateIpGoogleAccess': module.params.get('private_ip_google_access'), u'region': module.params.get('region'), @@ -510,7 +496,6 @@ def response_to_hash(module, response): u'ipCidrRange': response.get(u'ipCidrRange'), u'name': response.get(u'name'), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), - u'enableFlowLogs': response.get(u'enableFlowLogs'), u'fingerprint': response.get(u'fingerprint'), u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(response.get(u'secondaryIpRanges', []), module).from_response(), u'privateIpGoogleAccess': response.get(u'privateIpGoogleAccess'), diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py index f4237189e18..149d65377df 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py @@ -164,11 +164,6 @@ resources: - Only networks that are in the distributed mode can have subnetworks. returned: success type: dict - enableFlowLogs: - description: - - Whether to enable flow logging for this subnetwork. - returned: success - type: bool fingerprint: description: - Fingerprint of this resource. This field is used internally during updates