Object.input should == noneditable (#62)

<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
This commit is contained in:
The Magician 2018-08-15 13:39:22 -07:00 committed by Alex Stephen
commit 7c4d1c582b
12 changed files with 169 additions and 375 deletions

View file

@ -63,18 +63,19 @@ options:
description:
- URL of the Target VPN gateway with which this VPN tunnel is associated.
- 'This field represents a link to a TargetVpnGateway resource in GCP. It can
be specified in two ways. First, you can place in the selfLink of the resource
here as a string Alternatively, you can add `register: name-of-resource` to
a gcp_compute_target_vpn_gateway task and then set this target_vpn_gateway field
to "{{ name-of-resource }}"'
be specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_target_vpn_gateway task and then set this
target_vpn_gateway field to "{{ name-of-resource }}"'
required: true
router:
description:
- URL of router resource to be used for dynamic routing.
- 'This field represents a link to a Router resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_router
task and then set this router field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_router task and then set this router field to "{{ name-of-resource
}}"'
required: false
peer_ip:
description:
@ -105,10 +106,6 @@ options:
The ranges should be disjoint.
- Only IPv4 is supported.
required: false
labels:
description:
- Labels to apply to this VpnTunnel.
required: false
region:
description:
- The region where the tunnel is located.
@ -123,54 +120,54 @@ notes:
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-vpn-tunnel"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: network-vpn-tunnel
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: network
- name: create a router
gcp_compute_router:
name: "router-vpn-tunnel"
network: "{{ network }}"
bgp:
asn: 64514
advertise_mode: CUSTOM
advertised_groups:
- ALL_SUBNETS
advertised_ip_ranges:
- range: 1.2.3.4
- range: 6.7.0.0/16
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: router-vpn-tunnel
network: "{{ network }}"
bgp:
asn: 64514
advertise_mode: CUSTOM
advertised_groups:
- ALL_SUBNETS
advertised_ip_ranges:
- range: 1.2.3.4
- range: 6.7.0.0/16
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: router
- name: create a target vpn gateway
gcp_compute_target_vpn_gateway:
name: "gateway-vpn-tunnel"
region: us-west1
network: "{{ network }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: gateway-vpn-tunnel
region: us-west1
network: "{{ network }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: gateway
- name: create a vpn tunnel
gcp_compute_vpn_tunnel:
name: "test_object"
region: us-west1
target_vpn_gateway: "{{ gateway }}"
router: "{{ router }}"
shared_secret: super secret
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
name: test_object
region: us-west1
target_vpn_gateway: "{{ gateway }}"
router: "{{ router }}"
shared_secret: super secret
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''
@ -197,12 +194,12 @@ targetVpnGateway:
description:
- URL of the Target VPN gateway with which this VPN tunnel is associated.
returned: success
type: str
type: dict
router:
description:
- URL of router resource to be used for dynamic routing.
returned: success
type: str
type: dict
peerIp:
description:
- IP address of the peer VPN gateway. Only IPv4 is supported.
@ -241,17 +238,6 @@ remoteTrafficSelector:
- Only IPv4 is supported.
returned: success
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:
description:
- The region where the tunnel is located.
@ -280,14 +266,13 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'),
description=dict(type='str'),
target_vpn_gateway=dict(required=True),
router=dict(),
target_vpn_gateway=dict(required=True, type='dict'),
router=dict(type='dict'),
peer_ip=dict(required=True, type='str'),
shared_secret=dict(required=True, type='str'),
ike_version=dict(default=2, type='int'),
local_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'),
)
)
@ -304,7 +289,7 @@ def main():
if fetch:
if state == 'present':
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)
changed = True
else:
@ -314,7 +299,6 @@ def main():
else:
if state == 'present':
fetch = create(module, collection(module), kind)
labels_update(module, module.params, fetch)
changed = True
else:
fetch = {}
@ -329,22 +313,8 @@ def create(module, link, kind):
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
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 update(module, link, kind):
module.fail_json(msg="VpnTunnel cannot be edited")
def delete(module, link, kind):
@ -364,7 +334,6 @@ def resource_to_request(module):
u'ikeVersion': module.params.get('ike_version'),
u'localTrafficSelector': module.params.get('local_traffic_selector'),
u'remoteTrafficSelector': module.params.get('remote_traffic_selector'),
u'labels': module.params.get('labels'),
}
return_vals = {}
for k, v in request.items():
@ -441,8 +410,6 @@ def response_to_hash(module, response):
u'ikeVersion': response.get(u'ikeVersion'),
u'localTrafficSelector': response.get(u'localTrafficSelector'),
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
u'labels': response.get(u'labels'),
u'labelFingerprint': response.get(u'labelFingerprint'),
}