Guest User

Untitled

a guest
Nov 21st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. foreach my $n (@node_list)
  2. {
  3. chomp ($n);
  4.  
  5. foreach my $c (@cpes)
  6. {
  7. my @returned; #Interfaces to CPEs with MED settings
  8. my @creturned; #General Customer Interfaces
  9.  
  10. my ($cust) = $c =~ /([a-zA-Z]+)[_-][a-zA-Z0-9]+/s;
  11. print "nttCustomer is $custn";
  12.  
  13. chomp($c);
  14. $c = uc $c;
  15. my ($search) = $c;
  16.  
  17. (@returned) = `cat /curr/$n | grep "$search"`;
  18. if (@returned)
  19. {
  20. my $cust_match = 'interface "' . $cust;
  21. (@creturned) = `cat /curr/$n | egrep -i "$cust_match" | grep -v "$search"`;
  22.  
  23. }
  24. if (@creturned) #Have we found other CPEs on the same router
  25. {
  26. my ($nf) = $n =~ /([a-zA-Z0-9-]+).cfg/s;
  27.  
  28. my (@interfaces) = map { /([A-Z0-9_]+)/s } @creturned;
  29. @interfaces = uniq(@interfaces);
  30.  
  31. unshift (@interfaces, $c);
  32. push (@new_out, {$nf => {$cust => [@interfaces]}});
  33. }
  34.  
  35. }
  36.  
  37. $VAR1 = [
  38. {
  39. 'router-xx-xx' => {
  40. '50000' => [
  41. [
  42. 'THXXXXVF_NLXXXX40_1121_2',
  43. '10x.xx.x.50'
  44. ],
  45. [
  46. 'THXXXPVF_NLXXXX66_1121_1',
  47. '10x.xx.x.70'
  48. ],
  49. [
  50. 'THXXXXVF_NLXXXX67_1121_2',
  51. '10x.xx.x.78'
  52. ],
  53.  
  54. }
  55. },
  56.  
  57. foreach my $candidate (@nodes)
  58. {
  59. my %node = %{ $candidate };
  60.  
  61. foreach my $n (keys %node)
  62. {
  63. print "nRouter is $nn";
  64.  
  65. foreach my $cust (keys %{ $node{$n} })
  66. {
  67. print "Customer on $n is n" . Dumper $cust;
  68. my @intlist = @{$node{$n}{$cust}};
  69.  
  70. my $med_cpe = $intlist[0]; #the CPE that was used to find node
  71.  
  72. {truncated}
  73. my (@mlist) = grep {$_=~ / $rid /} @info;
  74. {truncated}
  75. push (@shared, [$cpe, $dip]);
  76. }
  77. push @master, {$n => {$rid => [@shared]}};;
  78. }
  79. }
  80. }
  81. }
Add Comment
Please, Sign In to add comment