Commit f162f8bb authored by Leigh Stoller's avatar Leigh Stoller

Add ReservableTypes() to Reservation library, us this in ptopgen to

generate a top level element in the emulab namespace that lists the
nodes that cat be reserved (physical node types with at least one
actual node in the database). Change portal_monitor to look for and
use this element when processing the advertisement.
parent 2da17106
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2016 University of Utah and the Flux Group.
# Copyright (c) 2008-2017 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -312,6 +312,24 @@ sub CheckAggregates()
$aggregate->status("up");
$aggregate->last_error("");
}
#
# Get the list of reservable types. Need to be backwards compat
# here until all clusters updated with this element. See below.
#
my $reservable_types;
if (my $ref = GeniXML::FindNodesNS("n:reservable_types",
$manifest,
$GeniXML::EMULAB_NS)->pop()) {
$reservable_types = {};
foreach my $t (GeniXML::FindNodesNS("n:type", $ref,
$GeniXML::EMULAB_NS)->get_nodelist()) {
my $typename = GeniXML::GetText("name", $t);
$reservable_types->{$typename} = $typename;
}
}
my $pcount = 0;
my $pavail = 0;
......@@ -338,13 +356,19 @@ sub CheckAggregates()
foreach my $htype (FindNodes("n:hardware_type",
$ref)->get_nodelist()) {
my $hname = GeniXML::GetText("name", $htype);
next
if (!defined($hname) || $hname eq "" ||
$hname eq "pcvm" || $hname eq "pc" ||
$hname =~ /^delay/ ||
# Protect DB.
$hname !~ /^[-\w]+$/);
if (defined($reservable_types)) {
next
if (!exists($reservable_types->{$hname}));
}
else {
# This can be deleted when clusters updated.
next
if (!defined($hname) || $hname eq "" ||
$hname eq "pcvm" || $hname eq "pc" ||
$hname =~ /^delay/ ||
# Protect DB.
$hname !~ /^[-\w]+$/);
}
my $ntype =
GeniXML::FindNodesNS("n:node_type",
$htype,
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2016 University of Utah and the Flux Group.
# Copyright (c) 2016-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -35,6 +35,7 @@ use Date::Parse;
use emdb;
use libtestbed;
use emutil;
use EmulabConstants;
use Project;
use User;
use Experiment;
......@@ -1042,5 +1043,40 @@ sub MaxSwapInMap($$) {
return \%counts;
}
#
# Reservable types for reservation system. Class Method.
#
sub ReservableTypes($)
{
my ($class) = @_;
my @result = ();
my @alltypes = NodeType->AllTypes();
foreach my $type (@alltypes) {
next
if ($type->class() ne "pc");
my $typename = $type->type();
#
# Skip if no physical testnodes of this type.
#
my $query_result =
DBQueryWarn("select count(node_id) from nodes ".
"where type='$typename' and ".
" role='" . $Node::NODEROLE_TESTNODE . "'");
return ()
if (!$query_result);
next
if (!$query_result->numrows);
my ($count) = $query_result->fetchrow_array();
next
if (!$count);
push(@result, $type);
}
return @result;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -218,6 +218,7 @@ use NodeType;
use Lan;
use BlockstoreType;
use User;
use Reservation;
tblog_stop_capture('stdout');
......@@ -2570,6 +2571,16 @@ sub print_header {
print "<location country='$default_country' ".
"longitude='$default_long' latitude='$default_lat'/>\n";
print "</site_info>\n";
#
# Reservable types for reservation system.
#
my @reservable = Reservation->ReservableTypes();
print "<emulab:reservable_types>";
foreach my $type (@reservable) {
my $typename = $type->type();
print "<emulab:type name='$typename' />";
}
print "</emulab:reservable_types>\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