summaryrefslogtreecommitdiffstats
path: root/src/booking
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2019-04-09 16:30:57 -0400
committerParker Berberian <pberberian@iol.unh.edu>2019-05-03 11:48:22 -0400
commit04b676a8bc7209b8017395dc9bb36086283ac72c (patch)
tree381f48806f6e109784ca502f584865da72bcfe11 /src/booking
parentfec940b7b8d15099b8f914ce35552c59db9eb77b (diff)
Implement OPNFV workflow
This is a counterpart to an update to network models, and allows for configuring baremetal OPNFV and Openstack deploys Change-Id: I0185dbfa6c9105d7e63a7e7d7dd1f5cf228a8877 Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu> Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/booking')
-rw-r--r--src/booking/migrations/0006_booking_opnfv_config.py20
-rw-r--r--src/booking/models.py3
-rw-r--r--src/booking/quick_deployer.py64
3 files changed, 61 insertions, 26 deletions
diff --git a/src/booking/migrations/0006_booking_opnfv_config.py b/src/booking/migrations/0006_booking_opnfv_config.py
new file mode 100644
index 0000000..e5ffc71
--- /dev/null
+++ b/src/booking/migrations/0006_booking_opnfv_config.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.1 on 2019-05-01 18:02
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('resource_inventory', '0010_auto_20190430_1405'),
+ ('booking', '0005_booking_idf'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='booking',
+ name='opnfv_config',
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='resource_inventory.OPNFVConfig'),
+ ),
+ ]
diff --git a/src/booking/models.py b/src/booking/models.py
index 02e03cc..9836730 100644
--- a/src/booking/models.py
+++ b/src/booking/models.py
@@ -9,7 +9,7 @@
##############################################################################
-from resource_inventory.models import ResourceBundle, ConfigBundle
+from resource_inventory.models import ResourceBundle, ConfigBundle, OPNFVConfig
from account.models import Lab
from django.contrib.auth.models import User
from django.db import models
@@ -29,6 +29,7 @@ class Booking(models.Model):
ext_count = models.IntegerField(default=2)
resource = models.ForeignKey(ResourceBundle, on_delete=models.SET_NULL, null=True)
config_bundle = models.ForeignKey(ConfigBundle, on_delete=models.SET_NULL, null=True)
+ opnfv_config = models.ForeignKey(OPNFVConfig, on_delete=models.SET_NULL, null=True)
project = models.CharField(max_length=100, default="", blank=True, null=True)
lab = models.ForeignKey(Lab, null=True, on_delete=models.SET_NULL)
pdf = models.TextField(blank=True, default="")
diff --git a/src/booking/quick_deployer.py b/src/booking/quick_deployer.py
index 640ded9..763c8a0 100644
--- a/src/booking/quick_deployer.py
+++ b/src/booking/quick_deployer.py
@@ -32,7 +32,8 @@ from resource_inventory.models import (
OPNFVConfig,
Network,
NetworkConnection,
- NetworkRole
+ NetworkRole,
+ HostOPNFVConfig,
)
from resource_inventory.resource_manager import ResourceManager
from resource_inventory.pdf_templater import PDFTemplater
@@ -185,18 +186,30 @@ def generate_hostconfig(generic_host, image, config_bundle):
hconf = HostConfiguration()
hconf.host = generic_host
hconf.image = image
-
- opnfvrole = OPNFVRole.objects.get(name="Jumphost")
- if not opnfvrole:
- raise OPNFVRoleDNE("No jumphost role was found.")
-
- hconf.opnfvRole = opnfvrole
hconf.bundle = config_bundle
+ hconf.is_head_node = True
hconf.save()
return hconf
+def generate_hostopnfv(hostconfig, opnfvconfig):
+ config = HostOPNFVConfig()
+ role = None
+ try:
+ role = OPNFVRole.objects.get(name="Jumphost")
+ except Exception:
+ role = OPNFVRole.objects.create(
+ name="Jumphost",
+ description="Single server jumphost role"
+ )
+ config.role = role
+ config.host_config = hostconfig
+ config.opnfv_config = opnfvconfig
+ config.save()
+ return config
+
+
def generate_resource_bundle(generic_resource_bundle, config_bundle): # warning: requires cleanup
try:
resource_manager = ResourceManager.getInstance()
@@ -273,18 +286,16 @@ def create_from_form(form, request):
check_available_matching_host(lab, host_profile) # requires cleanup if failure after this point
grbundle = generate_grb(request.user, lab, quick_booking_id)
-
gresource = generate_gresource(grbundle, hostname)
-
ghost = generate_ghost(gresource, host_profile)
-
cbundle = generate_config_bundle(request.user, quick_booking_id, grbundle)
+ hconf = generate_hostconfig(ghost, image, cbundle)
# if no installer provided, just create blank host
+ opnfv_config = None
if installer:
- generate_opnfvconfig(scenario, installer, cbundle)
-
- generate_hostconfig(ghost, image, cbundle)
+ opnfv_config = generate_opnfvconfig(scenario, installer, cbundle)
+ generate_hostopnfv(hconf, opnfv_config)
# construct generic interfaces
for interface_profile in host_profile.interfaceprofile.all():
@@ -297,24 +308,27 @@ def create_from_form(form, request):
resource_bundle = generate_resource_bundle(grbundle, cbundle)
# generate booking
- booking = Booking()
- booking.purpose = purpose_field
- booking.project = project_field
- booking.lab = lab
- booking.owner = request.user
- booking.start = timezone.now()
- booking.end = timezone.now() + timedelta(days=int(length))
- booking.resource = resource_bundle
- booking.pdf = PDFTemplater.makePDF(booking.resource)
- booking.config_bundle = cbundle
- booking.save()
+ booking = Booking.objects.create(
+ purpose=purpose_field,
+ project=project_field,
+ lab=lab,
+ owner=request.user,
+ start=timezone.now(),
+ end=timezone.now() + timedelta(days=int(length)),
+ resource=resource_bundle,
+ config_bundle=cbundle,
+ opnfv_config=opnfv_config
+ )
+ booking.pdf = PDFTemplater.makePDF(booking)
+
users_field = users_field[2:-2]
if users_field: # may be empty after split, if no collaborators entered
users_field = json.loads(users_field)
for collaborator in users_field:
user = User.objects.get(id=collaborator['id'])
booking.collaborators.add(user)
- booking.save()
+
+ booking.save()
# generate job
JobFactory.makeCompleteJob(booking)