Add configuration for jenkins location

Location url is used to let Jenkins
know how to refer to itself

Change-Id: I44ac0d271d38e4c04721df605142f44345736cf2
Related-bug: PROD-26834
             PROD-30275
(cherry picked from commit I44ac0d271d38e4c04721df605142f44345736cf2)
diff --git a/_states/jenkins_location.py b/_states/jenkins_location.py
new file mode 100644
index 0000000..7aac8bf
--- /dev/null
+++ b/_states/jenkins_location.py
@@ -0,0 +1,34 @@
+import logging
+
+logger = 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_location state module cannot be loaded: '
+            'jenkins_common not found')
+    return True
+
+
+def config(name, url, email=''):
+    """
+    Jenkins location configuration. This value is used to
+    let Jenkins know how to refer to itself.
+
+    :url: Jenkins location url:
+    :email: Jenkins server email
+    :returns: salt-specified state dict
+    """
+
+    template = __salt__['jenkins_common.load_template'](
+        'salt://jenkins/files/groovy/location.template',
+        __env__)
+
+    return __salt__['jenkins_common.api_call'](name, template,
+                        ['CHANGED', 'EXISTS'],
+                        {'url': url, 'email': email},
+                        'location config')