X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute%2FNode.pm;h=67e32a00eac1197a581599b308a935dd7f86f32b;hb=1be52e58e3cb8a1746bd583b1b1e311602bb1935;hp=d3b1e955411833567a8b2551c55e19d1616b4136;hpb=af378e74088394d9c70a9a01d67a311cf4774d96;p=spider.git diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index d3b1e955..67e32a00 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -211,6 +211,24 @@ sub rnodes return @out; } +# this takes in a list of node and user calls (not references) from +# a config type update for a node and returns +# the differences as lists of things that have gone away +# and things that have been added. +sub calc_config_changes +{ + my $self = shift; + my %nodes = map {$_ => 1} @{$self->{nodes}}; + my %users = map {$_ => 1} @{$self->{users}}; + my $cnodes = shift; + my $cusers = shift; + my (@dnodes, @dusers, @nnodes, @nusers); + push @nnodes, map {my @r = $nodes{$_} ? () : $_; delete $nodes{$_}; @r} @$cnodes; + push @dnodes, keys %nodes; + push @nusers, map {my @r = $users{$_} ? () : $_; delete $users{$_}; @r} @$cusers; + push @dusers, keys %users; + return (\@dnodes, \@dusers, \@nnodes, \@nusers); +} sub new { @@ -221,10 +239,11 @@ sub new my $self = $pkg->SUPER::new($call); $self->{parent} = ref $pkg ? [ $pkg->{call} ] : [ ]; - $self->{version} = shift; - $self->{flags} = shift; + $self->{version} = shift || 5000; + $self->{flags} = shift || Route::here(1); $self->{users} = []; $self->{nodes} = []; + $self->{lastid} = {}; $list{$call} = $self;