Commit 65b23583 authored by Jonathon Duerig's avatar Jonathon Duerig

Filter out no-usb-boot osids for nodes which boot from a usb stick.

parent f166e33e
......@@ -411,6 +411,15 @@ while (my ($class,$type,$isvirt) = $result->fetchrow_array) {
$permissions{$type} = 1;
}
# Figure out which nodes will use a USB dongle to boot. As a proxy, we
# look for the pxe_boot_path pointing to the tpm version of grub.
our %node_usb;
$result = DBQueryFatal("select node_id from node_attributes where attrkey='pxe_boot_path' and attrvalue='/tftpboot/pxeboot_tpm'");
while (($node) = $result->fetchrow_array) {
$node_usb{$node} = 1;
}
# Read node_startloc
$result = DBQueryFatal("select node_id,building from node_startloc");
while (($node,$building) = $result->fetchrow_array) {
......@@ -490,7 +499,7 @@ if (defined($pid)) {
# 1) To avoid an explosion in the number of features for nodes
# 2) To avoid information leaks, allowing projects to see each other's images
#
my $osidquery = "select distinct o.osid, oi.type, o.osname, o.pid, o.OS, o.version, o.description,o.protogeni_export from os_info as o " .
my $osidquery = "select distinct o.osid, oi.type, o.osname, o.pid, o.OS, o.version, o.description,o.protogeni_export, o.osfeatures from os_info as o " .
"left join osidtoimageid as oi on o.osid = oi.osid " .
"left join images as i on oi.imageid = i.imageid ";
if ($pid) {
......@@ -503,7 +512,7 @@ if ($pid) {
" or (g.pid is not null and g.pid='$pid')";
}
my $defaultosidquery = 'select distinct o.osid, t.type, o.osname, o.pid, o.OS, o.version, o.description, o.protogeni_export '.
my $defaultosidquery = 'select distinct o.osid, t.type, o.osname, o.pid, o.OS, o.version, o.description, o.protogeni_export, o.osfeatures '.
'from os_info as o left join node_type_attributes as t '.
'on (o.osid=t.attrvalue) where t.attrkey="default_osid"';
......@@ -534,6 +543,7 @@ our %osid_pid;
our %osid_os;
our %osid_version;
our %osid_description;
our %osid_avoid_usb;
our %node_countries;
our %node_latitudes;
our %node_longitudes;
......@@ -547,8 +557,8 @@ processOs($result);
sub processOs
{
my $result = shift(@_);
while (my ($osid,$type,$osname,$ospid,$osos,
$osversion,$osdescription,$geni) = $result->fetchrow()) {
while (my ($osid,$type,$osname,$ospid,$osos, $osversion,
$osdescription,$geni,$osfeatures) = $result->fetchrow()) {
if ($typemap{$type}) {
my $default = $typemap{$type}->{'OSID'};
if ($geni eq 1 ||
......@@ -566,6 +576,9 @@ sub processOs
} else {
$node_type_osids{$type} = [$osid];
}
if (defined($osfeatures) && $osfeatures =~ /no-usb-boot/) {
$osid_avoid_usb{$osid} = 1;
}
#
# We have to maintain a data structure telling us which types an OSID could
# be on for use below with generic OSIDs
......@@ -1074,9 +1087,11 @@ foreach $node (@nodenames) {
# evidenced by its type) can support
#
foreach my $o1 (@{$node_type_osids{$type}}) {
push @features, "OS-$o1:0";
foreach my $o2 (@{$osid_subosids{$o1}}) {
push @features, "OS-$o1-$o2:0";
if (! exists($node_usb{$node}) || ! exists($osid_avoid_usb{$o1})) {
push @features, "OS-$o1:0";
foreach my $o2 (@{$osid_subosids{$o1}}) {
push @features, "OS-$o1-$o2:0";
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment