Commit 89bf2035 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add DB check to make sure the os image spec is valid (in the DB, and

appropriate for the node type). This prevents the user from editing
the IR file directly and specifying a bogus image ID.
parent 02f3b381
#!/usr/bin/perl -wT
use English;
# TODO: Database checks for valid OS image in IR file.
# Delta stuff.
# Reload disk images.
# Parse an IR file and determine what OS has been requested on each node.
# Do the database magic to make it so. Only root, admin types, or the
......@@ -118,6 +124,20 @@ while (<IN>) {
$row[1] ne "$eid") {
die("Node '$node' pid/eid mismatch: $pid/$eid ... $row[0]/$row[1]\n");
# Check to make sure that the OS spec is valid by checking the database.
# Cross check type from nodes table against image_ids for that type in
# the disk_images table.
$db_result = $DB->query("select disk_images.image_id from disk_images ".
"left join nodes ".
"on nodes.type=disk_images.type ".
"and disk_images.image_id='$os' ".
"where nodes.node_id='tbpc09'");
if ($db_result->numrows < 1) {
die("Improper image specification $node:$os in IR file.\n");
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