Bug fixes for GCP modules (as of 2019-01-22T12:43:52-08:00) (#51246)
This commit is contained in:
parent
2836c8c897
commit
395fbce194
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 = '''
|
||||
---
|
||||
|
@ -212,7 +211,7 @@ def main():
|
|||
name=dict(required=True, type='str'),
|
||||
profile=dict(type='str', choices=['COMPATIBLE', 'MODERN', 'RESTRICTED', 'CUSTOM']),
|
||||
min_tls_version=dict(type='str', choices=['TLS_1_0', 'TLS_1_1', 'TLS_1_2']),
|
||||
custom_features=dict(type='list', elements='str')
|
||||
custom_features=dict(type='list', elements='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -269,7 +268,7 @@ def resource_to_request(module):
|
|||
u'name': module.params.get('name'),
|
||||
u'profile': module.params.get('profile'),
|
||||
u'minTlsVersion': module.params.get('min_tls_version'),
|
||||
u'customFeatures': module.params.get('custom_features')
|
||||
u'customFeatures': module.params.get('custom_features'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -304,8 +303,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']))
|
||||
|
@ -344,7 +343,7 @@ def response_to_hash(module, response):
|
|||
u'enabledFeatures': response.get(u'enabledFeatures'),
|
||||
u'customFeatures': response.get(u'customFeatures'),
|
||||
u'fingerprint': response.get(u'fingerprint'),
|
||||
u'warnings': SslPolicyWarningsArray(response.get(u'warnings', []), module).from_response()
|
||||
u'warnings': SslPolicyWarningsArray(response.get(u'warnings', []), module).from_response(),
|
||||
}
|
||||
|
||||
|
||||
|
@ -370,7 +369,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'])
|
||||
|
@ -404,16 +403,10 @@ class SslPolicyWarningsArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'code': item.get('code'),
|
||||
u'message': item.get('message')
|
||||
})
|
||||
return remove_nones_from_dict({u'code': item.get('code'), u'message': item.get('message')})
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'code': item.get(u'code'),
|
||||
u'message': item.get(u'message')
|
||||
})
|
||||
return remove_nones_from_dict({u'code': item.get(u'code'), u'message': item.get(u'message')})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -154,11 +153,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -168,9 +163,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -279,12 +278,11 @@ def main():
|
|||
name=dict(required=True, type='str'),
|
||||
network=dict(required=True),
|
||||
enable_flow_logs=dict(type='bool'),
|
||||
secondary_ip_ranges=dict(type='list', elements='dict', options=dict(
|
||||
range_name=dict(required=True, type='str'),
|
||||
ip_cidr_range=dict(required=True, type='str')
|
||||
)),
|
||||
secondary_ip_ranges=dict(
|
||||
type='list', elements='dict', options=dict(range_name=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str'))
|
||||
),
|
||||
private_ip_google_access=dict(type='bool'),
|
||||
region=dict(required=True, type='str')
|
||||
region=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -325,8 +323,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)
|
||||
|
||||
|
||||
|
@ -342,41 +339,30 @@ def update_fields(module, request, response):
|
|||
def ip_cidr_range_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'ipCidrRange': module.params.get('ip_cidr_range')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"]).format(**module.params),
|
||||
{u'ipCidrRange': module.params.get('ip_cidr_range')},
|
||||
)
|
||||
|
||||
|
||||
def enable_flow_logs_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.patch(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/regions/{region}/subnetworks/{name}"
|
||||
]).format(**module.params),
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}"]).format(**module.params),
|
||||
{
|
||||
u'enableFlowLogs': module.params.get('enable_flow_logs'),
|
||||
u'fingerprint': response.get('fingerprint'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request()
|
||||
}
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def private_ip_google_access_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'privateIpGoogleAccess': module.params.get('private_ip_google_access')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"]).format(
|
||||
**module.params
|
||||
),
|
||||
{u'privateIpGoogleAccess': module.params.get('private_ip_google_access')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -395,7 +381,7 @@ def resource_to_request(module):
|
|||
u'enableFlowLogs': module.params.get('enable_flow_logs'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
|
||||
u'privateIpGoogleAccess': module.params.get('private_ip_google_access'),
|
||||
u'region': module.params.get('region')
|
||||
u'region': module.params.get('region'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -430,8 +416,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']))
|
||||
|
@ -472,7 +458,7 @@ def response_to_hash(module, response):
|
|||
u'fingerprint': response.get(u'fingerprint'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(response.get(u'secondaryIpRanges', []), module).from_response(),
|
||||
u'privateIpGoogleAccess': response.get(u'privateIpGoogleAccess'),
|
||||
u'region': module.params.get('region')
|
||||
u'region': module.params.get('region'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -498,7 +484,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'])
|
||||
|
@ -532,16 +518,10 @@ class SubnetworkSecondaryiprangesArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'rangeName': item.get('range_name'),
|
||||
u'ipCidrRange': item.get('ip_cidr_range')
|
||||
})
|
||||
return remove_nones_from_dict({u'rangeName': item.get('range_name'), u'ipCidrRange': item.get('ip_cidr_range')})
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'rangeName': item.get(u'rangeName'),
|
||||
u'ipCidrRange': item.get(u'ipCidrRange')
|
||||
})
|
||||
return remove_nones_from_dict({u'rangeName': item.get(u'rangeName'), u'ipCidrRange': item.get(u'ipCidrRange')})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -176,12 +175,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str'),
|
||||
region=dict(required=True, type='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -191,9 +185,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -110,11 +109,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -124,9 +119,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -280,7 +279,7 @@ def main():
|
|||
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
|
||||
ssl_certificates=dict(required=True, type='list'),
|
||||
ssl_policy=dict(),
|
||||
url_map=dict(required=True)
|
||||
url_map=dict(required=True),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -321,8 +320,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)
|
||||
|
||||
|
||||
|
@ -340,52 +338,32 @@ def update_fields(module, request, response):
|
|||
def quic_override_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetHttpsProxies/{name}/setQuicOverride"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'quicOverride': module.params.get('quic_override')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetHttpsProxies/{name}/setQuicOverride"]).format(**module.params),
|
||||
{u'quicOverride': module.params.get('quic_override')},
|
||||
)
|
||||
|
||||
|
||||
def ssl_certificates_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/targetHttpsProxies/{name}/setSslCertificates"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/targetHttpsProxies/{name}/setSslCertificates"]).format(**module.params),
|
||||
{u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
def ssl_policy_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetHttpsProxies/{name}/setSslPolicy"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetHttpsProxies/{name}/setSslPolicy"]).format(**module.params),
|
||||
{u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
def url_map_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/targetHttpsProxies/{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}/targetHttpsProxies/{name}/setUrlMap"]).format(**module.params),
|
||||
{u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -402,7 +380,7 @@ def resource_to_request(module):
|
|||
u'quicOverride': module.params.get('quic_override'),
|
||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
|
||||
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():
|
||||
|
@ -437,8 +415,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']))
|
||||
|
@ -475,7 +453,7 @@ def response_to_hash(module, response):
|
|||
u'quicOverride': response.get(u'quicOverride'),
|
||||
u'sslCertificates': response.get(u'sslCertificates'),
|
||||
u'sslPolicy': response.get(u'sslPolicy'),
|
||||
u'urlMap': response.get(u'urlMap')
|
||||
u'urlMap': response.get(u'urlMap'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -501,7 +479,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -133,11 +132,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -147,9 +142,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -257,7 +256,7 @@ def main():
|
|||
instances=dict(type='list'),
|
||||
name=dict(required=True, type='str'),
|
||||
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO']),
|
||||
region=dict(required=True, type='str')
|
||||
region=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -316,7 +315,7 @@ def resource_to_request(module):
|
|||
u'healthCheck': replace_resource_dict(module.params.get(u'health_check', {}), 'selfLink'),
|
||||
u'instances': replace_resource_dict(module.params.get('instances', []), 'selfLink'),
|
||||
u'name': module.params.get('name'),
|
||||
u'sessionAffinity': module.params.get('session_affinity')
|
||||
u'sessionAffinity': module.params.get('session_affinity'),
|
||||
}
|
||||
request = encode_request(request, module)
|
||||
return_vals = {}
|
||||
|
@ -352,8 +351,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)
|
||||
|
||||
result = decode_request(result, module)
|
||||
|
||||
|
@ -394,7 +393,7 @@ def response_to_hash(module, response):
|
|||
u'id': response.get(u'id'),
|
||||
u'instances': response.get(u'instances'),
|
||||
u'name': module.params.get('name'),
|
||||
u'sessionAffinity': module.params.get('session_affinity')
|
||||
u'sessionAffinity': module.params.get('session_affinity'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -420,7 +419,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -168,12 +167,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str'),
|
||||
region=dict(required=True, type='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -183,9 +177,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -266,7 +265,7 @@ def main():
|
|||
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
|
||||
service=dict(required=True),
|
||||
ssl_certificates=dict(required=True, type='list'),
|
||||
ssl_policy=dict()
|
||||
ssl_policy=dict(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -307,8 +306,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)
|
||||
|
||||
|
||||
|
@ -326,52 +324,32 @@ def update_fields(module, request, response):
|
|||
def proxy_header_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetSslProxies/{name}/setProxyHeader"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'proxyHeader': module.params.get('proxy_header')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setProxyHeader"]).format(**module.params),
|
||||
{u'proxyHeader': module.params.get('proxy_header')},
|
||||
)
|
||||
|
||||
|
||||
def service_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetSslProxies/{name}/setBackendService"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setBackendService"]).format(**module.params),
|
||||
{u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
def ssl_certificates_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetSslProxies/{name}/setSslCertificates"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setSslCertificates"]).format(**module.params),
|
||||
{u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
def ssl_policy_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetSslProxies/{name}/setSslPolicy"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setSslPolicy"]).format(**module.params),
|
||||
{u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -388,7 +366,7 @@ def resource_to_request(module):
|
|||
u'proxyHeader': module.params.get('proxy_header'),
|
||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
|
||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -423,8 +401,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']))
|
||||
|
@ -461,7 +439,7 @@ def response_to_hash(module, response):
|
|||
u'proxyHeader': response.get(u'proxyHeader'),
|
||||
u'service': response.get(u'service'),
|
||||
u'sslCertificates': response.get(u'sslCertificates'),
|
||||
u'sslPolicy': response.get(u'sslPolicy')
|
||||
u'sslPolicy': response.get(u'sslPolicy'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -487,7 +465,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -129,11 +128,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -143,9 +138,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -199,7 +198,7 @@ def main():
|
|||
description=dict(type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
|
||||
service=dict(required=True)
|
||||
service=dict(required=True),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -240,8 +239,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)
|
||||
|
||||
|
||||
|
@ -255,26 +253,16 @@ def update_fields(module, request, response):
|
|||
def proxy_header_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'proxyHeader': module.params.get('proxy_header')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"]).format(**module.params),
|
||||
{u'proxyHeader': module.params.get('proxy_header')},
|
||||
)
|
||||
|
||||
|
||||
def service_update(module, request, response):
|
||||
auth = GcpSession(module, 'compute')
|
||||
auth.post(
|
||||
''.join([
|
||||
"https://www.googleapis.com/compute/v1/",
|
||||
"projects/{project}/global/targetTcpProxies/{name}/setBackendService"
|
||||
]).format(**module.params),
|
||||
{
|
||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')
|
||||
}
|
||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setBackendService"]).format(**module.params),
|
||||
{u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -289,7 +277,7 @@ def resource_to_request(module):
|
|||
u'description': module.params.get('description'),
|
||||
u'name': module.params.get('name'),
|
||||
u'proxyHeader': module.params.get('proxy_header'),
|
||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')
|
||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -324,8 +312,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']))
|
||||
|
@ -360,7 +348,7 @@ def response_to_hash(module, response):
|
|||
u'id': response.get(u'id'),
|
||||
u'name': module.params.get('name'),
|
||||
u'proxyHeader': response.get(u'proxyHeader'),
|
||||
u'service': response.get(u'service')
|
||||
u'service': response.get(u'service'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -386,7 +374,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -115,11 +114,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -129,9 +124,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -181,7 +180,7 @@ def main():
|
|||
description=dict(type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
network=dict(required=True),
|
||||
region=dict(required=True, type='str')
|
||||
region=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -235,7 +234,7 @@ def resource_to_request(module):
|
|||
u'kind': 'compute#targetVpnGateway',
|
||||
u'description': module.params.get('description'),
|
||||
u'name': module.params.get('name'),
|
||||
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink')
|
||||
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -270,8 +269,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']))
|
||||
|
@ -307,7 +306,7 @@ def response_to_hash(module, response):
|
|||
u'id': response.get(u'id'),
|
||||
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
||||
u'tunnels': response.get(u'tunnels'),
|
||||
u'forwardingRules': response.get(u'forwardingRules')
|
||||
u'forwardingRules': response.get(u'forwardingRules'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,7 +332,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -130,12 +129,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str'),
|
||||
region=dict(required=True, type='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -145,9 +139,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -371,27 +370,33 @@ def main():
|
|||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||
default_service=dict(required=True),
|
||||
description=dict(type='str'),
|
||||
host_rules=dict(type='list', elements='dict', options=dict(
|
||||
description=dict(type='str'),
|
||||
hosts=dict(required=True, type='list', elements='str'),
|
||||
path_matcher=dict(required=True, type='str')
|
||||
)),
|
||||
host_rules=dict(
|
||||
type='list',
|
||||
elements='dict',
|
||||
options=dict(
|
||||
description=dict(type='str'), hosts=dict(required=True, type='list', elements='str'), path_matcher=dict(required=True, type='str')
|
||||
),
|
||||
),
|
||||
name=dict(required=True, type='str'),
|
||||
path_matchers=dict(type='list', elements='dict', options=dict(
|
||||
default_service=dict(required=True),
|
||||
description=dict(type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
path_rules=dict(type='list', elements='dict', options=dict(
|
||||
paths=dict(required=True, type='list', elements='str'),
|
||||
service=dict(required=True)
|
||||
))
|
||||
)),
|
||||
tests=dict(type='list', elements='dict', options=dict(
|
||||
description=dict(type='str'),
|
||||
host=dict(required=True, type='str'),
|
||||
path=dict(required=True, type='str'),
|
||||
service=dict(required=True)
|
||||
))
|
||||
path_matchers=dict(
|
||||
type='list',
|
||||
elements='dict',
|
||||
options=dict(
|
||||
default_service=dict(required=True),
|
||||
description=dict(type='str'),
|
||||
name=dict(required=True, type='str'),
|
||||
path_rules=dict(
|
||||
type='list', elements='dict', options=dict(paths=dict(required=True, type='list', elements='str'), service=dict(required=True))
|
||||
),
|
||||
),
|
||||
),
|
||||
tests=dict(
|
||||
type='list',
|
||||
elements='dict',
|
||||
options=dict(
|
||||
description=dict(type='str'), host=dict(required=True, type='str'), path=dict(required=True, type='str'), service=dict(required=True)
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -449,7 +454,7 @@ def resource_to_request(module):
|
|||
u'hostRules': UrlMapHostrulesArray(module.params.get('host_rules', []), module).to_request(),
|
||||
u'name': module.params.get('name'),
|
||||
u'pathMatchers': UrlMapPathmatchersArray(module.params.get('path_matchers', []), module).to_request(),
|
||||
u'tests': UrlMapTestsArray(module.params.get('tests', []), module).to_request()
|
||||
u'tests': UrlMapTestsArray(module.params.get('tests', []), module).to_request(),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -484,8 +489,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']))
|
||||
|
@ -523,7 +528,7 @@ def response_to_hash(module, response):
|
|||
u'fingerprint': response.get(u'fingerprint'),
|
||||
u'name': module.params.get('name'),
|
||||
u'pathMatchers': UrlMapPathmatchersArray(response.get(u'pathMatchers', []), module).from_response(),
|
||||
u'tests': UrlMapTestsArray(response.get(u'tests', []), module).from_response()
|
||||
u'tests': UrlMapTestsArray(response.get(u'tests', []), module).from_response(),
|
||||
}
|
||||
|
||||
|
||||
|
@ -549,7 +554,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'])
|
||||
|
@ -583,18 +588,10 @@ class UrlMapHostrulesArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'description': item.get('description'),
|
||||
u'hosts': item.get('hosts'),
|
||||
u'pathMatcher': item.get('path_matcher')
|
||||
})
|
||||
return remove_nones_from_dict({u'description': item.get('description'), u'hosts': item.get('hosts'), u'pathMatcher': item.get('path_matcher')})
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'description': item.get(u'description'),
|
||||
u'hosts': item.get(u'hosts'),
|
||||
u'pathMatcher': item.get(u'pathMatcher')
|
||||
})
|
||||
return remove_nones_from_dict({u'description': item.get(u'description'), u'hosts': item.get(u'hosts'), u'pathMatcher': item.get(u'pathMatcher')})
|
||||
|
||||
|
||||
class UrlMapPathmatchersArray(object):
|
||||
|
@ -618,20 +615,24 @@ class UrlMapPathmatchersArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'defaultService': replace_resource_dict(item.get(u'default_service', {}), 'selfLink'),
|
||||
u'description': item.get('description'),
|
||||
u'name': item.get('name'),
|
||||
u'pathRules': UrlMapPathrulesArray(item.get('path_rules', []), self.module).to_request()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'defaultService': replace_resource_dict(item.get(u'default_service', {}), 'selfLink'),
|
||||
u'description': item.get('description'),
|
||||
u'name': item.get('name'),
|
||||
u'pathRules': UrlMapPathrulesArray(item.get('path_rules', []), self.module).to_request(),
|
||||
}
|
||||
)
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'defaultService': item.get(u'defaultService'),
|
||||
u'description': item.get(u'description'),
|
||||
u'name': item.get(u'name'),
|
||||
u'pathRules': UrlMapPathrulesArray(item.get(u'pathRules', []), self.module).from_response()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'defaultService': item.get(u'defaultService'),
|
||||
u'description': item.get(u'description'),
|
||||
u'name': item.get(u'name'),
|
||||
u'pathRules': UrlMapPathrulesArray(item.get(u'pathRules', []), self.module).from_response(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class UrlMapPathrulesArray(object):
|
||||
|
@ -655,16 +656,10 @@ class UrlMapPathrulesArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'paths': item.get('paths'),
|
||||
u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink')
|
||||
})
|
||||
return remove_nones_from_dict({u'paths': item.get('paths'), u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink')})
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'paths': item.get(u'paths'),
|
||||
u'service': item.get(u'service')
|
||||
})
|
||||
return remove_nones_from_dict({u'paths': item.get(u'paths'), u'service': item.get(u'service')})
|
||||
|
||||
|
||||
class UrlMapTestsArray(object):
|
||||
|
@ -688,20 +683,19 @@ class UrlMapTestsArray(object):
|
|||
return items
|
||||
|
||||
def _request_for_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'description': item.get('description'),
|
||||
u'host': item.get('host'),
|
||||
u'path': item.get('path'),
|
||||
u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'description': item.get('description'),
|
||||
u'host': item.get('host'),
|
||||
u'path': item.get('path'),
|
||||
u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink'),
|
||||
}
|
||||
)
|
||||
|
||||
def _response_from_item(self, item):
|
||||
return remove_nones_from_dict({
|
||||
u'description': item.get(u'description'),
|
||||
u'host': item.get(u'host'),
|
||||
u'path': item.get(u'path'),
|
||||
u'service': item.get(u'service')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{u'description': item.get(u'description'), u'host': item.get(u'host'), u'path': item.get(u'path'), u'service': item.get(u'service')}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -211,11 +210,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -225,9 +220,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -289,7 +288,7 @@ def main():
|
|||
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')
|
||||
region=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -331,8 +330,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)
|
||||
|
||||
|
||||
|
@ -344,14 +342,8 @@ def update_fields(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')
|
||||
}
|
||||
''.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')},
|
||||
)
|
||||
|
||||
|
||||
|
@ -372,7 +364,7 @@ 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')
|
||||
u'labels': module.params.get('labels'),
|
||||
}
|
||||
return_vals = {}
|
||||
for k, v in request.items():
|
||||
|
@ -407,8 +399,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']))
|
||||
|
@ -450,7 +442,7 @@ def response_to_hash(module, response):
|
|||
u'localTrafficSelector': response.get(u'localTrafficSelector'),
|
||||
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
|
||||
u'labels': response.get(u'labels'),
|
||||
u'labelFingerprint': response.get(u'labelFingerprint')
|
||||
u'labelFingerprint': response.get(u'labelFingerprint'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -476,7 +468,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'])
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -168,12 +167,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
filters=dict(type='list', elements='str'),
|
||||
region=dict(required=True, type='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
||||
|
@ -183,9 +177,7 @@ def main():
|
|||
items = items.get('items')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -597,40 +596,45 @@ def main():
|
|||
name=dict(type='str'),
|
||||
description=dict(type='str'),
|
||||
initial_node_count=dict(required=True, type='int'),
|
||||
node_config=dict(type='dict', options=dict(
|
||||
machine_type=dict(type='str'),
|
||||
disk_size_gb=dict(type='int'),
|
||||
oauth_scopes=dict(type='list', elements='str'),
|
||||
service_account=dict(type='str'),
|
||||
metadata=dict(type='dict'),
|
||||
image_type=dict(type='str'),
|
||||
labels=dict(type='dict'),
|
||||
local_ssd_count=dict(type='int'),
|
||||
tags=dict(type='list', elements='str'),
|
||||
preemptible=dict(type='bool')
|
||||
)),
|
||||
master_auth=dict(type='dict', options=dict(
|
||||
username=dict(type='str'),
|
||||
password=dict(type='str'),
|
||||
cluster_ca_certificate=dict(type='str'),
|
||||
client_certificate=dict(type='str'),
|
||||
client_key=dict(type='str')
|
||||
)),
|
||||
node_config=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
machine_type=dict(type='str'),
|
||||
disk_size_gb=dict(type='int'),
|
||||
oauth_scopes=dict(type='list', elements='str'),
|
||||
service_account=dict(type='str'),
|
||||
metadata=dict(type='dict'),
|
||||
image_type=dict(type='str'),
|
||||
labels=dict(type='dict'),
|
||||
local_ssd_count=dict(type='int'),
|
||||
tags=dict(type='list', elements='str'),
|
||||
preemptible=dict(type='bool'),
|
||||
),
|
||||
),
|
||||
master_auth=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
username=dict(type='str'),
|
||||
password=dict(type='str'),
|
||||
cluster_ca_certificate=dict(type='str'),
|
||||
client_certificate=dict(type='str'),
|
||||
client_key=dict(type='str'),
|
||||
),
|
||||
),
|
||||
logging_service=dict(type='str', choices=['logging.googleapis.com', 'none']),
|
||||
monitoring_service=dict(type='str', choices=['monitoring.googleapis.com', 'none']),
|
||||
network=dict(type='str'),
|
||||
cluster_ipv4_cidr=dict(type='str'),
|
||||
addons_config=dict(type='dict', options=dict(
|
||||
http_load_balancing=dict(type='dict', options=dict(
|
||||
disabled=dict(type='bool')
|
||||
)),
|
||||
horizontal_pod_autoscaling=dict(type='dict', options=dict(
|
||||
disabled=dict(type='bool')
|
||||
))
|
||||
)),
|
||||
addons_config=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
http_load_balancing=dict(type='dict', options=dict(disabled=dict(type='bool'))),
|
||||
horizontal_pod_autoscaling=dict(type='dict', options=dict(disabled=dict(type='bool'))),
|
||||
),
|
||||
),
|
||||
subnetwork=dict(type='str'),
|
||||
location=dict(type='list', elements='str'),
|
||||
zone=dict(required=True, type='str')
|
||||
zone=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -692,7 +696,7 @@ def resource_to_request(module):
|
|||
u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'),
|
||||
u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
|
||||
u'subnetwork': module.params.get('subnetwork'),
|
||||
u'location': module.params.get('location')
|
||||
u'location': module.params.get('location'),
|
||||
}
|
||||
request = encode_request(request, module)
|
||||
return_vals = {}
|
||||
|
@ -728,8 +732,8 @@ def return_if_object(module, response, 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']))
|
||||
|
@ -779,7 +783,7 @@ def response_to_hash(module, response):
|
|||
u'nodeIpv4CidrSize': response.get(u'nodeIpv4CidrSize'),
|
||||
u'servicesIpv4Cidr': response.get(u'servicesIpv4Cidr'),
|
||||
u'currentNodeCount': response.get(u'currentNodeCount'),
|
||||
u'expireTime': response.get(u'expireTime')
|
||||
u'expireTime': response.get(u'expireTime'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -805,7 +809,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)
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
|
@ -829,9 +833,7 @@ def raise_if_errors(response, err_path, module):
|
|||
#
|
||||
# Format the request to match the expected input by the API
|
||||
def encode_request(resource_request, module):
|
||||
return {
|
||||
'cluster': resource_request
|
||||
}
|
||||
return {'cluster': resource_request}
|
||||
|
||||
|
||||
class ClusterNodeconfig(object):
|
||||
|
@ -843,32 +845,36 @@ class ClusterNodeconfig(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'machineType': self.request.get('machine_type'),
|
||||
u'diskSizeGb': self.request.get('disk_size_gb'),
|
||||
u'oauthScopes': self.request.get('oauth_scopes'),
|
||||
u'serviceAccount': self.request.get('service_account'),
|
||||
u'metadata': self.request.get('metadata'),
|
||||
u'imageType': self.request.get('image_type'),
|
||||
u'labels': self.request.get('labels'),
|
||||
u'localSsdCount': self.request.get('local_ssd_count'),
|
||||
u'tags': self.request.get('tags'),
|
||||
u'preemptible': self.request.get('preemptible')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'machineType': self.request.get('machine_type'),
|
||||
u'diskSizeGb': self.request.get('disk_size_gb'),
|
||||
u'oauthScopes': self.request.get('oauth_scopes'),
|
||||
u'serviceAccount': self.request.get('service_account'),
|
||||
u'metadata': self.request.get('metadata'),
|
||||
u'imageType': self.request.get('image_type'),
|
||||
u'labels': self.request.get('labels'),
|
||||
u'localSsdCount': self.request.get('local_ssd_count'),
|
||||
u'tags': self.request.get('tags'),
|
||||
u'preemptible': self.request.get('preemptible'),
|
||||
}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'machineType': self.request.get(u'machineType'),
|
||||
u'diskSizeGb': self.request.get(u'diskSizeGb'),
|
||||
u'oauthScopes': self.request.get(u'oauthScopes'),
|
||||
u'serviceAccount': self.request.get(u'serviceAccount'),
|
||||
u'metadata': self.request.get(u'metadata'),
|
||||
u'imageType': self.request.get(u'imageType'),
|
||||
u'labels': self.request.get(u'labels'),
|
||||
u'localSsdCount': self.request.get(u'localSsdCount'),
|
||||
u'tags': self.request.get(u'tags'),
|
||||
u'preemptible': self.request.get(u'preemptible')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'machineType': self.request.get(u'machineType'),
|
||||
u'diskSizeGb': self.request.get(u'diskSizeGb'),
|
||||
u'oauthScopes': self.request.get(u'oauthScopes'),
|
||||
u'serviceAccount': self.request.get(u'serviceAccount'),
|
||||
u'metadata': self.request.get(u'metadata'),
|
||||
u'imageType': self.request.get(u'imageType'),
|
||||
u'labels': self.request.get(u'labels'),
|
||||
u'localSsdCount': self.request.get(u'localSsdCount'),
|
||||
u'tags': self.request.get(u'tags'),
|
||||
u'preemptible': self.request.get(u'preemptible'),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class ClusterMasterauth(object):
|
||||
|
@ -880,22 +886,26 @@ class ClusterMasterauth(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'username': self.request.get('username'),
|
||||
u'password': self.request.get('password'),
|
||||
u'clusterCaCertificate': self.request.get('cluster_ca_certificate'),
|
||||
u'clientCertificate': self.request.get('client_certificate'),
|
||||
u'clientKey': self.request.get('client_key')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'username': self.request.get('username'),
|
||||
u'password': self.request.get('password'),
|
||||
u'clusterCaCertificate': self.request.get('cluster_ca_certificate'),
|
||||
u'clientCertificate': self.request.get('client_certificate'),
|
||||
u'clientKey': self.request.get('client_key'),
|
||||
}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'username': self.request.get(u'username'),
|
||||
u'password': self.request.get(u'password'),
|
||||
u'clusterCaCertificate': self.request.get(u'clusterCaCertificate'),
|
||||
u'clientCertificate': self.request.get(u'clientCertificate'),
|
||||
u'clientKey': self.request.get(u'clientKey')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'username': self.request.get(u'username'),
|
||||
u'password': self.request.get(u'password'),
|
||||
u'clusterCaCertificate': self.request.get(u'clusterCaCertificate'),
|
||||
u'clientCertificate': self.request.get(u'clientCertificate'),
|
||||
u'clientKey': self.request.get(u'clientKey'),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class ClusterAddonsconfig(object):
|
||||
|
@ -907,16 +917,20 @@ class ClusterAddonsconfig(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get('http_load_balancing', {}), self.module).to_request(),
|
||||
u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get('horizontal_pod_autoscaling', {}), self.module).to_request()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get('http_load_balancing', {}), self.module).to_request(),
|
||||
u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get('horizontal_pod_autoscaling', {}), self.module).to_request(),
|
||||
}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get(u'httpLoadBalancing', {}), self.module).from_response(),
|
||||
u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get(u'horizontalPodAutoscaling', {}), self.module).from_response()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get(u'httpLoadBalancing', {}), self.module).from_response(),
|
||||
u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get(u'horizontalPodAutoscaling', {}), self.module).from_response(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class ClusterHttploadbalancing(object):
|
||||
|
@ -928,14 +942,10 @@ class ClusterHttploadbalancing(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'disabled': self.request.get('disabled')
|
||||
})
|
||||
return remove_nones_from_dict({u'disabled': self.request.get('disabled')})
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'disabled': self.request.get(u'disabled')
|
||||
})
|
||||
return remove_nones_from_dict({u'disabled': self.request.get(u'disabled')})
|
||||
|
||||
|
||||
class ClusterHorizontalpodautoscaling(object):
|
||||
|
@ -947,14 +957,10 @@ class ClusterHorizontalpodautoscaling(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'disabled': self.request.get('disabled')
|
||||
})
|
||||
return remove_nones_from_dict({u'disabled': self.request.get('disabled')})
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'disabled': self.request.get(u'disabled')
|
||||
})
|
||||
return remove_nones_from_dict({u'disabled': self.request.get(u'disabled')})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -367,11 +366,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
zone=dict(required=True, type='str')
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str')))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
|
||||
|
@ -381,9 +376,7 @@ def main():
|
|||
items = items.get('clusters')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -443,34 +442,33 @@ def main():
|
|||
argument_spec=dict(
|
||||
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
||||
name=dict(type='str'),
|
||||
config=dict(type='dict', options=dict(
|
||||
machine_type=dict(type='str'),
|
||||
disk_size_gb=dict(type='int'),
|
||||
oauth_scopes=dict(type='list', elements='str'),
|
||||
service_account=dict(type='str'),
|
||||
metadata=dict(type='dict'),
|
||||
image_type=dict(type='str'),
|
||||
labels=dict(type='dict'),
|
||||
local_ssd_count=dict(type='int'),
|
||||
tags=dict(type='list', elements='str'),
|
||||
preemptible=dict(type='bool')
|
||||
)),
|
||||
config=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
machine_type=dict(type='str'),
|
||||
disk_size_gb=dict(type='int'),
|
||||
oauth_scopes=dict(type='list', elements='str'),
|
||||
service_account=dict(type='str'),
|
||||
metadata=dict(type='dict'),
|
||||
image_type=dict(type='str'),
|
||||
labels=dict(type='dict'),
|
||||
local_ssd_count=dict(type='int'),
|
||||
tags=dict(type='list', elements='str'),
|
||||
preemptible=dict(type='bool'),
|
||||
),
|
||||
),
|
||||
initial_node_count=dict(required=True, type='int'),
|
||||
autoscaling=dict(type='dict', options=dict(
|
||||
enabled=dict(type='bool'),
|
||||
min_node_count=dict(type='int'),
|
||||
max_node_count=dict(type='int')
|
||||
)),
|
||||
management=dict(type='dict', options=dict(
|
||||
auto_upgrade=dict(type='bool'),
|
||||
auto_repair=dict(type='bool'),
|
||||
upgrade_options=dict(type='dict', options=dict(
|
||||
auto_upgrade_start_time=dict(type='str'),
|
||||
description=dict(type='str')
|
||||
))
|
||||
)),
|
||||
autoscaling=dict(type='dict', options=dict(enabled=dict(type='bool'), min_node_count=dict(type='int'), max_node_count=dict(type='int'))),
|
||||
management=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
auto_upgrade=dict(type='bool'),
|
||||
auto_repair=dict(type='bool'),
|
||||
upgrade_options=dict(type='dict', options=dict(auto_upgrade_start_time=dict(type='str'), description=dict(type='str'))),
|
||||
),
|
||||
),
|
||||
cluster=dict(required=True),
|
||||
zone=dict(required=True, type='str')
|
||||
zone=dict(required=True, type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -525,7 +523,7 @@ def resource_to_request(module):
|
|||
u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
|
||||
u'initialNodeCount': module.params.get('initial_node_count'),
|
||||
u'autoscaling': NodePoolAutoscaling(module.params.get('autoscaling', {}), module).to_request(),
|
||||
u'management': NodePoolManagement(module.params.get('management', {}), module).to_request()
|
||||
u'management': NodePoolManagement(module.params.get('management', {}), module).to_request(),
|
||||
}
|
||||
request = encode_request(request, module)
|
||||
return_vals = {}
|
||||
|
@ -546,17 +544,13 @@ def self_link(module):
|
|||
'project': module.params['project'],
|
||||
'zone': module.params['zone'],
|
||||
'cluster': replace_resource_dict(module.params['cluster'], 'name'),
|
||||
'name': module.params['name']
|
||||
'name': module.params['name'],
|
||||
}
|
||||
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools/{name}".format(**res)
|
||||
|
||||
|
||||
def collection(module):
|
||||
res = {
|
||||
'project': module.params['project'],
|
||||
'zone': module.params['zone'],
|
||||
'cluster': replace_resource_dict(module.params['cluster'], 'name')
|
||||
}
|
||||
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
|
||||
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
|
||||
|
||||
|
||||
|
@ -572,8 +566,8 @@ def return_if_object(module, response, 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']))
|
||||
|
@ -608,7 +602,7 @@ def response_to_hash(module, response):
|
|||
u'initialNodeCount': module.params.get('initial_node_count'),
|
||||
u'version': response.get(u'version'),
|
||||
u'autoscaling': NodePoolAutoscaling(response.get(u'autoscaling', {}), module).from_response(),
|
||||
u'management': NodePoolManagement(response.get(u'management', {}), module).from_response()
|
||||
u'management': NodePoolManagement(response.get(u'management', {}), module).from_response(),
|
||||
}
|
||||
|
||||
|
||||
|
@ -634,7 +628,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)
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
|
@ -658,9 +652,7 @@ def raise_if_errors(response, err_path, module):
|
|||
#
|
||||
# Format the request to match the expected input by the API
|
||||
def encode_request(resource_request, module):
|
||||
return {
|
||||
'nodePool': resource_request
|
||||
}
|
||||
return {'nodePool': resource_request}
|
||||
|
||||
|
||||
class NodePoolConfig(object):
|
||||
|
@ -672,32 +664,36 @@ class NodePoolConfig(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'machineType': self.request.get('machine_type'),
|
||||
u'diskSizeGb': self.request.get('disk_size_gb'),
|
||||
u'oauthScopes': self.request.get('oauth_scopes'),
|
||||
u'serviceAccount': self.request.get('service_account'),
|
||||
u'metadata': self.request.get('metadata'),
|
||||
u'imageType': self.request.get('image_type'),
|
||||
u'labels': self.request.get('labels'),
|
||||
u'localSsdCount': self.request.get('local_ssd_count'),
|
||||
u'tags': self.request.get('tags'),
|
||||
u'preemptible': self.request.get('preemptible')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'machineType': self.request.get('machine_type'),
|
||||
u'diskSizeGb': self.request.get('disk_size_gb'),
|
||||
u'oauthScopes': self.request.get('oauth_scopes'),
|
||||
u'serviceAccount': self.request.get('service_account'),
|
||||
u'metadata': self.request.get('metadata'),
|
||||
u'imageType': self.request.get('image_type'),
|
||||
u'labels': self.request.get('labels'),
|
||||
u'localSsdCount': self.request.get('local_ssd_count'),
|
||||
u'tags': self.request.get('tags'),
|
||||
u'preemptible': self.request.get('preemptible'),
|
||||
}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'machineType': self.request.get(u'machineType'),
|
||||
u'diskSizeGb': self.request.get(u'diskSizeGb'),
|
||||
u'oauthScopes': self.request.get(u'oauthScopes'),
|
||||
u'serviceAccount': self.request.get(u'serviceAccount'),
|
||||
u'metadata': self.request.get(u'metadata'),
|
||||
u'imageType': self.request.get(u'imageType'),
|
||||
u'labels': self.request.get(u'labels'),
|
||||
u'localSsdCount': self.request.get(u'localSsdCount'),
|
||||
u'tags': self.request.get(u'tags'),
|
||||
u'preemptible': self.request.get(u'preemptible')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'machineType': self.request.get(u'machineType'),
|
||||
u'diskSizeGb': self.request.get(u'diskSizeGb'),
|
||||
u'oauthScopes': self.request.get(u'oauthScopes'),
|
||||
u'serviceAccount': self.request.get(u'serviceAccount'),
|
||||
u'metadata': self.request.get(u'metadata'),
|
||||
u'imageType': self.request.get(u'imageType'),
|
||||
u'labels': self.request.get(u'labels'),
|
||||
u'localSsdCount': self.request.get(u'localSsdCount'),
|
||||
u'tags': self.request.get(u'tags'),
|
||||
u'preemptible': self.request.get(u'preemptible'),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class NodePoolAutoscaling(object):
|
||||
|
@ -709,18 +705,14 @@ class NodePoolAutoscaling(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'enabled': self.request.get('enabled'),
|
||||
u'minNodeCount': self.request.get('min_node_count'),
|
||||
u'maxNodeCount': self.request.get('max_node_count')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{u'enabled': self.request.get('enabled'), u'minNodeCount': self.request.get('min_node_count'), u'maxNodeCount': self.request.get('max_node_count')}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'enabled': self.request.get(u'enabled'),
|
||||
u'minNodeCount': self.request.get(u'minNodeCount'),
|
||||
u'maxNodeCount': self.request.get(u'maxNodeCount')
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{u'enabled': self.request.get(u'enabled'), u'minNodeCount': self.request.get(u'minNodeCount'), u'maxNodeCount': self.request.get(u'maxNodeCount')}
|
||||
)
|
||||
|
||||
|
||||
class NodePoolManagement(object):
|
||||
|
@ -732,18 +724,22 @@ class NodePoolManagement(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'autoUpgrade': self.request.get('auto_upgrade'),
|
||||
u'autoRepair': self.request.get('auto_repair'),
|
||||
u'upgradeOptions': NodePoolUpgradeoptions(self.request.get('upgrade_options', {}), self.module).to_request()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'autoUpgrade': self.request.get('auto_upgrade'),
|
||||
u'autoRepair': self.request.get('auto_repair'),
|
||||
u'upgradeOptions': NodePoolUpgradeoptions(self.request.get('upgrade_options', {}), self.module).to_request(),
|
||||
}
|
||||
)
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'autoUpgrade': self.request.get(u'autoUpgrade'),
|
||||
u'autoRepair': self.request.get(u'autoRepair'),
|
||||
u'upgradeOptions': NodePoolUpgradeoptions(self.request.get(u'upgradeOptions', {}), self.module).from_response()
|
||||
})
|
||||
return remove_nones_from_dict(
|
||||
{
|
||||
u'autoUpgrade': self.request.get(u'autoUpgrade'),
|
||||
u'autoRepair': self.request.get(u'autoRepair'),
|
||||
u'upgradeOptions': NodePoolUpgradeoptions(self.request.get(u'upgradeOptions', {}), self.module).from_response(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class NodePoolUpgradeoptions(object):
|
||||
|
@ -755,16 +751,10 @@ class NodePoolUpgradeoptions(object):
|
|||
self.request = {}
|
||||
|
||||
def to_request(self):
|
||||
return remove_nones_from_dict({
|
||||
u'autoUpgradeStartTime': self.request.get('auto_upgrade_start_time'),
|
||||
u'description': self.request.get('description')
|
||||
})
|
||||
return remove_nones_from_dict({u'autoUpgradeStartTime': self.request.get('auto_upgrade_start_time'), u'description': self.request.get('description')})
|
||||
|
||||
def from_response(self):
|
||||
return remove_nones_from_dict({
|
||||
u'autoUpgradeStartTime': self.request.get(u'autoUpgradeStartTime'),
|
||||
u'description': self.request.get(u'description')
|
||||
})
|
||||
return remove_nones_from_dict({u'autoUpgradeStartTime': self.request.get(u'autoUpgradeStartTime'), u'description': self.request.get(u'description')})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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 = '''
|
||||
---
|
||||
|
@ -268,12 +267,7 @@ import json
|
|||
|
||||
|
||||
def main():
|
||||
module = GcpModule(
|
||||
argument_spec=dict(
|
||||
zone=dict(required=True, type='str'),
|
||||
cluster=dict(required=True)
|
||||
)
|
||||
)
|
||||
module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str'), cluster=dict(required=True)))
|
||||
|
||||
if not module.params['scopes']:
|
||||
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
|
||||
|
@ -283,18 +277,12 @@ def main():
|
|||
items = items.get('nodePools')
|
||||
else:
|
||||
items = []
|
||||
return_value = {
|
||||
'items': items
|
||||
}
|
||||
return_value = {'items': items}
|
||||
module.exit_json(**return_value)
|
||||
|
||||
|
||||
def collection(module):
|
||||
res = {
|
||||
'project': module.params['project'],
|
||||
'zone': module.params['zone'],
|
||||
'cluster': replace_resource_dict(module.params['cluster'], 'name')
|
||||
}
|
||||
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
|
||||
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue