Commit 99a462a8 authored by Mike Hibler's avatar Mike Hibler

Add a node-default pxe_boot_path to go along with node-type-default.

As if things weren't hairy enough for the pxe_boot_path, we need a per-node
default value. This should not be confused with the next_pxe_boot_path or
pxe_boot_path fields in the nodes table, which is a per-node value but only
for the lifetime of the current experiment.

We need this new field specifically so that we can switch some, but not all,
of the d710s over to the TPM-aware pxeboot.

For the record, the select order for setting the filename field in
dhcpd.conf is:

 1. nodes.next_pxe_boot_path for node
 2. nodes.pxe_boot_path for node
 3. "pxe_boot_path" node_attribute for node
 4. "pxe_boot_path" node_type_attribute for node type
 5. don't set (i.e., use the dhcpd.conf global default).
parent 77918217
......@@ -1517,6 +1517,17 @@ sub default_imageid($;$) {
return NodeTypeInfo($self)->default_imageid($stuff);
}
sub default_pxeboot($) {
my ($self) = @_;
my $val = undef;
if (NodeAttribute($self, "pxe_boot_path", \$val) == 0 && defined($val)) {
return $val;
}
return NodeTypeAttribute($self, "pxe_boot_path", undef);
}
#
# And these are the less common attributes, but still common enough to
# warrant shortcuts.
......
......@@ -45,7 +45,7 @@ $| = 1;
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use NodeType;
use Node;
#
# PXE boot constants
......@@ -314,11 +314,13 @@ while (<IF>) {
#
# Handle alternate boot program filename if it exists.
# Use mutable nodes.next_pxe_boot_path or
# nodes.pxe_boot_path if one is defined.
# Otherwise use the node_types.pxe_boot_path if it is
# defined. Otherwise don't set anything (use the global
# default).
# Order is:
#
# 1. nodes.next_pxe_boot_path for node
# 2. nodes.pxe_boot_path for node
# 3. "pxe_boot_path" node_attribute for node
# 4. "pxe_boot_path" node_type_attribute for node type
# 5. don't set (i.e., use the dhcpd.conf global default).
#
my $pxeboot = $row{"next_pxe_boot_path"};
if (!$pxeboot) {
......@@ -326,20 +328,13 @@ while (<IF>) {
}
$filename = SetupPXEBoot($node_id, $mac, 1, $pxeboot);
if (!$filename) {
# Get the type info for this type.
my $nodetype = NodeType->Lookup($row{"type"});
if (!$nodetype) {
fatal("Could not find type info for $node_id");
# Get the node or node type default
my $nobj = Node->Lookup($node_id);
if (!$nobj) {
fatal("Could not find Node info for $node_id");
}
# Get the type specific version of pxe_boot_path
my $nt_pxe_boot_path;
$nodetype->pxe_boot_path(\$nt_pxe_boot_path) == 0
or fatal("Could not get pxe_boot_path for ".
"$node_id");
$filename = SetupPXEBoot($node_id, $mac, 0,
$nt_pxe_boot_path);
my $path = $nobj->default_pxeboot();
$filename = SetupPXEBoot($node_id, $mac, 0, $path);
}
if ($filename) {
$filename = "${spaces}\tfilename \"$filename\";\n";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -152,8 +152,11 @@ foreach my $node (@nodes) {
my $npb = $nodeobject->next_pxe_boot_path();
my $pb = $nodeobject->pxe_boot_path();
if (!$pb) {
$nodeobject->NodeTypeAttribute("pxe_boot_path", \$pb);
if ($pb) {
if (!$nodeobject->NodeAttribute("pxe_boot_path", \$pb) &&
defined($pb)) {
$pb = "$pb (NODE DEFAULT)";
} elsif (!$nodeobject->NodeTypeAttribute("pxe_boot_path", \$pb) &&
defined($pb)) {
$pb = "$pb (NODE TYPE DEFAULT)";
} else {
$pb = "/tftpboot/pxeboot.emu (SYSTEM DEFAULT)";
......
......@@ -9442,6 +9442,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
if (rc < 0) {
error("dodhcpdconf: error creating output\n");
mysql_free_result(res);
return 1;
}
......@@ -9467,6 +9468,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
error("dodhcpconf: %s: "
"DB Error getting experiment info for %s:%s\n",
row[6], row[5]);
mysql_free_result(res);
return 1;
}
......@@ -9492,6 +9494,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
error("dodhcpconf: %s: "
"DB Error getting experiment info for %s:%s\n",
row[6], row[5]);
mysql_free_result(res);
return 1;
}
......@@ -9513,6 +9516,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
error("dodhcpconf: %s: "
"DB Error getting subbosses for %s\n",
row[0]);
mysql_free_result(res);
return 1;
}
......@@ -9533,6 +9537,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
if (rc < 0) {
error("dodhcpdconf: error creating output\n");
mysql_free_result(res);
return 1;
}
......@@ -9573,6 +9578,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
if (rc < 0) {
error("dodhcpdconf: error creating output\n");
mysql_free_result(res);
return 1;
}
......@@ -9583,6 +9589,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
if (rc < 0) {
error("dodhcpdconf: error creating output\n");
mysql_free_result(res);
return 1;
}
......@@ -9590,13 +9597,22 @@ COMMAND_PROTOTYPE(dodhcpdconf)
remain -= rc;
} else {
MYSQL_ROW row2;
res2 = mydb_query("select attrvalue from node_type_attributes where "
"attrkey = 'pxe_boot_path' and type = '%s'", 1, row[4]);
/* See if there is a default value for the node */
res2 = mydb_query("select attrvalue from node_attributes where "
"attrkey = 'pxe_boot_path' and node_id = '%s'", 1, row[0]);
if (res2 && (int)mysql_num_rows(res2) == 0) {
/* or for the node type */
mysql_free_result(res2);
res2 = mydb_query("select attrvalue from node_type_attributes where "
"attrkey = 'pxe_boot_path' and type = '%s'", 1, row[4]);
}
if (!res2) {
error("dodhcpconf: %s: "
"DB Error getting pxe_boot_path for %s\n",
"DB Error getting pxe_boot_path from attributes for %s\n",
row[0]);
mysql_free_result(res);
return 1;
}
......@@ -9605,12 +9621,14 @@ COMMAND_PROTOTYPE(dodhcpdconf)
row2 = mysql_fetch_row(res2);
rc = 0;
if (row2[0]!= NULL) {
if (row2[0] != NULL) {
rc = snprintf(b, remain, " FILENAME=\"%s\"", row2[0]);
}
if (rc < 0) {
error("dodhcpdconf: error creating output\n");
mysql_free_result(res2);
mysql_free_result(res);
return 1;
}
......
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