Commit 573c6a54 authored by Kirk Webb's avatar Kirk Webb

Move "InheritTaintStates" call to common taint library.

It's going to be used by both OSinfo and Node objects.  New OSes will
want to inherit taint states from the OS they are derived from.
parent d0eb29d1
......@@ -3773,36 +3773,18 @@ sub RemoveTaintState($;$) {
return libTaintStates::RemoveTaintState($self, $taint);
}
#
# Inherit the taint states from an OS. Take the union with whatever
# taint states are already set for the node.
#
sub InheritTaintStates($$)
{
sub InheritTaintStates($$) {
my ($self, $osinfo) = @_;
require OSinfo;
if (!ref($osinfo)) {
my $tmp = OSinfo->Lookup($osinfo);
if (!defined($tmp)) {
warn "Cannot lookup osinfo for $osinfo\n";
return -1;
}
$osinfo = $tmp;
}
my @taint_states = $osinfo->GetTaintStates();
return 0
if (!@taint_states);
push @taint_states, $self->GetTaintStates();
require libTaintStates;
return $self->SetTaintStates(@taint_states);
return libTaintStates::InheritTaintStates($self, $osinfo);
}
#
# Synchornize the node's taint states based on the OSes listed
# for its partitions.
# for its partitions. Any existing taint states on the node are
# lost (unless they appear on one or more partition OSes).
#
sub SyncTaintStates($)
{
......
......@@ -761,6 +761,12 @@ sub RemoveTaintState($;$) {
return libTaintStates::RemoveTaintState($self, $taint);
}
sub InheritTaintStates($$) {
my ($self, $osinfo) = @_;
require libTaintStates;
return libTaintStates::InheritTaintStates($self, $osinfo);
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -179,5 +179,31 @@ sub RemoveTaintState($;$)
return SetTaintStates($obj, @ntstates);
}
#
# Inherit the taint states from an OS. Take the union with whatever
# taint states are already set for the node.
#
sub InheritTaintStates($$)
{
my ($obj, $osinfo) = @_;
require OSinfo;
if (!ref($osinfo)) {
my $tmp = OSinfo->Lookup($osinfo);
if (!defined($tmp)) {
warn "Cannot lookup osinfo for $osinfo\n";
return -1;
}
$osinfo = $tmp;
}
my @taint_states = GetTaintStates($osinfo);
return 0
if (!@taint_states);
push @taint_states, GetTaintStates($obj);
return SetTaintStates($obj, @taint_states);
}
# Next line required by perl for modules
1;
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