aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'src/workflow')
-rw-r--r--src/workflow/models.py91
-rw-r--r--src/workflow/resource_bundle_workflow.py9
2 files changed, 89 insertions, 11 deletions
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 66b1739..495ce07 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -27,13 +27,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
@@ -48,13 +46,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
- return ptl
+ if "gerrit.opnfv.org" not in parts[0]:
+ return None
+ # 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
@@ -485,6 +554,12 @@ class Repository():
booking.collaborators.add(collaborator)
try:
+ booking.pdf = ResourceManager().makePDF(booking.resource)
+ booking.save()
+ except Exception as e:
+ return "BOOK, failed to create Pod Desriptor File: " + str(e)
+
+ try:
JobFactory.makeCompleteJob(booking)
except Exception as e:
return "BOOK, serializing for api generated exception: " + str(e) + " CODE:0xFFFF"
diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py
index 712c92b..4858ebe 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