mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:greearb/lanforge-scripts
This commit is contained in:
		| @@ -428,8 +428,9 @@ sub sleep_sec { | |||||||
|  |  | ||||||
| sub get_eid_map { | sub get_eid_map { | ||||||
|   my ($self, $resource) = @_; |   my ($self, $resource) = @_; | ||||||
|   my %eid_map = (); |   my $rh_eid_map = {}; | ||||||
|   my @ports_lines = split("\n", $self->doAsyncCmd("nc_show_ports 1 $resource ALL")); |   my @ports_lines = split("\n", $self->doAsyncCmd("nc_show_ports 1 $resource ALL")); | ||||||
|  |   sleep 1; | ||||||
|   chomp(@ports_lines); |   chomp(@ports_lines); | ||||||
|  |  | ||||||
|   my ($eid, $card, $port, $type, $mac, $dev, $parent, $ip); |   my ($eid, $card, $port, $type, $mac, $dev, $parent, $ip); | ||||||
| @@ -446,16 +447,15 @@ sub get_eid_map { | |||||||
|     # careful about that comma after card! |     # careful about that comma after card! | ||||||
|     # NO EID for Shelf: 1, Card: 1, Port: 2  Type: WIFI-Radio  Alias: |     # NO EID for Shelf: 1, Card: 1, Port: 2  Type: WIFI-Radio  Alias: | ||||||
|     ($card, $port, $type) = $line =~ m/^Shelf: 1, Card: (\d+),\s+Port: (\d+)\s+Type: (\w+)/; |     ($card, $port, $type) = $line =~ m/^Shelf: 1, Card: (\d+),\s+Port: (\d+)\s+Type: (\w+)/; | ||||||
|     if ((defined $card) && ($card ne "") && (defined $port) && ($port ne "")) { |     if ((defined $card) && ($card ne "") && (defined $port) && ($port ne "") && ($type ne "VRF")) { | ||||||
|       $eid = "1.${card}.${port}"; |       $eid = "1.".$card.".".$port; | ||||||
|       my $rh_eid = { |       my $rh_eid = { | ||||||
|         eid => $eid, |         eid => $eid, | ||||||
|         type => $type, |         type => $type, | ||||||
|         parent => undef, |         parent => undef, | ||||||
|         dev => undef, |         dev => undef, | ||||||
|       }; |       }; | ||||||
|       $eid_map{$eid} = $rh_eid; |       $rh_eid_map->{$eid} = $rh_eid; | ||||||
|       #print "\nfound eid $eid\n"; |  | ||||||
|     } |     } | ||||||
|     #elsif ($line =~ /^Shelf/) { |     #elsif ($line =~ /^Shelf/) { | ||||||
|     #  #print "NO EID for $line\n"; |     #  #print "NO EID for $line\n"; | ||||||
| @@ -467,28 +467,42 @@ sub get_eid_map { | |||||||
|     } |     } | ||||||
|     ($mac, $dev) = $line =~ / MAC: ([0-9:a-fA-F]+)\s+DEV: (\S+)/; |     ($mac, $dev) = $line =~ / MAC: ([0-9:a-fA-F]+)\s+DEV: (\S+)/; | ||||||
|     if ((defined $mac) && ($mac ne "")) { |     if ((defined $mac) && ($mac ne "")) { | ||||||
|      #print "$eid MAC: $line\n"; |       #print "$eid MAC: $line\n"; | ||||||
|       $eid_map{$eid}->{mac} = $mac; |       $rh_eid_map->{$eid}->{mac} = $mac; | ||||||
|       $eid_map{$eid}->{dev} = $dev; |       $rh_eid_map->{$eid}->{dev} = $dev; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ($parent) = $line =~ / Parent.Peer: (\S+) /; |     ($parent) = $line =~ / Parent.Peer: (\S+) /; | ||||||
|     if ((defined $parent) && ($parent ne "")) { |     if ((defined $parent) && ($parent ne "")) { | ||||||
|       #print "$eid PARENT: $line\n"; |       #print "$eid PARENT: $line\n"; | ||||||
|       $eid_map{$eid}->{parent} = $parent; |       $rh_eid_map->{$eid}->{parent} = $parent; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ($ip) = $line =~ m/ IP: *([^ ]+) */; |     ($ip) = $line =~ m/ IP: *([^ ]+) */; | ||||||
|     if ((defined $ip) && ($ip ne "")) { |     if ((defined $ip) && ($ip ne "")) { | ||||||
|       #print "$eid IP: $line\n"; |       #print "$eid IP: $line\n"; | ||||||
|       $eid_map{$eid}->{ip} = $ip; |       $rh_eid_map->{$eid}->{ip} = $ip; | ||||||
|     } |     } | ||||||
|   } # foreach |   } # foreach | ||||||
|  |  | ||||||
|   #foreach $eid (keys %eid_map) { |   #foreach $eid (keys %eid_map) { | ||||||
|   #  print "eid $eid "; |   #  print "eid $eid "; | ||||||
|   #} |   #} | ||||||
|   return \%eid_map; |   return $rh_eid_map; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ## | ||||||
|  | ## | ||||||
|  | ## | ||||||
|  | sub find_by_name { | ||||||
|  |   my ($self, $rh_eid_map, $devname) = @_; | ||||||
|  |   while (my ($eid, $rh_rec) = each %{$rh_eid_map}) { | ||||||
|  |     #print "fbn: ".$rh_rec->{dev}."\n"; | ||||||
|  |     if ((defined $rh_rec->{dev}) && ($rh_rec->{dev} eq $devname)) { | ||||||
|  |       return $rh_rec; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
| ## | ## | ||||||
| @@ -496,15 +510,20 @@ sub get_eid_map { | |||||||
| ## EG: $ra_interfaces = $u->ports_on_radio($rh_eid_map, $radio_name); | ## EG: $ra_interfaces = $u->ports_on_radio($rh_eid_map, $radio_name); | ||||||
| ## | ## | ||||||
| sub ports_on_radio { | sub ports_on_radio { | ||||||
|   my ($self, $rh_eid_map, $radio) = @_; |   my ($self, $rh_rec2_map, $radio) = @_; | ||||||
|   my @interfaces = (); |   my $ra_ifs = []; | ||||||
|   while (my ($eid, $rh_eid) = each %$rh_eid_map) { |   #print "PARENT IS $radio\n"; | ||||||
|     if ((defined $rh_eid->{parent}) && ($rh_eid->{parent} eq $radio)) { |  | ||||||
|       push(@interfaces, $rh_eid->{dev}); |   foreach my $rh_rec2 (values %{$rh_rec2_map}) { | ||||||
|  |     next if (!(defined $rh_rec2->{parent})); | ||||||
|  |     #print "\npor: ".$rh_rec2->{parent}.">".$rh_rec2->{dev}."\n"; | ||||||
|  |     if ($rh_rec2->{parent} eq $radio) { | ||||||
|  |       #print $rh_rec2->{dev}."<-".$rh_rec2->{parent}." "; | ||||||
|  |       my $devn = $rh_rec2->{dev}; | ||||||
|  |       push(@$ra_ifs, $devn); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   return $ra_ifs; | ||||||
|   return \@interfaces; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| 1; # So the require or use succeeds (perl stuff) | 1; # So the require or use succeeds (perl stuff) | ||||||
|   | |||||||
| @@ -234,6 +234,8 @@ if ($::action eq "create") { | |||||||
|    } |    } | ||||||
|    my $upstream_resource = $::resource; |    my $upstream_resource = $::resource; | ||||||
|    my $rh_eid_map = $::utils->get_eid_map($::resource); |    my $rh_eid_map = $::utils->get_eid_map($::resource); | ||||||
|  |    die("Unable to find keys in rh_eid_map") if ((keys(%$rh_eid_map)) < 1); | ||||||
|  |  | ||||||
|    my $rh_upstream_map = $rh_eid_map; |    my $rh_upstream_map = $rh_eid_map; | ||||||
|    if ($::upstream !~ /^1\.$::resource\.\S+$/) { |    if ($::upstream !~ /^1\.$::resource\.\S+$/) { | ||||||
|      $upstream_resource = (split('.', $::upstream))[1]; |      $upstream_resource = (split('.', $::upstream))[1]; | ||||||
| @@ -244,11 +246,35 @@ if ($::action eq "create") { | |||||||
|    } |    } | ||||||
|    #print Dumper($rh_eid_map); |    #print Dumper($rh_eid_map); | ||||||
|  |  | ||||||
|  |    # build a list of ports -n ports long starting at -first_port | ||||||
|  |    my @ports = (); | ||||||
|  |    my $rh_first_dev = $::utils->find_by_name($rh_eid_map, $::first_sta); | ||||||
|  |    die("Unable to find dev record for port $::first_sta on resource $::resource") | ||||||
|  |      if ($rh_first_dev == -1); | ||||||
|  |    my $parent_name = $rh_first_dev->{parent}; | ||||||
|  |    die("Unable to find parent of $::first_sta, bye.") | ||||||
|  |      if (!(defined $parent_name)); | ||||||
|  |    my $ra_interfaces = $::utils->ports_on_radio($rh_eid_map, $parent_name); | ||||||
|  |    die("Unable to find any subinterfaces of $parent_name") | ||||||
|  |      if (@$ra_interfaces < 1); | ||||||
|  |  | ||||||
|  |    # want a pattern that matches Qvlan and Mvlan patterns, not just stations | ||||||
|  |    # things like eth1.3 or rd0#0 or r0b#0 | ||||||
|  |    my ($prefix) = $::first_sta =~ /^(.*?[^0-9]+)\d+$/i; | ||||||
|  |    #print "PREFIX IS $prefix\n"; | ||||||
|  |    my @selected_list = (); | ||||||
|  |  | ||||||
|  |    foreach my $iface (sort @$ra_interfaces) { | ||||||
|  |      #print "iface[$iface] "; | ||||||
|  |      next if ($iface !~ /^$prefix/); | ||||||
|  |      push(@selected_list, $iface); | ||||||
|  |      last if (@selected_list >= $::num_cx); | ||||||
|  |    } | ||||||
|  |  | ||||||
|    for (my $i=0; $i < $::num_cx; $i++) { |    for (my $i=0; $i < $::num_cx; $i++) { | ||||||
|      my $j = 10000 + $i; |      my $j = 10000 + $i; | ||||||
|      my $name = $::cx_name . substr("$j", 1); |      my $name = $::cx_name . substr("$j", 1); | ||||||
|      my $sta = |      my $ports = join('.', 1, $::resource, $selected_list[$i]).",".$::upstream; | ||||||
|      my $ports = join('.', 1, $::resource, $::first_sta).",".$::upstream; |  | ||||||
|  |  | ||||||
|      print "Connection name $name uses $ports\n"; |      print "Connection name $name uses $ports\n"; | ||||||
|      my $cmd = qq(./lf_firemod.pl --mgr $::lfmgr_host --port $::lfmgr_port ) |      my $cmd = qq(./lf_firemod.pl --mgr $::lfmgr_host --port $::lfmgr_port ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ben Greear
					Ben Greear