Commit b4ee54fa authored by Leigh B Stoller's avatar Leigh B Stoller

Switch disksize to sysvol_any from the node_type_features table since

that is more useful to people (rather then just root disk size).
parent 04790f71
...@@ -90,6 +90,7 @@ sub LookupRow($$$) ...@@ -90,6 +90,7 @@ sub LookupRow($$$)
$self->{"DBROW"} = $row; $self->{"DBROW"} = $row;
$self->{"CLASS"} = ($type eq $row->{"class"} ? $type : undef); $self->{"CLASS"} = ($type eq $row->{"class"} ? $type : undef);
$self->{"ATTRS"} = undef; $self->{"ATTRS"} = undef;
$self->{"FETRS"} = undef;
$self->{"ISAUX"} = 0; $self->{"ISAUX"} = 0;
bless($self, $class); bless($self, $class);
...@@ -118,6 +119,7 @@ sub isgeninode($) { return field($_[0], 'isgeninode'); } ...@@ -118,6 +119,7 @@ sub isgeninode($) { return field($_[0], 'isgeninode'); }
sub isfednode($) { return field($_[0], 'isfednode'); } sub isfednode($) { return field($_[0], 'isfednode'); }
sub isswitch($) { return field($_[0], 'isswitch'); } sub isswitch($) { return field($_[0], 'isswitch'); }
sub attributes($) { return $_[0]->{'ATTRS'}; } sub attributes($) { return $_[0]->{'ATTRS'}; }
sub features($) { return $_[0]->{'FETRS'}; }
# #
# Force a reload of the data. # Force a reload of the data.
...@@ -245,6 +247,7 @@ sub LookupAuxType($$) ...@@ -245,6 +247,7 @@ sub LookupAuxType($$)
$newtype->{"TYPE"} = $auxtype; $newtype->{"TYPE"} = $auxtype;
$newtype->{"DBROW"} = $typeinfo->{"DBROW"}; $newtype->{"DBROW"} = $typeinfo->{"DBROW"};
$newtype->{"ATTRS"} = $typeinfo->{"ATTRS"}; $newtype->{"ATTRS"} = $typeinfo->{"ATTRS"};
$newtype->{"FETRS"} = $typeinfo->{"FETRS"};
$newtype->{"ISAUX"} = 1; $newtype->{"ISAUX"} = 1;
$newtype->{"BASE"} = $typeinfo; $newtype->{"BASE"} = $typeinfo;
bless($newtype, $class); bless($newtype, $class);
...@@ -480,6 +483,48 @@ sub SetAttribute($$$;$) ...@@ -480,6 +483,48 @@ sub SetAttribute($$$;$)
return 0; return 0;
} }
#
# Load features if not already loaded.
#
sub LoadFeatures($)
{
my ($self) = @_;
return 0
if (defined($self->{"FETRS"}));
#
# Get the attribute array.
#
my $type = $self->type();
my $query_result =
DBQueryWarn("select feature,weight from node_type_features ".
"where type='$type'");
$self->{"FETRS"} = {};
while (my ($key,$val) = $query_result->fetchrow_array()) {
$self->{"FETRS"}->{$key} = $val;
}
return 0;
}
#
# Look for a feature
#
sub GetFeature($$)
{
my ($self, $key) = @_;
$self->LoadFeatures() == 0
or return undef;
if (!exists($self->{"FETRS"}->{$key})) {
return undef;
}
return $self->{"FETRS"}->{$key};
}
sub disksize_any($) { return $_[0]->GetFeature("?+disk_any"); }
# #
# Free/Inuse count for a type. # Free/Inuse count for a type.
# #
......
...@@ -2621,9 +2621,18 @@ sub print_header { ...@@ -2621,9 +2621,18 @@ sub print_header {
print "<emulab:attribute name='architecture' ". print "<emulab:attribute name='architecture' ".
"value='" . $type->architecture() . "'/>\n" "value='" . $type->architecture() . "'/>\n"
if ($type->architecture()); if ($type->architecture());
my $disksize = $type->disksize_any();
if (!$disksize) {
$disksize = $type->disksize();
}
else {
# Convert Mebi to GB. Approximate is fine.
$disksize = int($disksize / 953.674);
}
print "<emulab:attribute name='disksize' ". print "<emulab:attribute name='disksize' ".
"value='" . $type->disksize() . "'/>\n" "value='" . $disksize . "'/>\n"
if ($type->disksize()); if ($disksize);
foreach my $key (keys(%attributes)) { foreach my $key (keys(%attributes)) {
my $val = $attributes{$key}->{"value"}; my $val = $attributes{$key}->{"value"};
if ($key =~ /^hw_/) { if ($key =~ /^hw_/) {
......
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