aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2020-06-09 17:24:59 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-06-09 17:24:59 +0000
commitf96012fae9a106228ad80671a8c66476834a50db (patch)
tree530cb98a14268da5710b21b070b21e1428b8a5e9 /src
parent945bfa360ed4c30f8a9b684dd49441afeeb4c9c1 (diff)
parent1fec02fd0a4d7af8a89beb91d8d751a23e5086e0 (diff)
Merge "Allow not setting image for multi-node pods"
Diffstat (limited to 'src')
-rw-r--r--src/booking/forms.py2
-rw-r--r--src/booking/quick_deployer.py34
-rw-r--r--src/templates/akraino/booking/quick_deploy.html8
-rw-r--r--src/templates/base/booking/quick_deploy.html2
4 files changed, 31 insertions, 15 deletions
diff --git a/src/booking/forms.py b/src/booking/forms.py
index 886f0f6..2a8784f 100644
--- a/src/booking/forms.py
+++ b/src/booking/forms.py
@@ -36,7 +36,7 @@ class QuickBookingForm(forms.Form):
super(QuickBookingForm, self).__init__(data=data, **kwargs)
self.fields["image"] = forms.ModelChoiceField(
- Image.objects.filter(public=True) | Image.objects.filter(owner=user)
+ Image.objects.filter(public=True) | Image.objects.filter(owner=user), required=False
)
self.fields['users'] = SearchableSelectMultipleField(
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index 9cfc465..0d4e5ea 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -103,9 +103,13 @@ def update_template(old_template, image, hostname, user):
# there is never multiple networks anyway. This may have to change in the future
for old_config in old_template.getConfigs():
+ image_to_set = image
+ if not image:
+ image_to_set = old_config.image
+
config = ResourceConfiguration.objects.create(
profile=old_config.profile,
- image=image,
+ image=image_to_set,
template=template,
is_head_node=old_config.is_head_node
)
@@ -170,19 +174,21 @@ def check_invariants(request, **kwargs):
lab = kwargs['lab']
length = kwargs['length']
# check that image os is compatible with installer
- if installer in image.os.sup_installers.all():
- # if installer not here, we can omit that and not check for scenario
- if not scenario:
- raise ValidationError("An OPNFV Installer needs a scenario to be chosen to work properly")
- if scenario not in installer.sup_scenarios.all():
- raise ValidationError("The chosen installer does not support the chosen scenario")
- if image.from_lab != lab:
- raise ValidationError("The chosen image is not available at the chosen hosting lab")
- # TODO
- # if image.host_type != host_profile:
- # raise ValidationError("The chosen image is not available for the chosen host type")
- if not image.public and image.owner != request.user:
- raise ValidationError("You are not the owner of the chosen private image")
+ if image:
+ if installer or scenario:
+ if installer in image.os.sup_installers.all():
+ # if installer not here, we can omit that and not check for scenario
+ if not scenario:
+ raise ValidationError("An OPNFV Installer needs a scenario to be chosen to work properly")
+ if scenario not in installer.sup_scenarios.all():
+ raise ValidationError("The chosen installer does not support the chosen scenario")
+ if image.from_lab != lab:
+ raise ValidationError("The chosen image is not available at the chosen hosting lab")
+ # TODO
+ # if image.host_type != host_profile:
+ # raise ValidationError("The chosen image is not available for the chosen host type")
+ if not image.public and image.owner != request.user:
+ raise ValidationError("You are not the owner of the chosen private image")
if length < 1 or length > 21:
raise BookingLengthException("Booking must be between 1 and 21 days long")
diff --git a/src/templates/akraino/booking/quick_deploy.html b/src/templates/akraino/booking/quick_deploy.html
index 80354d9..af9b3d3 100644
--- a/src/templates/akraino/booking/quick_deploy.html
+++ b/src/templates/akraino/booking/quick_deploy.html
@@ -17,3 +17,11 @@
</div>
</div>
{% endblock collab %}
+
+{% block image_script %}
+ <script type="text/javascript">
+ document.getElementById("id_image").disabled = true;
+ document.getElementById("id_image").style.display = 'none';
+ document.getElementById("id_image").previousElementSibling.style.display = 'none';
+ </script>
+{% endblock image_script %}
diff --git a/src/templates/base/booking/quick_deploy.html b/src/templates/base/booking/quick_deploy.html
index 70b9869..e4b9431 100644
--- a/src/templates/base/booking/quick_deploy.html
+++ b/src/templates/base/booking/quick_deploy.html
@@ -55,6 +55,8 @@
</div>
</div>
</form>
+{% block image_script %}
+{% endblock image_script %}
<script type="text/javascript">
function submit_form()