summaryrefslogtreecommitdiffstats
path: root/dashboard/src/resource_inventory/pdf_templater.py
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
commit8864dae63b9512835862aabbe7f288fbe3c661e0 (patch)
tree9a85c3f2759e2e6e6dd375b7a17c7d2e8331f05c /dashboard/src/resource_inventory/pdf_templater.py
parentd26781393ba3827b698e89573ace06ace4240f95 (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 'dashboard/src/resource_inventory/pdf_templater.py')
-rw-r--r--dashboard/src/resource_inventory/pdf_templater.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/dashboard/src/resource_inventory/pdf_templater.py b/dashboard/src/resource_inventory/pdf_templater.py
index 2db2129..d08b303 100644
--- a/dashboard/src/resource_inventory/pdf_templater.py
+++ b/dashboard/src/resource_inventory/pdf_templater.py
@@ -19,15 +19,15 @@ class PDFTemplater:
"""
@classmethod
- def makePDF(cls, resource):
+ def makePDF(cls, booking):
"""
fills the pod descriptor file template with info about the resource
"""
template = "dashboard/pdf.yaml"
info = {}
- info['details'] = cls.get_pdf_details(resource)
- info['jumphost'] = cls.get_pdf_jumphost(resource)
- info['nodes'] = cls.get_pdf_nodes(resource)
+ info['details'] = cls.get_pdf_details(booking.resource)
+ info['jumphost'] = cls.get_pdf_jumphost(booking)
+ info['nodes'] = cls.get_pdf_nodes(booking)
return render_to_string(template, context=info)
@@ -63,22 +63,40 @@ class PDFTemplater:
return details
@classmethod
- def get_pdf_jumphost(cls, resource):
+ def get_jumphost(cls, booking):
+ jumphost = None
+ if booking.opnfv_config:
+ jumphost_opnfv_config = booking.opnfv_config.host_opnfv_config.get(
+ role__name__iexact="jumphost"
+ )
+ jumphost = booking.resource.hosts.get(config=jumphost_opnfv_config.host_config)
+ else: # if there is no opnfv config, use headnode
+ jumphost = Host.objects.filter(
+ bundle=booking.resource,
+ config__is_head_node=True
+ ).first()
+
+ return jumphost
+
+ @classmethod
+ def get_pdf_jumphost(cls, booking):
"""
returns a dict of all the info for the "jumphost" section
"""
- jumphost = Host.objects.get(bundle=resource, config__opnfvRole__name__iexact="jumphost")
+ jumphost = cls.get_jumphost(booking)
jumphost_info = cls.get_pdf_host(jumphost)
jumphost_info['os'] = jumphost.config.image.os.name
return jumphost_info
@classmethod
- def get_pdf_nodes(cls, resource):
+ def get_pdf_nodes(cls, booking):
"""
returns a list of all the "nodes" (every host except jumphost)
"""
pdf_nodes = []
- nodes = Host.objects.filter(bundle=resource).exclude(config__opnfvRole__name__iexact="jumphost")
+ nodes = set(Host.objects.filter(bundle=booking.resource))
+ nodes.discard(cls.get_jumphost(booking))
+
for node in nodes:
pdf_nodes.append(cls.get_pdf_host(node))