mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 02:38:03 +00:00 
			
		
		
		
	extracts desired port name pattern to variable; sets DNS bind flag
This commit is contained in:
		| @@ -36,8 +36,9 @@ my $usage = qq("$0 --host {ip or hostname} # connect to this | |||||||
|    --port {port number} # defaults to 8080 |    --port {port number} # defaults to 8080 | ||||||
| ); | ); | ||||||
|  |  | ||||||
| my $des_resource = 2; | my $des_resource = 3; | ||||||
|  | #my $pat_port_type = '^eth\d[#]\d+'; | ||||||
|  | my $pat_port_type = '^sta\d+'; | ||||||
| ## | ## | ||||||
| ##    M A I N | ##    M A I N | ||||||
| ## | ## | ||||||
| @@ -188,14 +189,15 @@ my $rh_endp_A = { # actual endpoint | |||||||
|       #'alias'           => "untitled", |       #'alias'           => "untitled", | ||||||
|       'shelf'           => 1, |       'shelf'           => 1, | ||||||
|       'resource'        => $des_resource, |       'resource'        => $des_resource, | ||||||
|       # port  |  | ||||||
|       'type'            => 'l4_generic', |       'type'            => 'l4_generic', | ||||||
|       'timeout'         => '2000', |       'timeout'         => '2000', | ||||||
|       'url_rate'        => '600', |       'url_rate'        => '600', | ||||||
|       'url'             => 'dl http://10.36.0.1/ /dev/null', |       'url'             => 'dl http://idtest.candelatech.com/ /dev/null', | ||||||
|       'max_speed'       => '1000000', |       'max_speed'       => '1000000', | ||||||
|  |       'http_auth_type'  => 0, | ||||||
|  |       'proxy_auth_type' => 512, | ||||||
|    }; |    }; | ||||||
| my $rh_endp_B = { # dummy endpoints,  | my $rh_endp_B = { # dummy endpoints, # we don't actually need | ||||||
|       #'alias'           => "D_untitled", |       #'alias'           => "D_untitled", | ||||||
|       'shelf'           => 1, |       'shelf'           => 1, | ||||||
|       'resource'        => $des_resource, |       'resource'        => $des_resource, | ||||||
| @@ -232,7 +234,7 @@ my $create_b_side = 0; | |||||||
| if ($create_b_side) { | if ($create_b_side) { | ||||||
|    for my $rh_p (values %{$rh_ports->{'flat_list'}}) { |    for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | ||||||
|       last if ($num_cx >= ($num_ports-1)); |       last if ($num_cx >= ($num_ports-1)); | ||||||
|       next if ($rh_p->{'alias'} !~ /^eth\d[#]\d+/); |       next if ($rh_p->{'alias'} !~ /$pat_port_type/); | ||||||
|  |  | ||||||
|       # create dummy port and set it unmanaged |       # create dummy port and set it unmanaged | ||||||
|       my $end_b_alias = "D_l4json${disp_num}"; |       my $end_b_alias = "D_l4json${disp_num}"; | ||||||
| @@ -249,7 +251,7 @@ if ($create_b_side) { | |||||||
|    print "\nSetting Endpoint flags: "; |    print "\nSetting Endpoint flags: "; | ||||||
|    for my $rh_p (values %{$rh_ports->{'flat_list'}}) { |    for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | ||||||
|       last if ($num_cx >= ($num_ports-1)); |       last if ($num_cx >= ($num_ports-1)); | ||||||
|       next if ($rh_p->{'alias'} !~ /^eth\d[#]\d+/); |       next if ($rh_p->{'alias'} !~ /$pat_port_type/); | ||||||
|       my $end_b_alias = "D_l4json${disp_num}"; |       my $end_b_alias = "D_l4json${disp_num}"; | ||||||
|       $rh_set_flags_b->{'name'} = $end_b_alias; |       $rh_set_flags_b->{'name'} = $end_b_alias; | ||||||
|       $num_cx++; |       $num_cx++; | ||||||
| @@ -264,7 +266,7 @@ $disp_num = $des_resource * 1000; | |||||||
| print "\nAdding Endpoint A: "; | print "\nAdding Endpoint A: "; | ||||||
| for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | ||||||
|    last if ($num_cx >= ($num_ports-1)); |    last if ($num_cx >= ($num_ports-1)); | ||||||
|    next if ($rh_p->{'alias'} !~ /^eth\d[#]\d+/); |    next if ($rh_p->{'alias'} !~ /$pat_port_type/); | ||||||
|    my $end_a_alias = "l4json${disp_num}"; |    my $end_a_alias = "l4json${disp_num}"; | ||||||
|    $rh_endp_A->{'port'} = $rh_p->{'alias'}; |    $rh_endp_A->{'port'} = $rh_p->{'alias'}; | ||||||
|    $rh_endp_A->{'alias'} = $end_a_alias; |    $rh_endp_A->{'alias'} = $end_a_alias; | ||||||
| @@ -278,7 +280,7 @@ $disp_num = $des_resource * 1000; | |||||||
| print "\nSet_endp_flag: "; | print "\nSet_endp_flag: "; | ||||||
| for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | ||||||
|    last if ($num_cx >= ($num_ports-1)); |    last if ($num_cx >= ($num_ports-1)); | ||||||
|    next if ($rh_p->{'alias'} !~ /^eth\d[#]\d+/); |    next if ($rh_p->{'alias'} !~ /$pat_port_type/); | ||||||
|    my $end_a_alias = "l4json${disp_num}"; |    my $end_a_alias = "l4json${disp_num}"; | ||||||
|    $rh_set_flags_a->{'name'} = $end_a_alias; |    $rh_set_flags_a->{'name'} = $end_a_alias; | ||||||
|    $num_cx++; |    $num_cx++; | ||||||
| @@ -295,7 +297,7 @@ $num_cx = 0; | |||||||
| $disp_num = $des_resource * 1000; | $disp_num = $des_resource * 1000; | ||||||
| for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | for my $rh_p (values %{$rh_ports->{'flat_list'}}) { | ||||||
|    last if ($num_cx >= ($num_ports-1)); |    last if ($num_cx >= ($num_ports-1)); | ||||||
|    next if ($rh_p->{'alias'} !~ /^eth\d[#]\d+/); |    next if ($rh_p->{'alias'} !~ /$pat_port_type/); | ||||||
|    my $end_a_alias = "l4json${disp_num}"; |    my $end_a_alias = "l4json${disp_num}"; | ||||||
|    my $end_b_alias = ($create_b_side) ? "D_l4json${disp_num}" : "NA"; |    my $end_b_alias = ($create_b_side) ? "D_l4json${disp_num}" : "NA"; | ||||||
|    my $cx_alias = "CX_l4json${disp_num}"; |    my $cx_alias = "CX_l4json${disp_num}"; | ||||||
| @@ -339,11 +341,11 @@ while ($num_unfinished > 0) { | |||||||
|    print " Unfinished: $num_unfinished\n"; |    print " Unfinished: $num_unfinished\n"; | ||||||
|    sleep 1 if ($num_unfinished); |    sleep 1 if ($num_unfinished); | ||||||
| } | } | ||||||
| @endp_names = []; | @endp_names = (); | ||||||
| my $rh_endp = json_request("/layer4/list"); | my $rh_endp = json_request("/layer4/list"); | ||||||
| flatten_list($rh_endp, "endpoint"); | flatten_list($rh_endp, "endpoint"); | ||||||
| @endp_names = sort keys %{$rh_endp->{'flat_list'}}; | @endp_names = sort keys %{$rh_endp->{'flat_list'}}; | ||||||
| @cx_names = []; | @cx_names = (); | ||||||
| for my $endp_name (@endp_names) { | for my $endp_name (@endp_names) { | ||||||
|    next if ($endp_name =~ m/^D_/); |    next if ($endp_name =~ m/^D_/); | ||||||
|    if ($endp_name =~ m/^1\./) { |    if ($endp_name =~ m/^1\./) { | ||||||
| @@ -360,6 +362,10 @@ my $rh_cx_t = { | |||||||
|    }; |    }; | ||||||
| print "\nSetting timers: "; | print "\nSetting timers: "; | ||||||
| for my $cx_alias (sort @cx_names) { | for my $cx_alias (sort @cx_names) { | ||||||
|  |    if ($cx_alias =~ /^\s*$/ || ref $cx_alias eq "ARRAY") { | ||||||
|  |       print "BLANK CX_NAME: ".Dumper(\@cx_names); | ||||||
|  |       next; | ||||||
|  |    } | ||||||
|    $rh_cx_t->{'cx_name'} = $cx_alias; |    $rh_cx_t->{'cx_name'} = $cx_alias; | ||||||
|    print " ~$cx_alias "; |    print " ~$cx_alias "; | ||||||
|    json_post("/cli-json/set_cx_report_timer", $rh_cx_t); |    json_post("/cli-json/set_cx_report_timer", $rh_cx_t); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds