blob: 26b125927af8866343b55f0706698cae91115607 [file] [log] [blame]
Sergey Otpuschennikov83996702017-11-23 17:10:57 +04001import logging
2
3logger = logging.getLogger(__name__)
4
5def __virtual__():
6 '''
7 Only load if jenkins_common module exist.
8 '''
9 if 'jenkins_common.call_groovy_script' not in __salt__:
10 return (
11 False,
12 'The jenkins_gerrit state module cannot be loaded: '
13 'jenkins_common not found')
14 return True
15
16
17def present(name, hostname, username, frontendurl, auth_key_file, authkey,
18 port="29418", auth_key_file_password=None, email="", proxy=""):
19 """
20 Jenkins gerrit-trigger state method
21
22 :param name: server name
23 :param host: server hostname
24 :param username: username
25 :param email: trigger email (optional)
26 :param port: server ssh port
27 :param proxy: proxy url (optional)
28 :param frontendurl: server frontend URL
29 :param auth_key_file: path to key file
30 :param authkey: ssh key
31 :param auth_key_file_password: password for keyfile (optional)
32 :returns: salt-specified state dict
33 """
34 template = __salt__['jenkins_common.load_template'](
35 'salt://jenkins/files/groovy/gerrit.template',
36 __env__)
37 return __salt__['jenkins_common.api_call'](name, template,
38 ["CREATED", "EXISTS"],
39 {
40 "name": name,
41 "hostname": hostname,
42 "port": port if port else "29418",
43 "proxy": proxy if proxy else "",
44 "username": username,
45 "email": email if email else "",
46 "frontendurl": frontendurl,
47 "auth_key_file": auth_key_file,
48 "authkey": authkey,
49 "auth_key_file_password": auth_key_file_password if auth_key_file_password else None
50 },
51 "Gerrit server")