mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Bug fixes for GCP modules (#54254)
This commit is contained in:
parent
5c08afe16f
commit
65f2bfc850
2 changed files with 5 additions and 39 deletions
|
@ -403,10 +403,10 @@ class SslPolicyWarningsArray(object):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _request_for_item(self, item):
|
def _request_for_item(self, item):
|
||||||
return remove_nones_from_dict({u'code': item.get('code'), u'message': item.get('message')})
|
return remove_nones_from_dict({})
|
||||||
|
|
||||||
def _response_from_item(self, item):
|
def _response_from_item(self, item):
|
||||||
return remove_nones_from_dict({u'code': item.get(u'code'), u'message': item.get(u'message')})
|
return remove_nones_from_dict({})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -105,10 +105,6 @@ options:
|
||||||
The ranges should be disjoint.
|
The ranges should be disjoint.
|
||||||
- Only IPv4 is supported.
|
- Only IPv4 is supported.
|
||||||
required: false
|
required: false
|
||||||
labels:
|
|
||||||
description:
|
|
||||||
- Labels to apply to this VpnTunnel.
|
|
||||||
required: false
|
|
||||||
region:
|
region:
|
||||||
description:
|
description:
|
||||||
- The region where the tunnel is located.
|
- The region where the tunnel is located.
|
||||||
|
@ -241,17 +237,6 @@ remoteTrafficSelector:
|
||||||
- Only IPv4 is supported.
|
- Only IPv4 is supported.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
labels:
|
|
||||||
description:
|
|
||||||
- Labels to apply to this VpnTunnel.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
labelFingerprint:
|
|
||||||
description:
|
|
||||||
- The fingerprint used for optimistic locking of this resource. Used internally
|
|
||||||
during updates.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
region:
|
region:
|
||||||
description:
|
description:
|
||||||
- The region where the tunnel is located.
|
- The region where the tunnel is located.
|
||||||
|
@ -287,7 +272,6 @@ def main():
|
||||||
ike_version=dict(default=2, type='int'),
|
ike_version=dict(default=2, type='int'),
|
||||||
local_traffic_selector=dict(type='list', elements='str'),
|
local_traffic_selector=dict(type='list', elements='str'),
|
||||||
remote_traffic_selector=dict(type='list', elements='str'),
|
remote_traffic_selector=dict(type='list', elements='str'),
|
||||||
labels=dict(type='dict'),
|
|
||||||
region=dict(required=True, type='str'),
|
region=dict(required=True, type='str'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -304,7 +288,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
update(module, self_link(module), kind)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
fetch = fetch_resource(module, self_link(module), kind)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -314,7 +298,6 @@ def main():
|
||||||
else:
|
else:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
fetch = create(module, collection(module), kind)
|
fetch = create(module, collection(module), kind)
|
||||||
labels_update(module, module.params, fetch)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
fetch = {}
|
fetch = {}
|
||||||
|
@ -329,22 +312,8 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind, fetch):
|
def update(module, link, kind):
|
||||||
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
module.fail_json(msg="VpnTunnel cannot be edited")
|
||||||
return fetch_resource(module, self_link(module), kind)
|
|
||||||
|
|
||||||
|
|
||||||
def update_fields(module, request, response):
|
|
||||||
if response.get('labels') != request.get('labels'):
|
|
||||||
labels_update(module, request, response)
|
|
||||||
|
|
||||||
|
|
||||||
def labels_update(module, request, response):
|
|
||||||
auth = GcpSession(module, 'compute')
|
|
||||||
auth.post(
|
|
||||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/vpnTunnels/{name}/setLabels"]).format(**module.params),
|
|
||||||
{u'labels': module.params.get('labels'), u'labelFingerprint': response.get('labelFingerprint')},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
@ -364,7 +333,6 @@ def resource_to_request(module):
|
||||||
u'ikeVersion': module.params.get('ike_version'),
|
u'ikeVersion': module.params.get('ike_version'),
|
||||||
u'localTrafficSelector': module.params.get('local_traffic_selector'),
|
u'localTrafficSelector': module.params.get('local_traffic_selector'),
|
||||||
u'remoteTrafficSelector': module.params.get('remote_traffic_selector'),
|
u'remoteTrafficSelector': module.params.get('remote_traffic_selector'),
|
||||||
u'labels': module.params.get('labels'),
|
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -441,8 +409,6 @@ def response_to_hash(module, response):
|
||||||
u'ikeVersion': response.get(u'ikeVersion'),
|
u'ikeVersion': response.get(u'ikeVersion'),
|
||||||
u'localTrafficSelector': response.get(u'localTrafficSelector'),
|
u'localTrafficSelector': response.get(u'localTrafficSelector'),
|
||||||
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
|
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
|
||||||
u'labels': response.get(u'labels'),
|
|
||||||
u'labelFingerprint': response.get(u'labelFingerprint'),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue