From 4311b0e115468b531f55b9309887327636c6df33 Mon Sep 17 00:00:00 2001
From: Leigh B Stoller <stoller@flux.utah.edu>
Date: Fri, 14 Mar 2025 13:32:43 -0600
Subject: [PATCH] Show def_boot_osid in the node list.

---
 www/aptui/show-nodetype.php           | 28 ++++++++++++++++++++++++++-
 www/aptui/template/show-nodetype.html |  8 ++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/www/aptui/show-nodetype.php b/www/aptui/show-nodetype.php
index fa9727e2d0..8b8f6ad255 100644
--- a/www/aptui/show-nodetype.php
+++ b/www/aptui/show-nodetype.php
@@ -27,6 +27,7 @@ $BOOTSTRAP5OK = true;
 chdir("..");
 include("defs.php3");
 include("node_defs.php");
+include_once("imageid_defs.php");
 chdir("apt");
 include("quickvm_sup.php");
 # Must be after quickvm_sup.php since it changes the auth domain.
@@ -157,7 +158,8 @@ else {
     # List of nodes for a table.
     #
     $nodes_result = DBQueryFatal("select n.node_id,r.pid,r.eid, ".
-                                 "    e.expt_head_uid as uid,e.expt_expires ".
+                                 "    e.expt_head_uid as uid,e.expt_expires, ".
+                                 "    n.def_boot_osid,n.def_boot_osid_vers ".
                                  "  from nodes as n ".
                                  "left join reserved as r on ".
                                  "     r.node_id=n.node_id ".
@@ -176,6 +178,30 @@ else {
             $blob["eid"] = $row["eid"];
             $blob["uid"] = $row["uid"];
             $blob["expires"] = DateStringGMT($row["expt_expires"]);
+            $blob["def_boot_image_url"] = null;            
+
+            if ($row["def_boot_osid"]) {
+                $osid  = $row["def_boot_osid"];
+                $vers  = $row["def_boot_osid_vers"];
+                $image = Image::Lookup($osid,$vers);
+                
+                if ($image) {
+                    $name = $image->imagename();
+                    $url  = "show-image.php?imageid=${osid}&version=${vers}";
+                }
+                else {
+                    $osinfo = OSInfo::Lookup($osid,$vers);
+                    if ($osinfo) {
+                        $url  = "$TBBASE/showosinfo.php3?osid=${osid}";
+                        $name = $osinfo->osname();
+                    }
+                }
+                if (isset($url)) {
+                    $blob["def_boot_image_url"]  = $url;
+                    $blob["def_boot_image_name"] = $name;
+                    $blob["def_boot_image_vers"] = $vers;
+                }
+            }
         }
         $list[] = $blob;
     }
diff --git a/www/aptui/template/show-nodetype.html b/www/aptui/template/show-nodetype.html
index b45c8eacf3..f0c01304c8 100644
--- a/www/aptui/template/show-nodetype.html
+++ b/www/aptui/template/show-nodetype.html
@@ -435,6 +435,7 @@
 		<th>Eid</th>
 		<th>User</th>
 		<th class="sorter-sugar" data-filter="false">Expires</th>
+		<th>Image</th>
 	      </tr>
 	    </thead>
 	    <tbody>
@@ -457,6 +458,13 @@
 		       target="_blank"><%- blob.uid %></a>
 		  </td>
 		  <td class="format-date"><%- blob.expires %></td>
+		  <td>
+		    <% if (blob.def_boot_image_url) { %>
+		      <a href="<%= blob.def_boot_image_url %>">
+			<%- blob.def_boot_image_name + ":" +
+			blob.def_boot_image_vers %></a>
+		    <% } %>
+		  </td>
 		</tr>
 	      <% }); %>
 	    </tbody>
-- 
GitLab