|
|
|
@ -97,13 +97,11 @@ extends_documentation_fragment: gcp
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
|
- name: create a network
|
|
|
|
|
gcp_compute_network:
|
|
|
|
|
name: testObject
|
|
|
|
|
name: "test_object"
|
|
|
|
|
auto_create_subnetworks: true
|
|
|
|
|
project: testProject
|
|
|
|
|
auth_kind: service_account
|
|
|
|
|
service_account_file: /tmp/auth.pem
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
project: "test_project"
|
|
|
|
|
auth_kind: "service_account"
|
|
|
|
|
service_account_file: "/tmp/auth.pem"
|
|
|
|
|
state: present
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
@ -190,6 +188,9 @@ def main():
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if not module.params['scopes']:
|
|
|
|
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
|
kind = 'compute#network'
|
|
|
|
|
|
|
|
|
@ -199,10 +200,10 @@ def main():
|
|
|
|
|
if fetch:
|
|
|
|
|
if state == 'present':
|
|
|
|
|
if is_different(module, fetch):
|
|
|
|
|
fetch = update(module, self_link(module), kind, fetch)
|
|
|
|
|
fetch = update(module, self_link(module), kind)
|
|
|
|
|
changed = True
|
|
|
|
|
else:
|
|
|
|
|
delete(module, self_link(module), kind, fetch)
|
|
|
|
|
delete(module, self_link(module), kind)
|
|
|
|
|
fetch = {}
|
|
|
|
|
changed = True
|
|
|
|
|
else:
|
|
|
|
@ -222,12 +223,12 @@ def create(module, link, kind):
|
|
|
|
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update(module, link, kind, fetch):
|
|
|
|
|
def update(module, link, kind):
|
|
|
|
|
auth = GcpSession(module, 'compute')
|
|
|
|
|
return wait_for_operation(module, auth.put(link, resource_to_request(module)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete(module, link, kind, fetch):
|
|
|
|
|
def delete(module, link, kind):
|
|
|
|
|
auth = GcpSession(module, 'compute')
|
|
|
|
|
return wait_for_operation(module, auth.delete(link))
|
|
|
|
|
|
|
|
|
@ -330,7 +331,7 @@ def async_op_url(module, extra_data=None):
|
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
|
op_result = return_if_object(module, response, 'compute#operation')
|
|
|
|
|
if op_result is None:
|
|
|
|
|
return None
|
|
|
|
|
return {}
|
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#network')
|
|
|
|
|