mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-09 04:10:27 -07:00
Add post-create for VpnTunnels Labels (#218)
<!-- This change is generated by MagicModules. --> /cc @emilymye
This commit is contained in:
parent
074e2e2e28
commit
0f625018df
2 changed files with 3 additions and 48 deletions
|
@ -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'),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -138,17 +138,6 @@ items:
|
||||||
- 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.
|
||||||
|
|
Loading…
Add table
Reference in a new issue