Commit 5acdd9ce authored by Leigh Stoller's avatar Leigh Stoller

Checkpoint image provenance/versioning.

parent 5aff2d89
...@@ -1308,36 +1308,49 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host, ...@@ -1308,36 +1308,49 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
if (imageid != NULL) { if (imageid != NULL) {
/* Interested in a specific image */ /* Interested in a specific image */
if (can_access(imageidx, ei, 1)) { if (can_access(imageidx, ei, 1)) {
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,"
" path,imageid" " i.imagename,v.path,i.imageid"
" FROM images WHERE" " FROM images as i "
" pid='%s'" " LEFT JOIN image_versions "
" AND imagename='%s'", " as v on "
" v.imageid=i.imageid and "
" v.version=i.version "
" WHERE i.pid='%s'"
" AND i.imagename='%s'",
5, wantpid, wantname); 5, wantpid, wantname);
} else { } else {
/* /*
* Pid of expt must be same as pid of image * Pid of expt must be same as pid of image
* and gid the same or image "shared". * and gid the same or image "shared".
*/ */
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,"
"path,imageid" " i.imagename,v.path,i.imageid"
" FROM images WHERE" " FROM images as i "
" pid='%s' AND imagename='%s'" " LEFT JOIN image_versions "
" AND pid='%s'" " as v on "
" AND (gid='%s' OR" " v.imageid=i.imageid and "
" (gid=pid AND shared=1))", " v.version=i.version "
" WHERE i.pid='%s' "
" AND i.imagename='%s'"
" AND i.pid='%s'"
" AND (i.gid='%s' OR"
" (i.gid=i.pid AND "
" v.shared=1))",
5, wantpid, wantname, 5, wantpid, wantname,
ei->pid, ei->gid); ei->pid, ei->gid);
} }
} else { } else {
/* Find all images that this pid/gid can PUT */ /* Find all images that this pid/gid can PUT */
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,i.imagename,"
"path,imageid" "v.path,i.imageid"
" FROM images" " FROM images as i"
" WHERE pid='%s'" " LEFT JOIN image_versions as v on "
" AND (gid='%s' OR" " v.imageid=i.imageid and "
" (gid=pid AND shared=1))" " v.version=i.version "
" ORDER BY pid,gid,imagename", " WHERE i.pid='%s'"
" AND (i.gid='%s' OR"
" (i.gid=i.pid AND v.shared=1))"
" ORDER BY i.pid,i.gid,i.imagename",
5, ei->pid, ei->gid); 5, ei->pid, ei->gid);
} }
assert(res != NULL); assert(res != NULL);
...@@ -1436,34 +1449,48 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host, ...@@ -1436,34 +1449,48 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
if (imageid != NULL) { if (imageid != NULL) {
/* Interested in a specific image */ /* Interested in a specific image */
if (can_access(imageidx, ei, 0)) { if (can_access(imageidx, ei, 0)) {
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,"
"path,imageid" "i.imagename,v.path,i.imageid"
" FROM images WHERE" " FROM images as i "
" pid='%s'" " LEFT JOIN image_versions "
" AND imagename='%s'", " as v on "
" v.imageid=i.imageid and "
" v.version=i.version "
"WHERE i.pid='%s'"
" AND i.imagename='%s'",
5, wantpid, wantname); 5, wantpid, wantname);
} else { } else {
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,"
"path,imageid" "i.imagename,v.path,i.imageid"
" FROM images WHERE" " FROM images as i"
" pid='%s' AND imagename='%s'" " LEFT JOIN image_versions "
" AND (global=1" " as v on "
" OR (pid='%s'" " v.imageid=i.imageid and "
" AND (gid='%s'" " v.version=i.version "
" OR shared=1)))" " WHERE i.pid='%s' "
" AND i.imagename='%s'"
" AND (v.global=1"
" OR (i.pid='%s'"
" AND (i.gid='%s'"
" OR v.shared=1)))"
" ORDER BY pid,gid,imagename", " ORDER BY pid,gid,imagename",
5, wantpid, wantname, 5, wantpid, wantname,
ei->pid, ei->gid); ei->pid, ei->gid);
} }
} else { } else {
/* Find all images that this pid/gid can GET */ /* Find all images that this pid/gid can GET */
res = mydb_query("SELECT pid,gid,imagename," res = mydb_query("SELECT i.pid,i.gid,i.imagename,"
"path,imageid" "v.path,i.imageid"
" FROM images WHERE" " FROM images as i"
" (global=1" " LEFT JOIN image_versions "
" OR (pid='%s'" " as v on "
" AND (gid='%s' OR shared=1)))" " v.imageid=i.imageid and "
" ORDER BY pid,gid,imagename", " v.version=i.version "
" WHERE"
" (v.global=1"
" OR (i.pid='%s'"
" AND (i.gid='%s' OR v.shared=1)))"
" ORDER BY i.pid,i.gid,i.imagename",
5, ei->pid, ei->gid); 5, ei->pid, ei->gid);
} }
assert(res != NULL); assert(res != NULL);
...@@ -1610,10 +1637,14 @@ dump_image_aliases(FILE *fd) ...@@ -1610,10 +1637,14 @@ dump_image_aliases(FILE *fd)
char *lastpid; char *lastpid;
/* First the global image alias */ /* First the global image alias */
res = mydb_query("SELECT pid,imagename" res = mydb_query("SELECT i.pid,i.imagename"
" FROM images" " FROM images as i"
" WHERE global=1" " LEFT JOIN image_versions "
" ORDER BY pid,imagename", 2); " as v on "
" v.imageid=i.imageid and "
" v.version=i.version "
" WHERE v.global=1"
" ORDER BY i.pid,i.imagename", 2);
assert(res != NULL); assert(res != NULL);
nrows = mysql_num_rows(res); nrows = mysql_num_rows(res);
...@@ -1662,10 +1693,14 @@ dump_image_aliases(FILE *fd) ...@@ -1662,10 +1693,14 @@ dump_image_aliases(FILE *fd)
free(lastpid); free(lastpid);
lastpid = mystrdup(row[0]); lastpid = mystrdup(row[0]);
res2 = mydb_query("SELECT imagename" res2 = mydb_query("SELECT i.imagename"
" FROM images" " FROM images as i"
" WHERE pid='%s' AND shared=1" " LEFT JOIN image_versions "
" ORDER BY imagename", " as v on "
" v.imageid=i.imageid and "
" v.version=i.version "
" WHERE i.pid='%s' AND v.shared=1"
" ORDER BY i.imagename",
1, lastpid); 1, lastpid);
assert(res2 != NULL); assert(res2 != NULL);
......
...@@ -659,6 +659,7 @@ TBOPSEMAIL ...@@ -659,6 +659,7 @@ TBOPSEMAIL
IPV6_SUBNET_PREFIX IPV6_SUBNET_PREFIX
IPV6_ENABLED IPV6_ENABLED
NFSMAPTOUSER NFSMAPTOUSER
IMAGEPROVENANCE
BROWSER_CONSOLE_ENABLE BROWSER_CONSOLE_ENABLE
EC2META_ENABLE EC2META_ENABLE
NOSITECHECKIN NOSITECHECKIN
...@@ -5091,6 +5092,7 @@ MANAGEMENT_NETWORK="10.249.249.0" ...@@ -5091,6 +5092,7 @@ MANAGEMENT_NETWORK="10.249.249.0"
MANAGEMENT_NETMASK="255.255.255.0" MANAGEMENT_NETMASK="255.255.255.0"
MANAGEMENT_ROUTER="10.249.249.253" MANAGEMENT_ROUTER="10.249.249.253"
NFSMAPTOUSER="root" NFSMAPTOUSER="root"
IMAGEPROVENANCE=0
# #
# XXX You really don't want to change these! # XXX You really don't want to change these!
......
...@@ -291,6 +291,7 @@ AC_SUBST(BROWSER_CONSOLE_ENABLE) ...@@ -291,6 +291,7 @@ AC_SUBST(BROWSER_CONSOLE_ENABLE)
AC_SUBST(IPV6_ENABLED) AC_SUBST(IPV6_ENABLED)
AC_SUBST(IPV6_SUBNET_PREFIX) AC_SUBST(IPV6_SUBNET_PREFIX)
AC_SUBST(NFSMAPTOUSER) AC_SUBST(NFSMAPTOUSER)
AC_SUBST(IMAGEPROVENANCE)
# #
# Offer both versions of the email addresses that have the @ escaped # Offer both versions of the email addresses that have the @ escaped
...@@ -433,6 +434,7 @@ MANAGEMENT_NETWORK="10.249.249.0" ...@@ -433,6 +434,7 @@ MANAGEMENT_NETWORK="10.249.249.0"
MANAGEMENT_NETMASK="255.255.255.0" MANAGEMENT_NETMASK="255.255.255.0"
MANAGEMENT_ROUTER="10.249.249.253" MANAGEMENT_ROUTER="10.249.249.253"
NFSMAPTOUSER="root" NFSMAPTOUSER="root"
IMAGEPROVENANCE=0
# #
# XXX You really don't want to change these! # XXX You really don't want to change these!
......
...@@ -193,10 +193,13 @@ $EXPT_RESOURCESHOSED = 0; ...@@ -193,10 +193,13 @@ $EXPT_RESOURCESHOSED = 0;
# These are slots in the node table that need to be restored. # These are slots in the node table that need to be restored.
@nodetable_fields = ("def_boot_osid", @nodetable_fields = ("def_boot_osid",
"def_boot_osid_vers",
"def_boot_path", "def_boot_path",
"def_boot_cmd_line", "def_boot_cmd_line",
"temp_boot_osid", "temp_boot_osid",
"temp_boot_osid_vers",
"next_boot_osid", "next_boot_osid",
"next_boot_osid_vers",
"next_boot_path", "next_boot_path",
"next_boot_cmd_line", "next_boot_cmd_line",
"pxe_boot_path", "pxe_boot_path",
...@@ -4506,12 +4509,14 @@ sub LinkTestCapable($$) ...@@ -4506,12 +4509,14 @@ sub LinkTestCapable($$)
my $idx = $self->idx(); my $idx = $self->idx();
my $query_result = my $query_result =
DBQueryWarn("select v.vname, FIND_IN_SET('linktest',osfeatures) ". DBQueryWarn("select v.vname, FIND_IN_SET('linktest',ov.osfeatures) ".
" from virt_nodes as v ". " from virt_nodes as v ".
"left join reserved as r on r.pid=v.pid and ". "left join reserved as r on r.pid=v.pid and ".
" r.eid=v.eid and r.vname=v.vname ". " r.eid=v.eid and r.vname=v.vname ".
"left join nodes as n on n.node_id=r.node_id ". "left join nodes as n on n.node_id=r.node_id ".
"left join os_info as o on o.osid=n.def_boot_osid ". "left join os_info_versions as ov on ".
" ov.osid=n.def_boot_osid and ".
" ov.vers=n.def_boot_osid_vers ".
"where v.exptidx='$idx' and v.role!='bridge'"); "where v.exptidx='$idx' and v.role!='bridge'");
return -1 return -1
if (!defined($query_result)); if (!defined($query_result));
......
This diff is collapsed.
...@@ -360,7 +360,7 @@ sub Create($$$$) ...@@ -360,7 +360,7 @@ sub Create($$$$)
{ {
my ($class, $node_id, $experiment, $argref) = @_; my ($class, $node_id, $experiment, $argref) = @_;
my ($control_iface,$virtnode_capacity,$adminmfs,$adminmfs_osid); my ($control_iface,$virtnode_capacity,$adminmfs,$adminmfs_osid);
my ($priority, $osid, $opmode, $state); my ($priority, $osid, $osid_vers, $opmode, $state);
require OSinfo; require OSinfo;
require NodeType; require NodeType;
...@@ -392,6 +392,7 @@ sub Create($$$$) ...@@ -392,6 +392,7 @@ sub Create($$$$)
if (!defined($typeinfo)); if (!defined($typeinfo));
my $isremote = $typeinfo->isremotenode(); my $isremote = $typeinfo->isremotenode();
$osid_vers = 0;
if ($role eq "testnode") { if ($role eq "testnode") {
if ($typeinfo->virtnode_capacity(\$virtnode_capacity)) { if ($typeinfo->virtnode_capacity(\$virtnode_capacity)) {
...@@ -416,6 +417,7 @@ sub Create($$$$) ...@@ -416,6 +417,7 @@ sub Create($$$$)
return undef; return undef;
} }
$osid = $osinfo->osid(); $osid = $osinfo->osid();
$osid_vers = $adminmfs->vers();
$opmode = $osinfo->op_mode(); $opmode = $osinfo->op_mode();
} }
} }
...@@ -437,6 +439,7 @@ sub Create($$$$) ...@@ -437,6 +439,7 @@ sub Create($$$$)
return undef; return undef;
} }
$osid = $adminmfs->osid(); $osid = $adminmfs->osid();
$osid_vers = $adminmfs->vers();
$opmode = $adminmfs->op_mode(); $opmode = $adminmfs->op_mode();
} }
} }
...@@ -486,7 +489,7 @@ sub Create($$$$) ...@@ -486,7 +489,7 @@ sub Create($$$$)
" phys_nodeid='$node_id', role='$role', ". " phys_nodeid='$node_id', role='$role', ".
" priority=$priority, " . " priority=$priority, " .
" eventstate='$state', op_mode='$opmode', " . " eventstate='$state', op_mode='$opmode', " .
" def_boot_osid=$osid, " . " def_boot_osid=$osid, def_boot_osid_vers='$osid_vers'" .
" inception=now(), uuid=$uuid, ". " inception=now(), uuid=$uuid, ".
" state_timestamp=unix_timestamp(NOW()), " . " state_timestamp=unix_timestamp(NOW()), " .
" op_mode_timestamp=unix_timestamp(NOW())")) { " op_mode_timestamp=unix_timestamp(NOW())")) {
...@@ -1687,6 +1690,7 @@ sub ClearBootAttributes($) ...@@ -1687,6 +1690,7 @@ sub ClearBootAttributes($)
"tarballs='',failureaction='fatal', routertype='none', ". "tarballs='',failureaction='fatal', routertype='none', ".
"def_boot_cmd_line='',next_boot_cmd_line='', ". "def_boot_cmd_line='',next_boot_cmd_line='', ".
"temp_boot_osid=NULL,next_boot_osid=NULL, ". "temp_boot_osid=NULL,next_boot_osid=NULL, ".
"temp_boot_osid_vers=0,next_boot_osid_vers=0, ".
"update_accounts=0,ipport_next=ipport_low,rtabid=0, ". "update_accounts=0,ipport_next=ipport_low,rtabid=0, ".
"sfshostid=NULL,allocstate='$allocFreeState',boot_errno=0, ". "sfshostid=NULL,allocstate='$allocFreeState',boot_errno=0, ".
"destination_x=NULL,destination_y=NULL, ". "destination_x=NULL,destination_y=NULL, ".
...@@ -2171,17 +2175,13 @@ sub CreateVnodes($$$) ...@@ -2171,17 +2175,13 @@ sub CreateVnodes($$$)
# table. # table.
# #
my $osid = $nodetype->default_osid(); my $osid = $nodetype->default_osid();
my $osinfo = OSinfo->Lookup($osid);
my $query_result = if (!defined($osinfo)) {
DBQueryWarn("select op_mode from os_info where osid='$osid'");
return -1
if (! $query_result);
if (! $query_result->numrows) {
print STDERR "*** CreateVnodes: No such OSID '$osid'\n"; print STDERR "*** CreateVnodes: No such OSID '$osid'\n";
return -1; return -1;
} }
my ($opmode) = $query_result->fetchrow_array(); my ($opmode) = $osinfo->op_mode();
my $osid_vers = $osinfo->vers();
# #
# Need IP for jailed nodes. # Need IP for jailed nodes.
...@@ -2426,6 +2426,7 @@ sub CreateVnodes($$$) ...@@ -2426,6 +2426,7 @@ sub CreateVnodes($$$)
"eventstate" => $eventstate, "eventstate" => $eventstate,
"allocstate" => $allocstate, "allocstate" => $allocstate,
"def_boot_osid" => $osid, "def_boot_osid" => $osid,
"def_boot_osid_vers" => $osid_vers,
"update_accounts" => 1, "update_accounts" => 1,
"jailflag" => $isjailed); "jailflag" => $isjailed);
...@@ -2759,6 +2760,8 @@ sub SetNodeHistory($$$$) ...@@ -2759,6 +2760,8 @@ sub SetNodeHistory($$$$)
# Set the scheduled_reloads for a node. Type is optional and defaults to # Set the scheduled_reloads for a node. Type is optional and defaults to
# testbed default load type. See above. # testbed default load type. See above.
# #
# No image version info; we always reload the most current image.
#
sub SetSchedReload($$;$) sub SetSchedReload($$;$)
{ {
my ($self, $imageid, $type) = @_; my ($self, $imageid, $type) = @_;
...@@ -3136,13 +3139,18 @@ sub OSSelect($$$$) ...@@ -3136,13 +3139,18 @@ sub OSSelect($$$$)
if (!defined($field)) { if (!defined($field)) {
# Clear all osids. # Clear all osids.
DBQueryWarn("update nodes set ". DBQueryWarn("update nodes set ".
"def_boot_osid=NULL,next_boot_osid=NULL,temp_boot_osid=NULL ". "def_boot_osid=NULL,next_boot_osid=NULL,".
"temp_boot_osid=NULL, ".
"def_boot_osid_vers=0,next_boot_osid_vers=0,".
"temp_boot_osid_vers=0 ".
"where node_id='$nodeid'") "where node_id='$nodeid'")
or return -1; or return -1;
} else { } else {
# Set/Clear the osid. # Set/Clear the osid.
DBQueryWarn("update nodes set ${field}=". my $osid = (defined($osinfo) ? "'" . $osinfo->osid() . "'" : "NULL");
(defined($osinfo) ? "'" . $osinfo->osid() . "' " : "NULL ") . my $vers = (defined($osinfo) ? "'" . $osinfo->vers() . "'" : "'0'");
DBQueryWarn("update nodes set ${field}=$osid,${field}_vers=$vers ".
"where node_id='$nodeid'") "where node_id='$nodeid'")
or return -1; or return -1;
...@@ -3353,13 +3361,19 @@ sub ClearOsids($) { ...@@ -3353,13 +3361,19 @@ sub ClearOsids($) {
DBQueryWarn("update nodes set ". DBQueryWarn("update nodes set ".
" def_boot_osid=NULL,". " def_boot_osid=NULL,".
" next_boot_osid=NULL,". " next_boot_osid=NULL,".
" temp_boot_osid=NULL ". " temp_boot_osid=NULL, ".
" def_boot_osid_vers=0,".
" next_boot_osid_vers=0,".
" temp_boot_osid_vers=0 ".
"where node_id='$node_id'") "where node_id='$node_id'")
or return -1; or return -1;
$self->{"DBROW"}{"def_boot_osid"} = undef; $self->{"DBROW"}{"def_boot_osid"} = undef;
$self->{"DBROW"}{"temp_boot_osid"} = undef; $self->{"DBROW"}{"temp_boot_osid"} = undef;
$self->{"DBROW"}{"next_boot_osid"} = undef; $self->{"DBROW"}{"next_boot_osid"} = undef;
$self->{"DBROW"}{"def_boot_osid_vers"} = 0;
$self->{"DBROW"}{"temp_boot_osid_vers"} = 0;
$self->{"DBROW"}{"next_boot_osid_vers"} = 0;
return 0; return 0;
} }
...@@ -3401,11 +3415,13 @@ sub IsOSLoaded($$) ...@@ -3401,11 +3415,13 @@ sub IsOSLoaded($$)
$osinfo = $tmp; $osinfo = $tmp;
} }
my $osid = $osinfo->osid(); my $osid = $osinfo->osid();
my $vers = $osinfo->vers();
my $nodeid = $self->node_id(); my $nodeid = $self->node_id();
my $query_result = my $query_result =
DBQueryWarn("select osid from partitions as p ". DBQueryWarn("select osid from partitions as p ".
"where p.node_id='$nodeid' and p.osid='$osid'"); "where p.node_id='$nodeid' and p.osid='$osid' and ".
" p.osid_vers='$vers'");
return -1 return -1
if (!$query_result); if (!$query_result);
...@@ -3683,9 +3699,10 @@ sub RunningOsImage($) ...@@ -3683,9 +3699,10 @@ sub RunningOsImage($)
my ($self) = @_; my ($self) = @_;
my $nodeid = $self->node_id(); my $nodeid = $self->node_id();
my $osid = $self->def_boot_osid(); my $osid = $self->def_boot_osid();
my $imageid; my $vers = $self->def_boot_osid_vers();
my $image;
my $osinfo = OSinfo->Lookup($osid); my $osinfo = OSinfo->Lookup($osid, $vers);
return () return ()
if (!defined($osinfo)); if (!defined($osinfo));
...@@ -3693,19 +3710,19 @@ sub RunningOsImage($) ...@@ -3693,19 +3710,19 @@ sub RunningOsImage($)
# No partition entries for virtnodes, they are plain EZ images. # No partition entries for virtnodes, they are plain EZ images.
# #
if ($self->isvirtnode()) { if ($self->isvirtnode()) {
$imageid = $osid; # XXX No version info, need that.
$image = Image->Lookup($osid, $vers);
} }
else { else {
my $query_result = my $query_result =
DBQueryWarn("select imageid from partitions as p ". DBQueryWarn("select imageid,imageid_version from partitions as p ".
"where p.node_id='$nodeid' and p.osid='$osid'"); "where p.node_id='$nodeid' and p.osid='$osid'");
return () return ()
if (!$query_result || !$query_result->numrows); if (!$query_result || !$query_result->numrows);
($imageid) = $query_result->fetchrow_array(); my ($imageid,$version) = $query_result->fetchrow_array();
$image = Image->Lookup($imageid, $version);
} }
# This might not exist for a virtnode; caller has to deal with it.
my $image = Image->Lookup($imageid);
return ($osinfo, $image); return ($osinfo, $image);
} }
...@@ -3836,14 +3853,14 @@ sub SyncTaintStates($) ...@@ -3836,14 +3853,14 @@ sub SyncTaintStates($)
my $node_id = $self->node_id(); my $node_id = $self->node_id();
my $query_result = my $query_result =
DBQueryWarn("select osid from partitions ". DBQueryWarn("select osid,osid_vers from partitions ".
"where node_id='$node_id' and osid is not null"); "where node_id='$node_id' and osid is not null");
return -1 return -1
if (!$query_result); if (!$query_result);
my @taint_states = (); my @taint_states = ();
while (my ($osid) = $query_result->fetchrow_array()) { while (my ($osid, $vers) = $query_result->fetchrow_array()) {
my $osinfo = OSinfo->Lookup($osid); my $osinfo = OSinfo->Lookup($osid, $vers);
if (defined($osinfo) && $osinfo->IsTainted()) { if (defined($osinfo) && $osinfo->IsTainted()) {
push @taint_states, $osinfo->GetTaintStates(); push @taint_states, $osinfo->GetTaintStates();
} }
......
This diff is collapsed.
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2012 University of Utah and the Flux Group. # Copyright (c) 2000-2014 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -464,13 +464,19 @@ sub TBBootWhat($;$) ...@@ -464,13 +464,19 @@ sub TBBootWhat($;$)
# ALWAYS find exactly the same resulting OSID given the same inputs. # ALWAYS find exactly the same resulting OSID given the same inputs.
# #
my $query_result = my $query_result =
DBQueryWarn("select def_boot_osid, odef.op_mode, ". DBQueryWarn("select def_boot_osid, vdef.op_mode, ".
" temp_boot_osid, otemp.op_mode, ". " temp_boot_osid, vtemp.op_mode, ".
" next_boot_osid, onext.op_mode ". " next_boot_osid, vnext.op_mode ".
"from nodes as n ". "from nodes as n ".
"left join os_info as odef on odef.osid=def_boot_osid ". "left join os_info as odef on odef.osid=def_boot_osid ".
"left join os_info_versions as vdef on ".
" vdef.osid=odef.osid and vdef.vers=odef.version ".
"left join os_info as otemp on otemp.osid=temp_boot_osid ". "left join os_info as otemp on otemp.osid=temp_boot_osid ".
"left join os_info_versions as vtemp on ".
" vtemp.osid=otemp.osid and vtemp.vers=otemp.version ".
"left join os_info as onext on onext.osid=next_boot_osid ". "left join os_info as onext on onext.osid=next_boot_osid ".
"left join os_info_versions as vnext on ".
" vnext.osid=onext.osid and vnext.vers=onext.version ".
"where node_id='$node'"); "where node_id='$node'");
if (!$query_result || !$query_result->numrows) { if (!$query_result || !$query_result->numrows) {
...@@ -583,28 +589,6 @@ sub DefaultImageID ($$) { ...@@ -583,28 +589,6 @@ sub DefaultImageID ($$) {
return 1; return 1;
} }
#
# Convert user pid/name to internal imageid.
#
# usage: TBImageID(char *pid, char *imagename)
# returns imageid if its valid.
# returns 0 if not valid.
#
sub TBImageID ($$) {
my($pid, $imagename) = @_;
my $query_result =
DBQueryFatal("select imageid from images ".
"where pid='$pid' and imagename='$imagename'");
if (! $query_result->num_rows) {
return 0;
}
my @row = $query_result->fetchrow_array();
return $row[0];
}
# #
# Convert user pid/name to internal osid. # Convert user pid/name to internal osid.
# #
...@@ -770,8 +754,12 @@ sub TBImageLoadMaxOkay($$;@) ...@@ -770,8 +754,12 @@ sub TBImageLoadMaxOkay($$;@)
my($imageid,$node_count,@nodes) = @_; my($imageid,$node_count,@nodes) = @_;
my $query_result = DBQueryFatal("select part1_osid, part2_osid, " . my $query_result =
"part3_osid, part4_osid from images where imageid='$imageid'"); DBQueryFatal("select v.part1_osid, v.part2_osid, " .
" v.part3_osid, v.part4_osid from images as i ".
"left join image_versions as v on ".
" v.imageid=i.imageid and v.version=i.version ".
"where i.imageid='$imageid'");
if ($query_result->num_rows() != 1) { if ($query_result->num_rows() != 1) {
# #
...@@ -2408,17 +2396,17 @@ sub MapNumericUID($) ...@@ -2408,17 +2396,17 @@ sub MapNumericUID($)
sub MapNodeOSID($$) sub MapNodeOSID($$)
{ {
my ($node, $osid) = @_; my ($node, $osid) = @_;
require OSinfo;
# #
# See if this OSID is actually loaded on the machine. # See if this OSID is actually loaded on the machine.
# #
my $p_result = my $p_result =
DBQueryWarn("select * from partitions ". DBQueryWarn("select osid_vers from partitions ".
"where node_id='$node' and osid='$osid'"); "where node_id='$node' and osid='$osid'");
if (!$p_result) { if (!$p_result) {
return 0; return 0;
} }
if ($p_result->numrows) { if ($p_result->numrows) {
return $osid; return $osid;
} }
...@@ -2426,39 +2414,35 @@ sub MapNodeOSID($$) ...@@ -2426,39 +2414,35 @@ sub MapNodeOSID($$)
# #
# Get OSID info. # Get OSID info.
# #
my $osid_result = my ($vers) = $p_result->fetchrow_array();
DBQueryWarn("select * from os_info where osid='$osid'"); my $osinfo = OSinfo->Lookup($osid, $vers);
return 0
if (!$osid_result || $osid_result->numrows == 0) { if (!defined($osinfo));
return 0;
}
my %osid_row = $osid_result->fetchhash();
# #
# If its a specific Version, and its not loaded on the machine, # If its a specific Version, and its not loaded on the machine,
# nothing to do. # nothing to do.
# #
if (defined($osid_row{'version'}) && $osid_row{'version'} ne "") { return 0