Fix imports and pep8 problems so CI can pass again.

pull/20503/head
Toshio Kuratomi 8 years ago
parent 3537b24742
commit dcc63c8f93

@ -162,7 +162,8 @@ subjectAltName:
sample: 'DNS:www.ansible.com,DNS:m.ansible.com' sample: 'DNS:www.ansible.com,DNS:m.ansible.com'
''' '''
from ansible.module_utils.basic import * import errno
import os
try: try:
from OpenSSL import crypto from OpenSSL import crypto
@ -171,12 +172,14 @@ except ImportError:
else: else:
pyopenssl_found = True pyopenssl_found = True
import os from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
class CertificateSigningRequestError(Exception): class CertificateSigningRequestError(Exception):
pass pass
class CertificateSigningRequest(object): class CertificateSigningRequest(object):
def __init__(self, module): def __init__(self, module):
@ -204,7 +207,7 @@ class CertificateSigningRequest(object):
if self.subjectAltName is None: if self.subjectAltName is None:
self.subjectAltName = 'DNS:%s' % self.subject['CN'] self.subjectAltName = 'DNS:%s' % self.subject['CN']
for (key,value) in self.subject.items(): for (key, value) in self.subject.items():
if value is None: if value is None:
del self.subject[key] del self.subject[key]
@ -215,7 +218,7 @@ class CertificateSigningRequest(object):
req = crypto.X509Req() req = crypto.X509Req()
req.set_version(self.version) req.set_version(self.version)
subject = req.get_subject() subject = req.get_subject()
for (key,value) in self.subject.items(): for (key, value) in self.subject.items():
if value is not None: if value is not None:
setattr(subject, key, value) setattr(subject, key, value)
@ -243,7 +246,6 @@ class CertificateSigningRequest(object):
if module.set_fs_attributes_if_different(file_args, False): if module.set_fs_attributes_if_different(file_args, False):
self.changed = True self.changed = True
def remove(self): def remove(self):
'''Remove the Certificate Signing Request.''' '''Remove the Certificate Signing Request.'''
@ -256,7 +258,6 @@ class CertificateSigningRequest(object):
else: else:
self.changed = False self.changed = False
def dump(self): def dump(self):
'''Serialize the object into a dictionnary.''' '''Serialize the object into a dictionnary.'''
@ -272,7 +273,7 @@ class CertificateSigningRequest(object):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
digest=dict(default='sha256', type='str'), digest=dict(default='sha256', type='str'),
privatekey_path=dict(require=True, type='path'), privatekey_path=dict(require=True, type='path'),
@ -288,8 +289,8 @@ def main():
commonName=dict(aliases=['CN'], type='str'), commonName=dict(aliases=['CN'], type='str'),
emailAddress=dict(aliases=['E'], type='str'), emailAddress=dict(aliases=['E'], type='str'),
), ),
add_file_common_args = True, add_file_common_args=True,
supports_check_mode = True, supports_check_mode=True,
required_one_of=[['commonName', 'subjectAltName']], required_one_of=[['commonName', 'subjectAltName']],
) )

Loading…
Cancel
Save