Commit c5f973ca authored by Leigh Stoller's avatar Leigh Stoller

Add hardware attribute info (cores,memory,disksize,etc) to the

reservable types emulab extension, and record that in the portal,
new DBf table apt_aggregate_nodetype_attributes.
parent 59b7b1d8
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2018 University of Utah and the Flux Group.
# Copyright (c) 2008-2019 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -279,7 +279,27 @@ sub CheckAggregates()
foreach my $t (GeniXML::FindNodesNS("n:type", $ref,
$GeniXML::EMULAB_NS)->get_nodelist()) {
my $typename = GeniXML::GetText("name", $t);
$reservable_types->{$typename} = $typename;
if ($typename !~ /^[-\w]+$/) {
print STDERR "Bad type name at $nickname: $typename\n";
next;
}
$reservable_types->{$typename} = {};
#
# Look for attributes that need to be stored.
#
foreach my $a (GeniXML::FindNodesNS("n:attribute", $t,
$GeniXML::EMULAB_NS)->get_nodelist()) {
my $attrkey = GeniXML::GetText("name", $a);
my $attrval = GeniXML::GetText("value", $a);
if ($attrkey !~ /^[-\w]+$/) {
print STDERR "Bad type attrkey name at $nickname: ".
"$typename,$attrkey\n";
next;
}
$reservable_types->{$typename}->{$attrkey} = $attrval;
}
}
}
......@@ -400,6 +420,15 @@ sub CheckAggregates()
DBQueryWarn("replace into apt_aggregate_nodetypes set ".
" urn='$urn',type='$type',".
" count='$count',free='$avail'");
foreach my $attrkey (keys(%{$reservable_types->{$type}})) {
my $attrval = $reservable_types->{$type}->{$attrkey};
my $safeval = DBQuoteSpecial($attrval);
DBQueryWarn("replace into apt_aggregate_nodetype_attributes ".
" set urn='$urn',type='$type',".
" attrkey='$attrkey',attrvalue=$safeval");
}
}
}
if (!$impotent) {
......
......@@ -117,6 +117,7 @@ sub issimnode($) { return field($_[0], 'issimnode'); }
sub isgeninode($) { return field($_[0], 'isgeninode'); }
sub isfednode($) { return field($_[0], 'isfednode'); }
sub isswitch($) { return field($_[0], 'isswitch'); }
sub attributes($) { return $_[0]->{'ATTRS'}; }
#
# Force a reload of the data.
......
......@@ -90,6 +90,19 @@ CREATE TABLE `apt_aggregate_nodetypes` (
PRIMARY KEY (`urn`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `apt_aggregate_nodetype_attributes`
--
DROP TABLE IF EXISTS `apt_aggregate_nodetype_attributes`;
CREATE TABLE `apt_aggregate_nodetype_attributes` (
`urn` varchar(128) NOT NULL default '',
`type` varchar(30) NOT NULL default '',
`attrkey` varchar(32) NOT NULL default '',
`attrvalue` tinytext NOT NULL,
PRIMARY KEY (`urn`,`type`,`attrkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `apt_aggregates_status_events`
--
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBTableExists("apt_aggregate_nodetype_attributes")) {
DBQueryFatal("CREATE TABLE `apt_aggregate_nodetype_attributes` ( ".
" `urn` varchar(128) NOT NULL default '', ".
" `type` varchar(30) NOT NULL default '', ".
" `attrkey` varchar(32) NOT NULL default '', ".
" `attrvalue` tinytext NOT NULL, ".
" PRIMARY KEY (`urn`,`type`,`attrkey`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
......@@ -2611,10 +2611,26 @@ sub print_header {
# Reservable types for reservation system.
#
my @reservable = Reservation->ReservableTypes();
print "<emulab:reservable_types>";
print "<emulab:reservable_types>\n";
foreach my $type (@reservable) {
my $typename = $type->type();
print "<emulab:type name='$typename' />";
my $typename = $type->type();
$type->LoadAttributes();
my %attributes = %{$type->attributes()};
print "<emulab:type name='$typename'>\n";
print "<emulab:attribute name='architecture' ".
"value='" . $type->architecture() . "'/>\n"
if ($type->architecture());
print "<emulab:attribute name='disksize' ".
"value='" . $type->disksize() . "'/>\n"
if ($type->disksize());
foreach my $key (keys(%attributes)) {
my $val = $attributes{$key}->{"value"};
if ($key =~ /^hw_/) {
print "<emulab:attribute name='$key' value='$val'/>\n";
}
}
print "</emulab:type>\n";
}
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