mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-09-30 05:23:29 -07:00
Bug fixes for GCP modules (as of 2019-01-22T12:43:52-08:00) (#51246)
This commit is contained in:
parent
c71053973b
commit
a81d110422
24 changed files with 419 additions and 622 deletions
|
@ -18,15 +18,14 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
################################################################################
|
||||
# Documentation
|
||||
################################################################################
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ["preview"],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
|
@ -189,7 +188,7 @@ def main():
|
|||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||
description=dict(type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
url_map=dict(required=True)
|
||||
url_map=dict(required=True),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -230,8 +229,7 @@ def create(module, link, kind):
|
|||
|
||||
|
||||
def update(module, link, kind, fetch):
|
||||
update_fields(module, resource_to_request(module),
|
||||
response_to_hash(module, fetch))
|
||||
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
||||
return fetch_resource(module, self_link(module), kind)
|
||||
|
||||
|
||||
|
@ -243,13 +241,8 @@ def update_fields(module, request, response):
|
|||
def url_map_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/targetHttpProxies/{name}/setUrlMap"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/targetHttpProxies/{name}/setUrlMap"]).format(**module.params),
|
||||
{u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -263,7 +256,7 @@ def resource_to_request(module):
|
|||
u'kind': 'compute#targetHttpProxy',
|
||||
u'description': module.params.get('description'),
|
||||
u'name': module.params.get('name'),
|
||||
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')
|
||||
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -298,8 +291,8 @@ def return_if_object(module, response, kind, allow_not_found=False):
|
|||
try:
|
||||
module.raise_for_status(response)
|
||||
result = response.json()
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % inst)
|
||||
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||
module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
|
||||
|
||||
if navigate_hash(result, ['error', 'errors']):
|
||||
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
|
||||
|
@ -333,7 +326,7 @@ def response_to_hash(module, response):
|
|||
u'description': response.get(u'description'),
|
||||
u'id': response.get(u'id'),
|
||||
u'name': response.get(u'name'),
|
||||
u'urlMap': response.get(u'urlMap')
|
||||
u'urlMap': response.get(u'urlMap'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,7 +352,7 @@ def wait_for_completion(status, op_result, module):
|
|||
op_id = navigate_hash(op_result, ['name'])
|
||||
op_uri = async_op_url(module, {'op_id': op_id})
|
||||
while status != 'DONE':
|
||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
||||
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||
time.sleep(1.0)
|
||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue