aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'src/workflow')
-rw-r--r--src/workflow/forms.py15
-rw-r--r--src/workflow/models.py2
2 files changed, 14 insertions, 3 deletions
diff --git a/src/workflow/forms.py b/src/workflow/forms.py
index 4220dea..9b56f93 100644
--- a/src/workflow/forms.py
+++ b/src/workflow/forms.py
@@ -1,5 +1,6 @@
##############################################################################
# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others.
+# Copyright (c) 2020 Sawyer Bergeron, Sean Smith, and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -22,7 +23,7 @@ from account.models import UserProfile
from resource_inventory.models import (
OPNFVRole,
Installer,
- Scenario,
+ Scenario
)
from resource_inventory.resource_manager import ResourceManager
from booking.lib import get_user_items, get_user_field_opts
@@ -314,8 +315,10 @@ class FormUtils:
'selectable': true,
'follow': multiple_hosts,
'multiple': false,
- 'class': 'lab'
+ 'class': 'lab',
+ 'available_resources': json.dumps(lab.get_available_resources())
}
+
items[lab_node['id']] = lab_node
neighbors[lab_node['id']] = []
labs[lab_node['id']] = lab_node
@@ -331,14 +334,19 @@ class FormUtils:
'selectable': true,
'follow': false,
'multiple': multiple_hosts,
- 'class': 'resource'
+ 'class': 'resource',
+ 'required_resources': json.dumps(template.get_required_resources())
}
+
if multiple_hosts:
resource_node['values'] = [] # place to store multiple values
+
items[resource_node['id']] = resource_node
neighbors[lab_node['id']].append(resource_node['id'])
+
if resource_node['id'] not in neighbors:
neighbors[resource_node['id']] = []
+
neighbors[resource_node['id']].append(lab_node['id'])
resources[resource_node['id']] = resource_node
@@ -349,6 +357,7 @@ class FormUtils:
'neighbors': neighbors,
'filter_items': items
}
+
return context
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 4a5616e..f550a38 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -11,6 +11,7 @@
from django.template.loader import get_template
from django.http import HttpResponse
from django.utils import timezone
+from django.db import transaction
import yaml
import requests
@@ -559,6 +560,7 @@ class Repository():
self.el[self.RESULT] = bundle
return False
+ @transaction.atomic # TODO: Rewrite transactions with savepoints at user level for all workflows
def make_booking(self):
models = self.el[self.BOOKING_MODELS]
owner = self.el[self.SESSION_USER]