Pep8 fixes for jenkins_* module (#24154)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
d088030fa6
commit
cdca648f15
3 changed files with 32 additions and 29 deletions
|
@ -163,7 +163,9 @@ try:
|
|||
except ImportError:
|
||||
python_lxml_installed = False
|
||||
|
||||
|
||||
class JenkinsJob:
|
||||
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
||||
|
@ -265,7 +267,7 @@ class JenkinsJob:
|
|||
if self.enabled is None:
|
||||
return False
|
||||
|
||||
if ( (self.enabled is False and status != "disabled") or (self.enabled is True and status == "disabled") ):
|
||||
if ((self.enabled is False and status != "disabled") or (self.enabled is True and status == "disabled")):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -328,31 +330,34 @@ class JenkinsJob:
|
|||
result['enabled'] = None
|
||||
return result
|
||||
|
||||
|
||||
def test_dependencies(module):
|
||||
if not python_jenkins_installed:
|
||||
module.fail_json(msg="python-jenkins required for this module. "\
|
||||
"see http://python-jenkins.readthedocs.io/en/latest/install.html")
|
||||
module.fail_json(msg="python-jenkins required for this module. "
|
||||
"see http://python-jenkins.readthedocs.io/en/latest/install.html")
|
||||
|
||||
if not python_lxml_installed:
|
||||
module.fail_json(msg="lxml required for this module. "\
|
||||
"see http://lxml.de/installation.html")
|
||||
module.fail_json(msg="lxml required for this module. "
|
||||
"see http://lxml.de/installation.html")
|
||||
|
||||
|
||||
def job_config_to_string(xml_str):
|
||||
return ET.tostring(ET.fromstring(xml_str))
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
config = dict(required=False),
|
||||
name = dict(required=True),
|
||||
password = dict(required=False, no_log=True),
|
||||
state = dict(required=False, choices=['present', 'absent'], default="present"),
|
||||
enabled = dict(required=False, type='bool'),
|
||||
token = dict(required=False, no_log=True),
|
||||
url = dict(required=False, default="http://localhost:8080"),
|
||||
user = dict(required=False)
|
||||
argument_spec=dict(
|
||||
config=dict(required=False),
|
||||
name=dict(required=True),
|
||||
password=dict(required=False, no_log=True),
|
||||
state=dict(required=False, choices=['present', 'absent'], default="present"),
|
||||
enabled=dict(required=False, type='bool'),
|
||||
token=dict(required=False, no_log=True),
|
||||
url=dict(required=False, default="http://localhost:8080"),
|
||||
user=dict(required=False)
|
||||
),
|
||||
mutually_exclusive = [
|
||||
mutually_exclusive=[
|
||||
['password', 'token'],
|
||||
['config', 'enabled'],
|
||||
],
|
||||
|
|
|
@ -127,6 +127,7 @@ except ImportError:
|
|||
# python3
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
def is_csrf_protection_enabled(module):
|
||||
resp, info = fetch_url(module,
|
||||
module.params['url'] + '/api/json',
|
||||
|
@ -137,6 +138,7 @@ def is_csrf_protection_enabled(module):
|
|||
content = resp.read()
|
||||
return json.loads(content).get('useCrumbs', False)
|
||||
|
||||
|
||||
def get_crumb(module):
|
||||
resp, info = fetch_url(module,
|
||||
module.params['url'] + '/crumbIssuer/api/json',
|
||||
|
@ -147,20 +149,20 @@ def get_crumb(module):
|
|||
content = resp.read()
|
||||
return json.loads(content)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
script = dict(required=True, type="str"),
|
||||
url = dict(required=False, type="str", default="http://localhost:8080"),
|
||||
validate_certs = dict(required=False, type="bool", default=True),
|
||||
user = dict(required=False, no_log=True, type="str",default=None),
|
||||
password = dict(required=False, no_log=True, type="str",default=None),
|
||||
args = dict(required=False, type="dict", default=None)
|
||||
argument_spec=dict(
|
||||
script=dict(required=True, type="str"),
|
||||
url=dict(required=False, type="str", default="http://localhost:8080"),
|
||||
validate_certs=dict(required=False, type="bool", default=True),
|
||||
user=dict(required=False, no_log=True, type="str", default=None),
|
||||
password=dict(required=False, no_log=True, type="str", default=None),
|
||||
args=dict(required=False, type="dict", default=None)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if module.params['user'] is not None:
|
||||
if module.params['password'] is None:
|
||||
module.fail_json(msg="password required when user provided")
|
||||
|
@ -168,7 +170,6 @@ def main():
|
|||
module.params['url_password'] = module.params['password']
|
||||
module.params['force_basic_auth'] = True
|
||||
|
||||
|
||||
if module.params['args'] is not None:
|
||||
from string import Template
|
||||
script_contents = Template(module.params['script']).substitute(module.params['args'])
|
||||
|
@ -183,7 +184,7 @@ def main():
|
|||
resp, info = fetch_url(module,
|
||||
module.params['url'] + "/scriptText",
|
||||
data=urlencode({'script': script_contents}),
|
||||
headers = headers,
|
||||
headers=headers,
|
||||
method="POST")
|
||||
|
||||
if info["status"] != 200:
|
||||
|
@ -195,10 +196,9 @@ def main():
|
|||
module.fail_json(msg="script failed with stacktrace:\n " + result)
|
||||
|
||||
module.exit_json(
|
||||
output = result,
|
||||
output=result,
|
||||
)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -781,8 +781,6 @@ lib/ansible/modules/web_infrastructure/django_manage.py
|
|||
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/jenkins_job.py
|
||||
lib/ansible/modules/web_infrastructure/jenkins_script.py
|
||||
lib/ansible/modules/web_infrastructure/jira.py
|
||||
lib/ansible/modules/web_infrastructure/letsencrypt.py
|
||||
lib/ansible/modules/windows/win_disk_image.py
|
||||
|
|
Loading…
Reference in a new issue