Add verbose error messages at __virtual__
Change-Id: Ieb1a1ac405b5faac0e7bb9ce44df2f4869c5736c
diff --git a/_states/jenkins_approval.py b/_states/jenkins_approval.py
index f5263fb..e4b21b4 100644
--- a/_states/jenkins_approval.py
+++ b/_states/jenkins_approval.py
@@ -50,6 +50,19 @@
"""
+
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_approval state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def approved(name):
"""
Jenkins Script approval approve state method
diff --git a/_states/jenkins_artifactory.py b/_states/jenkins_artifactory.py
index 03a015c..0fea075 100644
--- a/_states/jenkins_artifactory.py
+++ b/_states/jenkins_artifactory.py
@@ -41,6 +41,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_artifactory state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, url, credential_id, **kwargs):
"""
Jenkins artifactory present state method
diff --git a/_states/jenkins_credential.py b/_states/jenkins_credential.py
index 5df3278..b2470fc 100644
--- a/_states/jenkins_credential.py
+++ b/_states/jenkins_credential.py
@@ -54,6 +54,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_credentials state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, scope, username, password="", desc="", key=None):
"""
Main jenkins credentials state method
diff --git a/_states/jenkins_job.py b/_states/jenkins_job.py
index 69deb37..74be81c 100644
--- a/_states/jenkins_job.py
+++ b/_states/jenkins_job.py
@@ -15,6 +15,18 @@
log = logging.getLogger(__name__)
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_job state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def _elements_equal(e1, e2):
if e1.tag != e2.tag:
return False
diff --git a/_states/jenkins_lib.py b/_states/jenkins_lib.py
index d4dc5be..88f1a47 100644
--- a/_states/jenkins_lib.py
+++ b/_states/jenkins_lib.py
@@ -50,6 +50,19 @@
}}
"""
+
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_lib state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, url, branch="master", credential_id="", implicit=True, **kwargs):
"""
Jenkins Global pipeline library present state method
diff --git a/_states/jenkins_node.py b/_states/jenkins_node.py
index 0b318c2..aa54efd 100644
--- a/_states/jenkins_node.py
+++ b/_states/jenkins_node.py
@@ -79,6 +79,19 @@
}}
"""
+
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_node state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def label(name, lbl_text, append=False):
"""
Jenkins node label state method
diff --git a/_states/jenkins_plugin.py b/_states/jenkins_plugin.py
index 4956751..cb54633 100644
--- a/_states/jenkins_plugin.py
+++ b/_states/jenkins_plugin.py
@@ -77,6 +77,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_plugin state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, restart=False):
"""
Jenkins plugin present state method, for installing plugins
diff --git a/_states/jenkins_security.py b/_states/jenkins_security.py
index d9d411f..c20cc83 100644
--- a/_states/jenkins_security.py
+++ b/_states/jenkins_security.py
@@ -44,6 +44,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_security state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def ldap(name, server, root_dn, user_search_base, manager_dn, manager_password, user_search="", group_search_base="", inhibit_infer_root_dn=False):
"""
Jenkins ldap state method
diff --git a/_states/jenkins_slack.py b/_states/jenkins_slack.py
index 73048fe..cbe52ec 100644
--- a/_states/jenkins_slack.py
+++ b/_states/jenkins_slack.py
@@ -25,6 +25,19 @@
}}
""" # noqa
+
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_slack state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def config(name, team_domain, token, token_credential_id="", room="", send_as=None):
"""
Jenkins Slack config state method
diff --git a/_states/jenkins_smtp.py b/_states/jenkins_smtp.py
index 969019c..f27972e 100644
--- a/_states/jenkins_smtp.py
+++ b/_states/jenkins_smtp.py
@@ -44,6 +44,19 @@
}}
""" # noqa
+
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_smtp state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def config(name, host, username, password, reply_to=None, port=25, ssl=False, charset="UTF-8"):
"""
Jenkins SMTP server config state method
diff --git a/_states/jenkins_theme.py b/_states/jenkins_theme.py
index b4e0b4d..2f0208b 100644
--- a/_states/jenkins_theme.py
+++ b/_states/jenkins_theme.py
@@ -23,6 +23,18 @@
}}
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_theme state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def config(name, css_url, js_url):
"""
Jenkins theme config state method
diff --git a/_states/jenkins_user.py b/_states/jenkins_user.py
index ec102b1..c2f2d9b 100644
--- a/_states/jenkins_user.py
+++ b/_states/jenkins_user.py
@@ -38,6 +38,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_user state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, username, password, admin=False):
"""
Main jenkins users state method
diff --git a/_states/jenkins_view.py b/_states/jenkins_view.py
index 28b12e0..dc941e9 100644
--- a/_states/jenkins_view.py
+++ b/_states/jenkins_view.py
@@ -71,6 +71,18 @@
""" # noqa
+def __virtual__():
+ '''
+ Only load if jenkins_common module exist.
+ '''
+ if 'jenkins_common.call_groovy_script' not in __salt__:
+ return (
+ False,
+ 'The jenkins_view state module cannot be loaded: '
+ 'jenkins_common not found')
+ return True
+
+
def present(name, type="ListView", **kwargs):
"""
Jenkins view present state method