From 31dc78ea35cf207cb88a4e0cba93c89bc7010886 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Tue, 19 Mar 2019 16:22:31 -0400 Subject: Add host detail view Change-Id: Ie385fe3f2fbe3b178f00928914d47a34b181d05e Signed-off-by: Sawyer Bergeron --- src/dashboard/views.py | 2 +- src/resource_inventory/urls.py | 5 +- src/resource_inventory/views.py | 17 +++- src/templates/dashboard/lab_detail.html | 2 + src/templates/resource/hostprofile_detail.html | 116 +++++++++++++++++++++++++ src/templates/resource/hosts.html | 2 +- 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 src/templates/resource/hostprofile_detail.html (limited to 'src') diff --git a/src/dashboard/views.py b/src/dashboard/views.py index c4a6685..aaad7ab 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -46,7 +46,7 @@ def lab_detail_view(request, lab_name): 'title': "Lab Overview", 'lab': lab, 'hostprofiles': lab.hostprofiles.all(), - 'images': images + 'images': images, } ) diff --git a/src/resource_inventory/urls.py b/src/resource_inventory/urls.py index 4e159ba..a72871b 100644 --- a/src/resource_inventory/urls.py +++ b/src/resource_inventory/urls.py @@ -25,10 +25,11 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url -from resource_inventory.views import HostView +from resource_inventory.views import HostView, hostprofile_detail_view app_name = "resource" urlpatterns = [ - url(r'^hosts$', HostView.as_view(), name='hosts') + url(r'^hosts$', HostView.as_view(), name='hosts'), + url(r'^profiles/(?P.+)/$', hostprofile_detail_view, name='host_detail'), ] diff --git a/src/resource_inventory/views.py b/src/resource_inventory/views.py index 2937bd7..8c3d899 100644 --- a/src/resource_inventory/views.py +++ b/src/resource_inventory/views.py @@ -9,8 +9,10 @@ from django.views.generic import TemplateView +from django.shortcuts import get_object_or_404 +from django.shortcuts import render -from resource_inventory.models import Host +from resource_inventory.models import HostProfile, Host class HostView(TemplateView): @@ -21,3 +23,16 @@ class HostView(TemplateView): hosts = Host.objects.filter(working=True) context.update({'hosts': hosts, 'title': "Hardware Resources"}) return context + + +def hostprofile_detail_view(request, hostprofile_id): + hostprofile = get_object_or_404(HostProfile, id=hostprofile_id) + + return render( + request, + "resource/hostprofile_detail.html", + { + 'title': "Host Type: " + str(hostprofile.name), + 'hostprofile': hostprofile + } + ) diff --git a/src/templates/dashboard/lab_detail.html b/src/templates/dashboard/lab_detail.html index a30ac9e..7d018ca 100644 --- a/src/templates/dashboard/lab_detail.html +++ b/src/templates/dashboard/lab_detail.html @@ -62,6 +62,8 @@ {{profile.name}} {{profile.description}} + {{profile.labs}} + Profile {% endfor %} diff --git a/src/templates/resource/hostprofile_detail.html b/src/templates/resource/hostprofile_detail.html new file mode 100644 index 0000000..0776b9e --- /dev/null +++ b/src/templates/resource/hostprofile_detail.html @@ -0,0 +1,116 @@ +{% extends "base.html" %} +{% load staticfiles %} + +{% block content %} +
+
+
+
+

Available at

+ Expand +
+
+ + + + +
+
    + {% for lab in hostprofile.labs.all %} +
  • {{lab.name}}
  • + {% endfor %} +
+
+
+
+
+
+

RAM

+ Expand +
+
+ + + + +
{{hostprofile.ramprofile.first.amount}}G, + {{hostprofile.ramprofile.first.channels}} channels
+
+
+
+
+

CPU

+ Expand +
+
+ + + + + + + + + + + + + +
Arch:{{hostprofile.cpuprofile.first.architecture}}
Cores:{{hostprofile.cpuprofile.first.cores}}
Sockets:{{hostprofile.cpuprofile.first.cpus}}
+
+
+
+
+
+
+

Interfaces

+ Expand +
+
+ + {% for intprof in hostprofile.interfaceprofile.all %} + + + + {% endfor %} +
+ + + + + + + + + +
Name:{{intprof.name}}
Speed:{{intprof.speed}}
+
+
+
+
+
+
+
+

Disk

+ Expand +
+
+ + + + + + + + + + + + + +
Size:{{hostprofile.storageprofile.first.size}} GiB
Type:{{hostprofile.storageprofile.first.media_type}}
Mount Point:{{hostprofile.storageprofile.first.name}}
+
+
+
+
+{% endblock content %} diff --git a/src/templates/resource/hosts.html b/src/templates/resource/hosts.html index 4bf64e0..69b7231 100644 --- a/src/templates/resource/hosts.html +++ b/src/templates/resource/hosts.html @@ -17,7 +17,7 @@ {{ host.name }} - {{ host.profile }} + {{ host.profile }} {{ host.booked }} -- cgit 1.2.3-korg