Bug fixes for GCP modules (#54765)

This commit is contained in:
The Magician 2019-04-03 10:31:08 -07:00 committed by ansibot
parent 688409128a
commit 9908b2fbf6
9 changed files with 55 additions and 53 deletions

View file

@ -62,16 +62,9 @@ def replace_resource_dict(item, value):
else: else:
if not item: if not item:
return item return item
if isinstance(item, dict): else:
return item.get(value) return item.get(value)
# Item could be a string or a string representing a dictionary.
try:
new_item = ast.literal_eval(item)
return replace_resource_dict(new_item, value)
except ValueError:
return item
# Handles all authentication and HTTP sessions for GCP API calls. # Handles all authentication and HTTP sessions for GCP API calls.
class GcpSession(object): class GcpSession(object):

View file

@ -63,9 +63,10 @@ options:
description: description:
- The instance to create the database on. - The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
@ -117,7 +118,7 @@ instance:
description: description:
- The instance to create the database on. - The instance to create the database on.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -140,7 +141,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
extra_statements=dict(type='list', elements='str'), extra_statements=dict(type='list', elements='str'),
instance=dict(required=True), instance=dict(required=True, type='dict'),
) )
) )

View file

@ -44,9 +44,10 @@ options:
description: description:
- The instance to create the database on. - The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -85,7 +86,7 @@ items:
description: description:
- The instance to create the database on. - The instance to create the database on.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -100,7 +101,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']

View file

@ -64,9 +64,10 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -120,7 +121,7 @@ instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -145,7 +146,7 @@ def main():
charset=dict(type='str'), charset=dict(type='str'),
collation=dict(type='str'), collation=dict(type='str'),
name=dict(type='str'), name=dict(type='str'),
instance=dict(required=True), instance=dict(required=True, type='dict'),
) )
) )

View file

@ -44,9 +44,10 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -87,7 +88,7 @@ items:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -102,7 +103,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']

View file

@ -61,9 +61,10 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
password: password:
description: description:
@ -118,7 +119,7 @@ instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
password: password:
description: description:
- The password for the user. - The password for the user.
@ -147,7 +148,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
host=dict(required=True, type='str'), host=dict(required=True, type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
instance=dict(required=True), instance=dict(required=True, type='dict'),
password=dict(type='str'), password=dict(type='str'),
) )
) )

View file

@ -44,9 +44,10 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -83,7 +84,7 @@ items:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
password: password:
description: description:
- The password for the user. - The password for the user.
@ -103,7 +104,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']

View file

@ -61,9 +61,10 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a in two ways. First, you can place a dictionary with key ''name'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket of your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
entity: entity:
description: description:
@ -140,9 +141,10 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a in two ways. First, you can place a dictionary with key ''name'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket of your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
entity: entity:
description: description:
@ -359,7 +361,7 @@ acl:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -453,7 +455,7 @@ defaultObjectAcl:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -740,7 +742,7 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
entity_id=dict(type='str'), entity_id=dict(type='str'),
project_team=dict( project_team=dict(
@ -763,7 +765,7 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
object=dict(type='str'), object=dict(type='str'),
role=dict(required=True, type='str', choices=['OWNER', 'READER']), role=dict(required=True, type='str', choices=['OWNER', 'READER']),

View file

@ -60,9 +60,10 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
entity: entity:
description: description:
@ -131,7 +132,7 @@ bucket:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -203,7 +204,7 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
entity_id=dict(type='str'), entity_id=dict(type='str'),
project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))), project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))),