1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Bug fixes for GCP modules (#51573)

This commit is contained in:
Alex Stephen 2019-01-31 14:03:38 -08:00 committed by ansibot
parent 2b0f16443c
commit 27c5e38e10
24 changed files with 42 additions and 53 deletions

View file

@ -329,7 +329,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -371,7 +371,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -486,7 +486,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
region: region:

View file

@ -354,7 +354,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -481,7 +481,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -421,7 +421,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
region: region:

View file

@ -467,7 +467,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -376,7 +376,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -334,7 +334,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
region: region:

View file

@ -556,7 +556,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
extends_documentation_fragment: gcp extends_documentation_fragment: gcp

View file

@ -470,7 +470,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri, 'compute#operation') op_result = fetch_resource(module, op_uri, 'compute#operation', False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.)
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
region: region:

View file

@ -49,7 +49,7 @@ options:
default: present default: present
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and zone, - The name of this cluster. The name must be unique within this project and location,
and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
only. Must start with a letter. Must end with a number or a letter. only. Must start with a letter. Must end with a number or a letter.
required: false required: false
@ -254,13 +254,11 @@ options:
required: false required: false
location: location:
description: description:
- The list of Google Compute Engine locations in which the cluster's nodes should - The location where the cluster is deployed.
be located.
required: false
zone:
description:
- The zone where the cluster is deployed.
required: true required: true
aliases:
- zone
version_added: 2.8
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -275,7 +273,7 @@ EXAMPLES = '''
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "test_project" project: "test_project"
auth_kind: "serviceaccount" auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
@ -285,7 +283,7 @@ EXAMPLES = '''
RETURN = ''' RETURN = '''
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and zone, - The name of this cluster. The name must be unique within this project and location,
and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
only. Must start with a letter. Must end with a number or a letter. only. Must start with a letter. Must end with a number or a letter.
returned: success returned: success
@ -508,12 +506,6 @@ subnetwork:
- The name of the Google Compute Engine subnetwork to which the cluster is connected. - The name of the Google Compute Engine subnetwork to which the cluster is connected.
returned: success returned: success
type: str type: str
location:
description:
- The list of Google Compute Engine locations in which the cluster's nodes should
be located.
returned: success
type: list
endpoint: endpoint:
description: description:
- The IP address of this cluster's master endpoint. - The IP address of this cluster's master endpoint.
@ -567,9 +559,9 @@ expireTime:
- The time the cluster will be automatically deleted in RFC3339 text format. - The time the cluster will be automatically deleted in RFC3339 text format.
returned: success returned: success
type: str type: str
zone: location:
description: description:
- The zone where the cluster is deployed. - The location where the cluster is deployed.
returned: success returned: success
type: str type: str
''' '''
@ -633,8 +625,7 @@ def main():
), ),
), ),
subnetwork=dict(type='str'), subnetwork=dict(type='str'),
location=dict(type='list', elements='str'), location=dict(required=True, type='str', aliases=['zone']),
zone=dict(required=True, type='str'),
) )
) )
@ -696,7 +687,6 @@ def resource_to_request(module):
u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'), u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'),
u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(), u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
u'subnetwork': module.params.get('subnetwork'), u'subnetwork': module.params.get('subnetwork'),
u'location': module.params.get('location'),
} }
request = encode_request(request, module) request = encode_request(request, module)
return_vals = {} return_vals = {}
@ -713,11 +703,11 @@ def fetch_resource(module, link, allow_not_found=True):
def self_link(module): def self_link(module):
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{name}".format(**module.params) return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters/{name}".format(**module.params)
def collection(module): def collection(module):
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters".format(**module.params) return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters".format(**module.params)
def return_if_object(module, response, allow_not_found=False): def return_if_object(module, response, allow_not_found=False):
@ -774,7 +764,6 @@ def response_to_hash(module, response):
u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'), u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'),
u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(), u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(),
u'subnetwork': response.get(u'subnetwork'), u'subnetwork': response.get(u'subnetwork'),
u'location': response.get(u'location'),
u'endpoint': response.get(u'endpoint'), u'endpoint': response.get(u'endpoint'),
u'initialClusterVersion': response.get(u'initialClusterVersion'), u'initialClusterVersion': response.get(u'initialClusterVersion'),
u'currentMasterVersion': response.get(u'currentMasterVersion'), u'currentMasterVersion': response.get(u'currentMasterVersion'),
@ -811,7 +800,7 @@ def wait_for_completion(status, op_result, module):
while status != 'DONE': while status != 'DONE':
raise_if_errors(op_result, ['error', 'errors'], module) raise_if_errors(op_result, ['error', 'errors'], module)
time.sleep(1.0) time.sleep(1.0)
op_result = fetch_resource(module, op_uri) op_result = fetch_resource(module, op_uri, False)
status = navigate_hash(op_result, ['status']) status = navigate_hash(op_result, ['status'])
return op_result return op_result

View file

@ -23,7 +23,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -39,7 +39,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -51,7 +51,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was created - name: verify that cluster was created
gcp_container_cluster_facts: gcp_container_cluster_facts:
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -73,7 +73,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -94,7 +94,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -106,7 +106,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was deleted - name: verify that cluster was deleted
gcp_container_cluster_facts: gcp_container_cluster_facts:
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -128,7 +128,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"