aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/api/admin.py2
-rw-r--r--src/api/models.py2
-rw-r--r--src/templates/dashboard/landing.html6
-rw-r--r--src/templates/resource/steps/meta_info.html8
-rw-r--r--src/templates/resource/steps/pod_definition.html1
-rw-r--r--src/templates/workflow/confirm.html33
-rw-r--r--src/templates/workflow/viewport-base.html27
-rw-r--r--src/workflow/models.py85
-rw-r--r--src/workflow/resource_bundle_workflow.py9
9 files changed, 149 insertions, 24 deletions
diff --git a/src/api/admin.py b/src/api/admin.py
index 3d32c78..8b2fcb3 100644
--- a/src/api/admin.py
+++ b/src/api/admin.py
@@ -17,6 +17,7 @@ from api.models import (
HardwareConfig,
NetworkConfig,
SoftwareConfig,
+ AccessConfig,
AccessRelation,
SoftwareRelation,
HostHardwareRelation,
@@ -33,6 +34,7 @@ admin.site.register(OpnfvApiConfig)
admin.site.register(HardwareConfig)
admin.site.register(NetworkConfig)
admin.site.register(SoftwareConfig)
+admin.site.register(AccessConfig)
admin.site.register(AccessRelation)
admin.site.register(SoftwareRelation)
admin.site.register(HostHardwareRelation)
diff --git a/src/api/models.py b/src/api/models.py
index 78ec920..b6bd79f 100644
--- a/src/api/models.py
+++ b/src/api/models.py
@@ -652,7 +652,7 @@ class JobFactory(object):
revoke=False,
job=job,
context={
- "key": user.userprofile.ssh_public_key.read(),
+ "key": user.userprofile.ssh_public_key.open().read().decode(encoding="UTF-8"),
"hosts": [host.labid for host in hosts]
}
)
diff --git a/src/templates/dashboard/landing.html b/src/templates/dashboard/landing.html
index 3e0aacd..b1eec86 100644
--- a/src/templates/dashboard/landing.html
+++ b/src/templates/dashboard/landing.html
@@ -28,12 +28,6 @@
grid-template-columns: 33% 34% 33%;
}
</style>
-<script type="text/javascript">
- function cwf(wf_type){
- document.getElementById('id_workflow').selectedIndex = wf_type;
- document.getElementById('wf_selection_form').submit();
- }
-</script>
<div class='wf_create_div'>
<button class="wf_create btn" onclick="cwf(0)">Create a Booking</button>
<button class="wf_create btn" onclick="cwf(1)">Create a Pod</button>
diff --git a/src/templates/resource/steps/meta_info.html b/src/templates/resource/steps/meta_info.html
index 389ff6d..b458842 100644
--- a/src/templates/resource/steps/meta_info.html
+++ b/src/templates/resource/steps/meta_info.html
@@ -14,5 +14,11 @@
{% endblock content %}
{% block onleave %}
-document.getElementById("resource_meta_form").submit();
+var ajaxForm = $("#resource_meta_form");
+var formData = ajaxForm.serialize();
+req = new XMLHttpRequest();
+req.open("POST", "/wf/workflow/", false);
+req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+req.onerror = function() { alert("problem submitting form"); }
+req.send(formData);
{% endblock %}
diff --git a/src/templates/resource/steps/pod_definition.html b/src/templates/resource/steps/pod_definition.html
index ab9dfb3..b2b4998 100644
--- a/src/templates/resource/steps/pod_definition.html
+++ b/src/templates/resource/steps/pod_definition.html
@@ -596,7 +596,6 @@ function submitForm() {
var input_elem = document.getElementById("hidden_xml_input");
var s = encodeGraph(currentGraph);
input_elem.value = s;
- //form.submit();
req = new XMLHttpRequest();
req.open("POST", "/wf/workflow/", false);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
diff --git a/src/templates/workflow/confirm.html b/src/templates/workflow/confirm.html
index 555fa56..4f2616e 100644
--- a/src/templates/workflow/confirm.html
+++ b/src/templates/workflow/confirm.html
@@ -70,15 +70,28 @@
req.send(formData);
}
+ function submitForm()
+ {
+ var form = $("#confirmation_form");
+ var formData = form.serialize();
+ var req = new XMLHttpRequest();
+ req.open("POST", "/wf/workflow/", false);
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ req.onerror = function() { alert("problem submitting confirmation"); }
+ req.onreadystatechange = function() { if(req.readyState === 4 ) { delete_manager(); } }
+ req.send(formData);
+ }
+
+
function formconfirm()
{
select.value = "True";
- document.getElementById("confirmation_form").submit();
+ submitForm();
}
function formcancel()
{
select.value = "False";
- document.getElementById("confirmation_form").submit();
+ submitForm();
}
var confirmed = {{bypassed|default:"false"}};
@@ -91,7 +104,20 @@
function fixVlans() {
document.getElementById("vlan_input").value = "True";
- document.getElementById("vlan_form").submit();
+ var form = $("#vlan_form");
+ var formData = form.serialize();
+ var req = new XMLHttpRequest();
+ req.open("POST", "/wf/workflow/", false);
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ req.onerror = function() { alert("problem submitting form"); }
+ req.onreadystatechange = function() { //replaces current page with response
+ if(req.readyState === 4 ) {
+ document.open();
+ document.write(req.responseText);
+ document.close();
+ }
+ }
+ req.send(formData);
}
var problem = {{vlan_warning|default:'false'}};
if(problem){
@@ -121,5 +147,4 @@ if(problem){
{% endblock element_messages %}
{% endblock content %}
{% block onleave %}
-//document.getElementById("confirmation_form").submit();
{% endblock %}
diff --git a/src/templates/workflow/viewport-base.html b/src/templates/workflow/viewport-base.html
index fd9b638..37eff27 100644
--- a/src/templates/workflow/viewport-base.html
+++ b/src/templates/workflow/viewport-base.html
@@ -14,6 +14,9 @@
height: calc(100% - 170px);
}
+ .go_btn_disabled{
+ background-color: #ffffff;
+ }
.go_forward{
right: 0px;
border-left: none;
@@ -208,6 +211,30 @@
function update_breadcrumbs(meta_json) {
step = meta_json['active'];
page_count = meta_json['steps'].length;
+ if( step == 0 )
+ {
+ var btn = document.getElementById("gob");
+ btn.classList.add("go_btn_disabled");
+ btn.disabled = true;
+ }
+ else
+ {
+ var btn = document.getElementById("gob");
+ btn.classList.remove("go_btn_disabled");
+ btn.disabled = false;
+ }
+ if( step == page_count - 1 )
+ {
+ var btn = document.getElementById("gof");
+ btn.classList.add("go_btn_disabled");
+ btn.disabled = true;
+ }
+ else
+ {
+ var btn = document.getElementById("gof");
+ btn.classList.remove("go_btn_disabled");
+ btn.disabled = false;
+ }
//remove all children of breadcrumbs so we can redraw
var container = document.getElementById("breadcrumbs");
while(container.firstChild){
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 6a8eca1..73a142e 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -26,13 +26,11 @@ from booking.models import Booking
class BookingAuthManager():
LFN_PROJECTS = ["opnfv"] # TODO
- def parse_url(self, info_url):
- """
- will return the PTL in the INFO file on success, or None
- """
+ def parse_github_url(self, url):
+ project_leads = []
try:
- parts = info_url.split("/")
- if parts[0].find("http") > -1: # the url include http(s)://
+ parts = url.split("/")
+ if "http" in parts[0]: # the url include http(s)://
parts = parts[2:]
if parts[-1] != "INFO.yaml":
return None
@@ -47,13 +45,84 @@ class BookingAuthManager():
info_file = requests.get(url, timeout=15).text
info_parsed = yaml.load(info_file)
ptl = info_parsed.get('project_lead')
- if not ptl:
+ if ptl:
+ project_leads.append(ptl)
+ sub_ptl = info_parsed.get("subproject_lead")
+ if sub_ptl:
+ project_leads.append(sub_ptl)
+
+ except Exception:
+ pass
+
+ return project_leads
+
+ def parse_gerrit_url(self, url):
+ project_leads = []
+ try:
+ parts = url.split("/")
+ if "http" in parts[0]: # the url include http(s)://
+ parts = parts[2:]
+ if "f=INFO.yaml" not in parts[-1].split(";"):
+ return None
+ if "gerrit.opnfv.org" not in parts[0]:
return None
- return ptl
+ # now to download and parse file
+ url = "https://" + "/".join(parts)
+ info_file = requests.get(url, timeout=15).text
+ info_parsed = yaml.load(info_file)
+ ptl = info_parsed.get('project_lead')
+ if ptl:
+ project_leads.append(ptl)
+ sub_ptl = info_parsed.get("subproject_lead")
+ if sub_ptl:
+ project_leads.append(sub_ptl)
except Exception:
return None
+ return project_leads
+
+ def parse_opnfv_git_url(self, url):
+ project_leads = []
+ try:
+ parts = url.split("/")
+ if "http" in parts[0]: # the url include http(s)://
+ parts = parts[2:]
+ if "INFO.yaml" not in parts[-1]:
+ return None
+ if "git.opnfv.org" not in parts[0]:
+ return None
+ if parts[-2] == "tree":
+ parts[-2] = "plain"
+ # now to download and parse file
+ url = "https://" + "/".join(parts)
+ info_file = requests.get(url, timeout=15).text
+ info_parsed = yaml.load(info_file)
+ ptl = info_parsed.get('project_lead')
+ if ptl:
+ project_leads.append(ptl)
+ sub_ptl = info_parsed.get("subproject_lead")
+ if sub_ptl:
+ project_leads.append(sub_ptl)
+
+ except Exception:
+ return None
+
+ return project_leads
+
+ def parse_url(self, info_url):
+ """
+ will return the PTL in the INFO file on success, or None
+ """
+ if "github" in info_url:
+ return self.parse_github_url(info_url)
+
+ if "gerrit.opnfv.org" in info_url:
+ return self.parse_gerrit_url(info_url)
+
+ if "git.opnfv.org" in info_url:
+ return self.parse_opnfv_git_url(info_url)
+
def booking_allowed(self, booking, repo):
"""
This is the method that will have to change whenever the booking policy changes in the Infra
diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py
index 712c92b..11386f9 100644
--- a/src/workflow/resource_bundle_workflow.py
+++ b/src/workflow/resource_bundle_workflow.py
@@ -131,9 +131,12 @@ class Define_Hardware(WorkflowStep):
try:
self.form = HardwareDefinitionForm(request.POST)
if self.form.is_valid():
- self.update_models(self.form.cleaned_data)
- self.update_confirmation()
- self.metastep.set_valid("Step Completed")
+ if len(json.loads(self.form.cleaned_data['filter_field']).labs) != 1:
+ self.metastep.set_invalid("Please select one lab")
+ else:
+ self.update_models(self.form.cleaned_data)
+ self.update_confirmation()
+ self.metastep.set_valid("Step Completed")
else:
self.metastep.set_invalid("Please complete the fields highlighted in red to continue")
pass