From b72ddf64bc5d89487ffe9672f0ba89c5b90ac2e5 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Thu, 22 Apr 2010 13:34:17 -0700 Subject: support for PARENT reference in priority statements. Example: priority: PARENT Means that this priority group will adopt the priority value of the parent. And the behavior on deletion of this priority root node will be deleted before the parent. On all other operations this node will be scheduled after the parent. This should fix problems in scheduling creation/deletion orders for priority groups so long as they are located within the same hierarchy. priority.pl has been updated as well. --- scripts/priority.pl | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/priority.pl b/scripts/priority.pl index 4124987..0cadbc3 100644 --- a/scripts/priority.pl +++ b/scripts/priority.pl @@ -9,6 +9,7 @@ use warnings; use File::Find; my %priorities; +my @parent_priorities; # Open node file and extract priority and comment if any sub get_priority { @@ -19,7 +20,7 @@ sub get_priority { while (<$f>) { chomp; - next unless m/^priority:\s(\d+)/; + next unless m/^priority:\s((PARENT)|(\d+))/; $priority = $1; $comment = $1 if (/#(.*)$/); @@ -47,7 +48,12 @@ sub wanted { if $comment; # append line to list of entries with same priority - push @{ $priorities{$priority} }, $dir; + if ($priority ne 'PARENT') { + push @{ $priorities{$priority} }, $dir; + } + else { + push(@parent_priorities, $dir); + } return 1; } @@ -58,6 +64,28 @@ die "$cfgdir does not exist!" unless -d $cfgdir; # walk config file tree find( \&wanted, $cfgdir ); +#resolve parent dependencies +foreach my $pp (@parent_priorities) { + my $tmp = $pp; + while (1) { + my $pos = rindex($tmp, "/"); + if ($pos == -1) { + last; + } + $tmp = substr($tmp,0,$pos); + + #search through second value in collection for match + foreach (keys %priorities) { + foreach my $a (@{ $priorities{$_} }) { + if ($a eq $tmp) { + push @{ $priorities{$_} }, $pp . " [PARENT]"; + last; + } + } + } + } +} + # display resulting priorities foreach my $key ( sort { $a <=> $b } keys %priorities ) { my @a = @{ $priorities{$key} }; -- cgit v1.2.3