aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.env.sample3
-rw-r--r--src/account/forms.py2
-rw-r--r--src/account/models.py1
-rw-r--r--src/account/views.py2
-rw-r--r--src/jenkins/adapter.py11
-rw-r--r--src/pharos_dashboard/settings.py6
-rw-r--r--src/templates/base.html1
7 files changed, 21 insertions, 5 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/account/forms.py b/src/account/forms.py
index 7653e2b..3b9c627 100644
--- a/src/account/forms.py
+++ b/src/account/forms.py
@@ -17,6 +17,6 @@ from account.models import UserProfile
class AccountSettingsForm(forms.ModelForm):
class Meta:
model = UserProfile
- fields = ['company', 'ssh_public_key', 'pgp_public_key', 'timezone']
+ fields = ['company', 'email_addr', 'ssh_public_key', 'pgp_public_key', 'timezone']
timezone = forms.ChoiceField(choices=[(x, x) for x in pytz.common_timezones], initial='UTC')
diff --git a/src/account/models.py b/src/account/models.py
index c2e9902..bfc0bbe 100644
--- a/src/account/models.py
+++ b/src/account/models.py
@@ -20,6 +20,7 @@ class UserProfile(models.Model):
timezone = models.CharField(max_length=100, blank=False, default='UTC')
ssh_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
pgp_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
+ email_addr = models.CharField(max_length=300, blank=false, default='email@mail.com')
company = models.CharField(max_length=200, blank=False)
oauth_token = models.CharField(max_length=1024, blank=False)
diff --git a/src/account/views.py b/src/account/views.py
index 17fbdc3..e6a0e5d 100644
--- a/src/account/views.py
+++ b/src/account/views.py
@@ -119,6 +119,7 @@ class JiraAuthenticatedView(RedirectView):
jira = JIRA(server=settings.JIRA_URL, oauth=oauth_dict)
username = jira.current_user()
+ email = jira.user(username).emailAddress
url = '/'
# Step 3. Lookup the user or create them if they don't exist.
try:
@@ -130,6 +131,7 @@ class JiraAuthenticatedView(RedirectView):
profile = UserProfile()
profile.user = user
profile.save()
+ user.userprofile.email_addr = email
url = reverse('account:settings')
user.userprofile.oauth_token = access_token['oauth_token']
user.userprofile.oauth_secret = access_token['oauth_token_secret']
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/'
+
diff --git a/src/templates/base.html b/src/templates/base.html
index ca17949..c74db05 100644
--- a/src/templates/base.html
+++ b/src/templates/base.html
@@ -1,5 +1,6 @@
{% extends "layout.html" %}
{% load bootstrap3 %}
+{% load staticfiles %}
{% block basecontent %}
<div id="wrapper">