Pep8 fixes for letsencrypt module (#24144)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
df5be2b8ea
commit
fbb924ff24
2 changed files with 90 additions and 87 deletions
|
@ -174,6 +174,7 @@ from datetime import datetime
|
|||
def nopad_b64(data):
|
||||
return base64.urlsafe_b64encode(data).decode('utf8').replace("=", "")
|
||||
|
||||
|
||||
def simple_get(module, url):
|
||||
resp, info = fetch_url(module, url, method='GET')
|
||||
|
||||
|
@ -197,6 +198,7 @@ def simple_get(module,url):
|
|||
module.fail_json(msg="ACME request failed: CODE: {0} RESULT: {1}".format(info['status'], result))
|
||||
return result
|
||||
|
||||
|
||||
def get_cert_days(module, cert_file):
|
||||
'''
|
||||
Return the days the certificate in cert_file remains valid and -1
|
||||
|
@ -218,6 +220,7 @@ def get_cert_days(module,cert_file):
|
|||
now = datetime.datetime.utcnow()
|
||||
return (not_after - now).days
|
||||
|
||||
|
||||
# function source: network/basics/uri.py
|
||||
def write_file(module, dest, content):
|
||||
'''
|
||||
|
@ -268,6 +271,7 @@ def write_file(module, dest, content):
|
|||
os.remove(tmpsrc)
|
||||
return changed
|
||||
|
||||
|
||||
class ACMEDirectory(object):
|
||||
'''
|
||||
The ACME server directory. Gives access to the available resources
|
||||
|
@ -294,6 +298,7 @@ class ACMEDirectory(object):
|
|||
self.module.fail_json(msg="Failed to get replay-nonce, got status {0}".format(info['status']))
|
||||
return info['replay-nonce']
|
||||
|
||||
|
||||
class ACMEAccount(object):
|
||||
'''
|
||||
ACME account object. Handles the authorized communication with the
|
||||
|
@ -499,6 +504,7 @@ class ACMEAccount(object):
|
|||
|
||||
return authz
|
||||
|
||||
|
||||
class ACMEClient(object):
|
||||
'''
|
||||
ACME client class. Uses an ACME account object and a CSR to
|
||||
|
@ -540,7 +546,6 @@ class ACMEClient(object):
|
|||
domains.add(san[4:])
|
||||
return domains
|
||||
|
||||
|
||||
def _get_domain_auth(self, domain):
|
||||
'''
|
||||
Get the status string of the first authorization for the given domain.
|
||||
|
@ -763,6 +768,7 @@ class ACMEClient(object):
|
|||
self.cert_days = get_cert_days(self.module, self.dest)
|
||||
self.changed = True
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
|
@ -789,15 +795,13 @@ def main():
|
|||
# the authorization status...) would lead to potential changes of the current
|
||||
# state
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True,authorizations={},
|
||||
challenge_data={},cert_days=cert_days)
|
||||
module.exit_json(changed=True, authorizations={}, challenge_data={}, cert_days=cert_days)
|
||||
else:
|
||||
client = ACMEClient(module)
|
||||
client.cert_days = cert_days
|
||||
data = client.do_challenges()
|
||||
client.get_certificate()
|
||||
module.exit_json(changed=client.changed,authorizations=client.authorizations,
|
||||
challenge_data=data,cert_days=client.cert_days)
|
||||
module.exit_json(changed=client.changed, authorizations=client.authorizations, challenge_data=data, cert_days=client.cert_days)
|
||||
else:
|
||||
module.exit_json(changed=False, cert_days=cert_days)
|
||||
|
||||
|
|
|
@ -772,7 +772,6 @@ lib/ansible/modules/web_infrastructure/ejabberd_user.py
|
|||
lib/ansible/modules/web_infrastructure/htpasswd.py
|
||||
lib/ansible/modules/web_infrastructure/jboss.py
|
||||
lib/ansible/modules/web_infrastructure/jira.py
|
||||
lib/ansible/modules/web_infrastructure/letsencrypt.py
|
||||
lib/ansible/modules/windows/win_disk_image.py
|
||||
lib/ansible/modules/windows/win_dns_client.py
|
||||
lib/ansible/modules/windows/win_domain.py
|
||||
|
|
Loading…
Reference in a new issue