Commit b8108ba9 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add IsGeneric() predicate (version not set).

Add MapToImage() which maps an osinfo to a specific image for a node
type.

Both of these are used in os_setup.
parent fd8d1b13
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2007-2009 University of Utah and the Flux Group. # Copyright (c) 2007-2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
package OSinfo; package OSinfo;
...@@ -19,6 +19,7 @@ use libdb; ...@@ -19,6 +19,7 @@ use libdb;
use libtestbed; use libtestbed;
use Project; use Project;
use User; use User;
use Image;
use English; use English;
use Data::Dumper; use Data::Dumper;
use overload ('""' => 'Stringify'); use overload ('""' => 'Stringify');
...@@ -433,6 +434,17 @@ sub ValidOpMode($$) ...@@ -433,6 +434,17 @@ sub ValidOpMode($$)
return (exists($OPMODES{$opmode}) ? 1 : 0); return (exists($OPMODES{$opmode}) ? 1 : 0);
} }
#
# Is the osinfo "generic"
#
sub IsGeneric($)
{
my ($self) = @_;
my $version = $self->version();
return ((defined($version) && $version ne "") ? 0 : 1);
}
# #
# Boot command like. The caller supplies the default in $pref. # Boot command like. The caller supplies the default in $pref.
# #
...@@ -618,5 +630,28 @@ sub RunsOnParent($$) ...@@ -618,5 +630,28 @@ sub RunsOnParent($$)
return 1; return 1;
} }
#
# Map an osinfo and node type to the actual image.
#
sub MapToImage($$)
{
my ($self, $type) = @_;
if (ref($type)) {
$type = $type->type();
}
my $osid = $self->osid();
my $query_result =
DBQueryWarn("select imageid from osidtoimageid ".
"where type='$type' and osid='$osid'");
return undef
if (!defined($query_result) || !$query_result->numrows);
my ($imageid) = $query_result->fetchrow_array();
return Image->Lookup($imageid);
}
# _Always_ make sure that this 1 is at the end of the file... # _Always_ make sure that this 1 is at the end of the file...
1; 1;
Supports Markdown
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