286 1.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#
# More state transitions so we can recover from SECVIOLATION via POWEROFF.
#
use strict;
use libdb;

sub DoUpdate($$$)
{
    my ($dbhandle, $dbname, $version) = @_;
    my @mode_transitions = (
    );
    my @timeouts = (
    );
    my @transitions = (
	["SECUREBOOT","SHUTDOWN","GPXEBOOTING","QuoteOK"],
	["SECUREBOOT","SHUTDOWN","SECVIOLATION","QuoteFailed"],
    );
    my @triggers = (
    );

    foreach my $row (@mode_transitions) {
	my ($opm1,$s1,$opm2,$s2,$lab) = @$row;
	my $query_result =
	    DBQueryFatal("SELECT op_mode1 FROM mode_transitions WHERE ".
			 "op_mode1='$opm1' AND state1='$s1' AND ".
			 "op_mode2='$opm2' AND state2='$s2'");
	if ($query_result->numrows == 0) {
	    DBQueryFatal("INSERT INTO mode_transitions VALUES ".
			 "('$opm1','$s1','$opm2', '$s2','$lab')");
	}
    }

    foreach my $row (@timeouts) {
	my ($opm,$s,$to,$act) = @$row;
	my $query_result =
	    DBQueryFatal("SELECT op_mode FROM state_timeouts WHERE ".
			 "op_mode='$opm' AND state='$s'");
	if ($query_result->numrows == 0) {
	    DBQueryFatal("INSERT INTO state_timeouts VALUES ".
			 "('$opm','$s','$to', '$act')");
	}
    }

    foreach my $row (@transitions) {
	my ($opm,$s1,$s2,$lab) = @$row;
	my $query_result =
	    DBQueryFatal("SELECT op_mode FROM state_transitions WHERE ".
			 "op_mode='$opm' AND state1='$s1' AND state2='$s2'");
	if ($query_result->numrows == 0) {
	    DBQueryFatal("INSERT INTO state_transitions VALUES ".
			 "('$opm','$s1','$s2','$lab')");
	}
    }

    foreach my $row (@triggers) {
	my ($node,$opm,$s,$trig) = @$row;
	my $query_result =
	    DBQueryFatal("SELECT node_id FROM state_triggers WHERE ".
			 "node_id='$node' AND op_mode='$opm' AND state='$s'");
	if ($query_result->numrows == 0) {
	    DBQueryFatal("INSERT INTO state_triggers VALUES ".
			 "('$node','$opm','$s','$trig')");
	}
    }

    return 0;
}
1;