From f6d95484a2f04633767409a565debe149ef5f56c Mon Sep 17 00:00:00 2001
From: slioch <slioch@eng-140.vyatta.com>
Date: Thu, 2 Jul 2009 09:48:10 -0700
Subject: fixed isActive() api to now support mixed level and passed in
 relative path values.

---
 lib/Vyatta/Config.pm | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm
index 95c5636..c97152c 100755
--- a/lib/Vyatta/Config.pm
+++ b/lib/Vyatta/Config.pm
@@ -107,12 +107,14 @@ sub isActive {
 
   my @comp_node = split " ", $path;
 
-  my $comp_node = $comp_node[-1];
+  my $comp_node = pop(@comp_node);
   if (!defined $comp_node) {
       return 1;
   }
+  
+  my $rel_path = join(" ",@comp_node);
 
-  my @nodes_modified = $self->listOrigPlusComNodes();
+  my @nodes_modified = $self->listOrigPlusComNodes($rel_path);
   foreach my $node (@nodes_modified) {
       if ($node eq $comp_node) {
 	  return 0;
@@ -128,7 +130,7 @@ sub listOrigPlusComNodes {
   my ($self, $path) = @_;
   my @nodes = ();
 
-  my @nodes_modified = $self->listNodes();
+  my @nodes_modified = $self->listNodes($path);
 
   #convert array to hash
   my %coll;
@@ -151,6 +153,9 @@ sub listOrigPlusComNodes {
 	  #$coll is of the form: blah
 
 	  my $dir_path = $level;
+	  if (defined $path) {
+	      $dir_path .= " " . $path;
+	  }
 	  $dir_path =~ s/ /\//g;
 	  $dir_path = "/".$dir_path;
 
@@ -169,8 +174,13 @@ sub listOrigPlusComNodes {
 		  $tmp = $node[1];
 	      }
 	      
+	      if (!defined $tmp || $tmp eq '') {
+		  next;
+	      }
+
 	      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);
-- 
cgit v1.2.3