aboutsummaryrefslogtreecommitdiffstats
path: root/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
commit04b676a8bc7209b8017395dc9bb36086283ac72c (patch)
tree381f48806f6e109784ca502f584865da72bcfe11 /src/resource_inventory/pdf_templater.py
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/resource_inventory/pdf_templater.py')
-rw-r--r--src/resource_inventory/pdf_templater.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/resource_inventory/pdf_templater.py b/src/resource_inventory/pdf_templater.py
index 2db2129..d08b303 100644
--- a/src/resource_inventory/pdf_templater.py
+++ b/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))