summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Vyatta/Config.pm77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm
index f80ff86..fd0222f 100755
--- a/lib/Vyatta/Config.pm
+++ b/lib/Vyatta/Config.pm
@@ -98,6 +98,83 @@ sub listNodes {
return @nodes_modified;
}
+## listNodes("level")
+# return array of all nodes (active plus currently committed) at "level"
+# level is relative
+sub listOrigPlusComNodes {
+ my ($self, $path) = @_;
+ my @nodes = ();
+
+ my @nodes_modified = $self->listNodes();
+
+ #convert array to hash
+ my %coll;
+ my $coll;
+ @coll{@nodes_modified} = @nodes_modified;
+
+ my $level = $self->{_level};
+
+ #now test against the inprocess file in the system
+# my $com_file = "/tmp/.changes_$$";
+ my $com_file = "/tmp/.changes";
+ open FILE, "<", $com_file;
+ if (-e $com_file) {
+ foreach my $line (<FILE>) {
+ my @node = split " ", $line; #split on space
+ #$node[1] is of the form: system/login/blah
+ #$coll is of the form: blah
+
+ my $dir_path = $level;
+ $dir_path =~ s/ /\//g;
+ $dir_path = "/".$dir_path;
+
+# print("comparing: $dir_path and $level to $node[1]\n");
+
+ #first only consider $path matches against $node[1]
+ if (!defined $dir_path || $node[1] =~ m/^$dir_path/) {
+ #or does $node[1] match the beginning of the line for $path
+
+ #if yes, then split the right side and find against the hash for the value...
+ my $tmp;
+ if (defined $dir_path) {
+ $tmp = substr($node[1],length($dir_path));
+ }
+ else {
+ $tmp = $node[1];
+ }
+
+ my @child = split "/",$tmp;
+ my $child;
+# print("tmp: $tmp, $child[0], $child[1]\n");
+ if ($child[0] =~ /^\s*$/ || !defined $child[0] || $child[0] eq '') {
+ shift(@child);
+ }
+
+# print("child value is: >$child[0]<\n");
+
+ #now can we find this entry in the hash?
+ #if '-' this is a delete and need to remove from hash
+ if ($node[0] eq "-") {
+ if (!defined $child[1]) {
+ delete($coll{$child[0]});
+ }
+ }
+ #if '+' this is a set and need to add to hash
+ elsif ($node[0] eq "+" && $child[0] ne '') {
+ $coll{$child[0]} = '1';
+ }
+ }
+ }
+ }
+
+#print "coll count: ".keys(%coll);
+
+ #now convert hash to array and return
+ @nodes_modified = ();
+ @nodes_modified = keys(%coll);
+ return @nodes_modified;
+}
+
## listOrigNodes("level")
# return array of all original nodes (i.e., before any current change; i.e.,
# in "working") at "level"