Add description field to Route resource, make non-updateable.

This commit is contained in:
Nathan McKinley 2018-06-14 18:29:50 +00:00 committed by Alex Stephen
parent a940819003
commit bfb2114f39

View file

@ -86,9 +86,10 @@ options:
description: description:
- The network that this route applies to. - The network that this route applies to.
- 'This field represents a link to a Network resource in GCP. It can be specified - 'This field represents a link to a Network resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this network field to "{{ name-of-resource }}"' to a gcp_compute_network task and then set this network field to "{{ name-of-resource
}}"'
required: true required: true
priority: priority:
description: description:
@ -117,9 +118,10 @@ options:
instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
.' .'
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_instance of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this next_hop_instance field to "{{ name-of-resource }}"' to a gcp_compute_instance task and then set this next_hop_instance field to
"{{ name-of-resource }}"'
required: false required: false
next_hop_ip: next_hop_ip:
description: description:
@ -129,9 +131,10 @@ options:
description: description:
- URL to a VpnTunnel that should handle matching packets. - URL to a VpnTunnel that should handle matching packets.
- 'This field represents a link to a VpnTunnel resource in GCP. It can be specified - 'This field represents a link to a VpnTunnel resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_vpn_tunnel of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this next_hop_vpn_tunnel field to "{{ name-of-resource }}"' to a gcp_compute_vpn_tunnel task and then set this next_hop_vpn_tunnel field
to "{{ name-of-resource }}"'
required: false required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
@ -142,26 +145,26 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-route" name: network-route
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a route - name: create a route
gcp_compute_route: gcp_compute_route:
name: "test_object" name: test_object
dest_range: 192.168.6.0/24 dest_range: 192.168.6.0/24
next_hop_gateway: global/gateways/default-internet-gateway next_hop_gateway: global/gateways/default-internet-gateway
network: "{{ network }}" network: "{{ network }}"
tags: tags:
- backends - backends
- databases - databases
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''
@ -191,7 +194,7 @@ network:
description: description:
- The network that this route applies to. - The network that this route applies to.
returned: success returned: success
type: str type: dict
priority: priority:
description: description:
- The priority of this route. Priority is used to break ties in cases where there - The priority of this route. Priority is used to break ties in cases where there
@ -222,7 +225,7 @@ nextHopInstance:
instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
.' .'
returned: success returned: success
type: str type: dict
nextHopIp: nextHopIp:
description: description:
- Network IP address of an instance that should handle matching packets. - Network IP address of an instance that should handle matching packets.
@ -232,7 +235,7 @@ nextHopVpnTunnel:
description: description:
- URL to a VpnTunnel that should handle matching packets. - URL to a VpnTunnel that should handle matching packets.
returned: success returned: success
type: str type: dict
nextHopNetwork: nextHopNetwork:
description: description:
- URL to a Network that should handle matching packets. - URL to a Network that should handle matching packets.
@ -262,13 +265,13 @@ def main():
dest_range=dict(required=True, type='str'), dest_range=dict(required=True, type='str'),
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
network=dict(required=True), network=dict(required=True, type='dict'),
priority=dict(type='int'), priority=dict(type='int'),
tags=dict(type='list', elements='str'), tags=dict(type='list', elements='str'),
next_hop_gateway=dict(type='str'), next_hop_gateway=dict(type='str'),
next_hop_instance=dict(), next_hop_instance=dict(type='dict'),
next_hop_ip=dict(type='str'), next_hop_ip=dict(type='str'),
next_hop_vpn_tunnel=dict(), next_hop_vpn_tunnel=dict(type='dict'),
) )
) )
@ -284,11 +287,10 @@ 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 = fetch_resource(module, self_link(module), kind)
changed = True changed = True
else: else:
delete(module, self_link(module), kind) delete(module, self_link(module), kind, fetch)
fetch = {} fetch = {}
changed = True changed = True
else: else:
@ -308,11 +310,12 @@ 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): def update(module, link, kind, fetch):
module.fail_json(msg="Route cannot be edited") auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def delete(module, link, kind): def delete(module, link, kind, fetch):
auth = GcpSession(module, 'compute') auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.delete(link)) return wait_for_operation(module, auth.delete(link))