mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-25 14:20:29 -07:00
fix: upgrade ansible version, address test and lint errors
This commit is contained in:
parent
c15b47250d
commit
08ada5354d
216 changed files with 4394 additions and 4262 deletions
|
@ -382,9 +382,13 @@ def wait_for_operation(module, response):
|
|||
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})
|
||||
sleep_time = 1.0
|
||||
while not status:
|
||||
raise_if_errors(op_result, ['error'], module)
|
||||
time.sleep(1.0)
|
||||
time.sleep(sleep_time)
|
||||
sleep_time *= 2
|
||||
if sleep_time > 10.0:
|
||||
sleep_time = 10.0
|
||||
op_result = fetch_resource(module, op_uri, False)
|
||||
status = navigate_hash(op_result, ['done'])
|
||||
return op_result
|
||||
|
|
|
@ -88,7 +88,10 @@ options:
|
|||
sha1_fingerprint:
|
||||
description:
|
||||
- The SHA-1 of the certificate.
|
||||
required: true
|
||||
type: str
|
||||
private_key:
|
||||
description:
|
||||
- The private key associated with the certificate.
|
||||
type: str
|
||||
project:
|
||||
description:
|
||||
|
@ -198,6 +201,11 @@ sha1Fingerprint:
|
|||
- The SHA-1 of the certificate.
|
||||
returned: success
|
||||
type: str
|
||||
privateKey:
|
||||
description:
|
||||
- The private key associated with the certificate.
|
||||
returned: success
|
||||
type: str
|
||||
'''
|
||||
|
||||
################################################################################
|
||||
|
@ -225,7 +233,8 @@ def main():
|
|||
create_time=dict(type='str'),
|
||||
expiration_time=dict(type='str'),
|
||||
instance=dict(required=True, type='dict'),
|
||||
sha1_fingerprint=dict(required=True, type='str'),
|
||||
sha1_fingerprint=dict(type='str'),
|
||||
private_key=dict(type='str'),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -262,12 +271,11 @@ def main():
|
|||
|
||||
def create(module, link, kind):
|
||||
auth = GcpSession(module, 'sql')
|
||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||
return wait_for_create_operation(module, auth.post(link, resource_to_request(module)))
|
||||
|
||||
|
||||
def update(module, link, kind):
|
||||
auth = GcpSession(module, 'sql')
|
||||
return wait_for_operation(module, auth.put(link, resource_to_request(module)))
|
||||
module.fail_json(msg="SQL certificates cannot be modified")
|
||||
|
||||
|
||||
def delete(module, link, kind):
|
||||
|
@ -298,7 +306,7 @@ def fetch_resource(module, link, kind, allow_not_found=True):
|
|||
|
||||
|
||||
def self_link(module):
|
||||
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
|
||||
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name'), 'sha1_fingerprint': module.params['sha1_fingerprint']}
|
||||
return "https://sqladmin.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/sslCerts/{sha1_fingerprint}".format(**res)
|
||||
|
||||
|
||||
|
@ -367,6 +375,31 @@ def async_op_url(module, extra_data=None):
|
|||
return url.format(**combined)
|
||||
|
||||
|
||||
# The create response includes the certificate, but it's not usable until
|
||||
# the operation completes. The create response is also the only place the
|
||||
# private key is available, so return the newly created resource directly.
|
||||
def wait_for_create_operation(module, response):
|
||||
op_result = return_if_object(module, response, 'sql#operation')
|
||||
if op_result is None:
|
||||
return {}
|
||||
status = navigate_hash(op_result, ['operation', 'status'])
|
||||
wait_done = wait_for_create_completion(status, op_result, module)
|
||||
res = navigate_hash(op_result, ['clientCert', 'certInfo'])
|
||||
res.update({'privateKey': navigate_hash(op_result, ['clientCert', 'certPrivateKey'])})
|
||||
return res
|
||||
|
||||
|
||||
def wait_for_create_completion(status, op_result, module):
|
||||
op_id = navigate_hash(op_result, ['operation', 'name'])
|
||||
op_uri = async_op_url(module, {'op_id': op_id})
|
||||
while status != 'DONE':
|
||||
raise_if_errors(op_result, ['error', 'errors'], module)
|
||||
time.sleep(1.0)
|
||||
op_result = fetch_resource(module, op_uri, 'sql#operation', False)
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
return op_result
|
||||
|
||||
|
||||
def wait_for_operation(module, response):
|
||||
op_result = return_if_object(module, response, 'sql#operation')
|
||||
if op_result is None:
|
||||
|
|
|
@ -60,11 +60,6 @@ options:
|
|||
bucket:
|
||||
description:
|
||||
- The name of the bucket.
|
||||
- 'This field represents a link to a Bucket resource in GCP. It can be specified
|
||||
in two ways. First, you can place a dictionary with key ''name'' and value of
|
||||
your resource''s name Alternatively, you can add `register: name-of-resource`
|
||||
to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
|
||||
}}"'
|
||||
required: true
|
||||
type: dict
|
||||
entity:
|
||||
|
@ -75,11 +70,6 @@ options:
|
|||
* project-team-{{projectId}} * allUsers * allAuthenticatedUsers .'
|
||||
required: true
|
||||
type: str
|
||||
object:
|
||||
description:
|
||||
- The name of the object, if applied to an object.
|
||||
required: false
|
||||
type: str
|
||||
role:
|
||||
description:
|
||||
- The access permission for the entity.
|
||||
|
@ -195,21 +185,6 @@ entityId:
|
|||
- The ID for the entity.
|
||||
returned: success
|
||||
type: str
|
||||
generation:
|
||||
description:
|
||||
- The content generation of the object, if applied to an object.
|
||||
returned: success
|
||||
type: int
|
||||
id:
|
||||
description:
|
||||
- The ID of the access-control entry.
|
||||
returned: success
|
||||
type: str
|
||||
object:
|
||||
description:
|
||||
- The name of the object, if applied to an object.
|
||||
returned: success
|
||||
type: str
|
||||
projectTeam:
|
||||
description:
|
||||
- The project team associated with the entity.
|
||||
|
@ -271,10 +246,7 @@ def main():
|
|||
state = module.params['state']
|
||||
kind = 'storage#objectAccessControl'
|
||||
|
||||
if module.params['id']:
|
||||
fetch = fetch_resource(module, self_link(module), kind)
|
||||
else:
|
||||
fetch = {}
|
||||
fetch = fetch_resource(module, self_link(module), kind)
|
||||
changed = False
|
||||
|
||||
if fetch:
|
||||
|
@ -393,9 +365,6 @@ def response_to_hash(module, response):
|
|||
u'email': response.get(u'email'),
|
||||
u'entity': response.get(u'entity'),
|
||||
u'entityId': response.get(u'entityId'),
|
||||
u'generation': response.get(u'generation'),
|
||||
u'id': response.get(u'id'),
|
||||
u'object': response.get(u'object'),
|
||||
u'projectTeam': DefaultObjectACLProjectteam(response.get(u'projectTeam', {}), module).from_response(),
|
||||
u'role': response.get(u'role'),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue