aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2017-11-03 14:36:19 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2017-11-03 16:43:15 -0400
commit50ca17b63ab7f79ec2b8326d3d1e5f3448091214 (patch)
treecb4b3ae03566ac1f6f73481f3879bd87baf83078
parent42763c659dd029cbe2c88e2292f638fd0735825e (diff)
Abstract Hard-Coded URLs to Config File
JIRA: PHAROS-317 The Jenkins URL configuration now works the same as the Jira URL configuration, with a base URL in the config.env file, with settings.py calculating the final URLs to be used in adapter.py. Change-Id: I79b4784ab39afdb789a24e4c0f1e8a3ae3566421 Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
-rw-r--r--config.env.sample3
-rw-r--r--src/jenkins/adapter.py11
-rw-r--r--src/pharos_dashboard/settings.py6
3 files changed, 16 insertions, 4 deletions
diff --git a/config.env.sample b/config.env.sample
index 060841c..b370fe2 100644
--- a/config.env.sample
+++ b/config.env.sample
@@ -22,3 +22,6 @@ JIRA_USER_PASSWORD=sample_jira_pass
# Rabbitmq
RABBITMQ_USER=opnfv
RABBITMQ_PASSWORD=opnfvopnfv
+
+#Jenkins Build Server
+JENKINS_URL=https://build.opnfv.org/ci
diff --git a/src/jenkins/adapter.py b/src/jenkins/adapter.py
index edf502f..b48b868 100644
--- a/src/jenkins/adapter.py
+++ b/src/jenkins/adapter.py
@@ -10,6 +10,7 @@
import logging
import re
+from django.conf import settings
import requests
from django.core.cache import cache
@@ -33,13 +34,15 @@ def get_json(url):
def get_all_slaves():
- url = "https://build.opnfv.org/ci/computer/api/json?tree=computer[displayName,offline,idle]"
+ url = settings.ALL_SLAVES_URL
json = get_json(url)
if json is not None:
return json['computer'] # return list of dictionaries
return []
+
+
def get_slave(slavename):
slaves = get_all_slaves()
for slave in slaves:
@@ -49,7 +52,7 @@ def get_slave(slavename):
def get_ci_slaves():
- url = "https://build.opnfv.org/ci/label/ci-pod/api/json?tree=nodes[nodeName,offline,idle]"
+ url = settings.CI_SLAVES_URL
json = get_json(url)
if json is not None:
return json['nodes']
@@ -57,7 +60,7 @@ def get_ci_slaves():
def get_all_jobs():
- url = "https://build.opnfv.org/ci/api/json?tree=jobs[displayName,url,lastBuild[fullDisplayName,building,builtOn,timestamp,result]]"
+ url = settings.ALL_JOBS_URL
json = get_json(url)
if json is not None:
return json['jobs'] # return list of dictionaries
@@ -123,7 +126,7 @@ def parse_job_string(full_displayname):
return job
def get_slave_url(slave):
- return 'https://build.opnfv.org/ci/computer/' + slave['displayName']
+ return settings.GET_SLAVE_URL + slave['displayName']
def get_slave_status(slave):
diff --git a/src/pharos_dashboard/settings.py b/src/pharos_dashboard/settings.py
index 546b174..83ad172 100644
--- a/src/pharos_dashboard/settings.py
+++ b/src/pharos_dashboard/settings.py
@@ -182,3 +182,9 @@ CELERYBEAT_SCHEDULE = {
'schedule': timedelta(hours=24)
},
}
+# Jenkins Settings
+ALL_SLAVES_URL = os.environ['JENKINS_URL'] + '/computer/api/json?tree=computer[displayName,offline,idle]'
+CI_SLAVES_URL = os.environ['JENKINS_URL'] + '/label/ci-pod/api/json?tree=nodes[nodeName,offline,idle]'
+ALL_JOBS_URL = os.environ['JENKINS_URL'] + '/api/json?tree=jobs[displayName,url,lastBuild[fullDisplayName,building,builtOn,timestamp,result]'
+GET_SLAVE_URL = os.environ['JENKINS_URL'] + '/computer/'
+