diff options
author | Alex Stephen <alexstephen@google.com> | 2018-08-13 09:07:24 -0700 |
---|---|---|
committer | Ryan Brown <sb@ryansb.com> | 2018-08-13 12:07:24 -0400 |
commit | 439716a832de9326a71692e9b651f79e0e0adfd9 (patch) | |
tree | 3f584c5fe4aba40fc182de4226be7342d9f2e912 /lib/ansible/modules/cloud/google/gcp_compute_health_check.py | |
parent | c8418a709b3603f82b9c4d53bb9c8f9ddd6b828b (diff) | |
download | ansible-439716a832de9326a71692e9b651f79e0e0adfd9.tar.gz |
Bug fixes for gcp_compute_health_check (#42811)
Diffstat (limited to 'lib/ansible/modules/cloud/google/gcp_compute_health_check.py')
-rw-r--r-- | lib/ansible/modules/cloud/google/gcp_compute_health_check.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py index de6fb88075..a07c5d1030 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py @@ -228,7 +228,7 @@ extends_documentation_fragment: gcp EXAMPLES = ''' - name: create a health check gcp_compute_health_check: - name: testObject + name: "test_object" type: TCP tcp_health_check: port_name: service-health @@ -237,11 +237,9 @@ EXAMPLES = ''' healthy_threshold: 10 timeout_sec: 2 unhealthy_threshold: 5 - project: testProject - auth_kind: service_account - service_account_file: /tmp/auth.pem - scopes: - - https://www.googleapis.com/auth/compute + project: "test_project" + auth_kind: "service_account" + service_account_file: "/tmp/auth.pem" state: present ''' @@ -512,6 +510,9 @@ def main(): ) ) + if not module.params['scopes']: + module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] + state = module.params['state'] kind = 'compute#healthCheck' @@ -564,10 +565,10 @@ def resource_to_request(module): u'timeoutSec': module.params.get('timeout_sec'), u'unhealthyThreshold': module.params.get('unhealthy_threshold'), u'type': module.params.get('type'), - u'httpHealthCheck': HealChecHttpHealChec(module.params.get('http_health_check', {}), module).to_request(), - u'httpsHealthCheck': HealChecHttpHealChec(module.params.get('https_health_check', {}), module).to_request(), - u'tcpHealthCheck': HealChecTcpHealChec(module.params.get('tcp_health_check', {}), module).to_request(), - u'sslHealthCheck': HealChecSslHealChec(module.params.get('ssl_health_check', {}), module).to_request() + u'httpHealthCheck': HealthCheckHttpHealthCheck(module.params.get('http_health_check', {}), module).to_request(), + u'httpsHealthCheck': HealthCheckHttpsHealthCheck(module.params.get('https_health_check', {}), module).to_request(), + u'tcpHealthCheck': HealthCheckTcpHealthCheck(module.params.get('tcp_health_check', {}), module).to_request(), + u'sslHealthCheck': HealthCheckSslHealthCheck(module.params.get('ssl_health_check', {}), module).to_request() } return_vals = {} for k, v in request.items(): @@ -644,10 +645,10 @@ def response_to_hash(module, response): u'timeoutSec': response.get(u'timeoutSec'), u'unhealthyThreshold': response.get(u'unhealthyThreshold'), u'type': response.get(u'type'), - u'httpHealthCheck': HealChecHttpHealChec(response.get(u'httpHealthCheck', {}), module).from_response(), - u'httpsHealthCheck': HealChecHttpHealChec(response.get(u'httpsHealthCheck', {}), module).from_response(), - u'tcpHealthCheck': HealChecTcpHealChec(response.get(u'tcpHealthCheck', {}), module).from_response(), - u'sslHealthCheck': HealChecSslHealChec(response.get(u'sslHealthCheck', {}), module).from_response() + u'httpHealthCheck': HealthCheckHttpHealthCheck(response.get(u'httpHealthCheck', {}), module).from_response(), + u'httpsHealthCheck': HealthCheckHttpsHealthCheck(response.get(u'httpsHealthCheck', {}), module).from_response(), + u'tcpHealthCheck': HealthCheckTcpHealthCheck(response.get(u'tcpHealthCheck', {}), module).from_response(), + u'sslHealthCheck': HealthCheckSslHealthCheck(response.get(u'sslHealthCheck', {}), module).from_response() } @@ -663,7 +664,7 @@ def async_op_url(module, extra_data=None): def wait_for_operation(module, response): op_result = return_if_object(module, response, 'compute#operation') if op_result is None: - return None + return {} status = navigate_hash(op_result, ['status']) wait_done = wait_for_completion(status, op_result, module) return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#healthCheck') @@ -688,7 +689,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class HealChecHttpHealChec(object): +class HealthCheckHttpHealthCheck(object): def __init__(self, request, module): self.module = module if request: @@ -715,7 +716,7 @@ class HealChecHttpHealChec(object): }) -class HealChecHttpHealChec(object): +class HealthCheckHttpsHealthCheck(object): def __init__(self, request, module): self.module = module if request: @@ -742,7 +743,7 @@ class HealChecHttpHealChec(object): }) -class HealChecTcpHealChec(object): +class HealthCheckTcpHealthCheck(object): def __init__(self, request, module): self.module = module if request: @@ -769,7 +770,7 @@ class HealChecTcpHealChec(object): }) -class HealChecSslHealChec(object): +class HealthCheckSslHealthCheck(object): def __init__(self, request, module): self.module = module if request: |