diff --git a/adjust_apache.pl b/adjust_apache.pl index ebfb5d5c..fa70d427 100755 --- a/adjust_apache.pl +++ b/adjust_apache.pl @@ -65,14 +65,31 @@ if (-f "$fname") { #my $blank = 0; #my $was_blank = 0; my $counter = 0; - my $debug = 0; + my $debug = 1; + my %host_map = ( + "localhost.localdomain" => "127.0.0.1", + "localhost" => "127.0.0.1", + "localhost4.localdomain4" => "127.0.0.1", + "localhost4" => "127.0.0.1", + "localhost.localdomain" => "::1", + "localhost" => "::1", + "localhost6.loaldomain6" => "::1", + "localhost6" => "::1", + $MgrHostname => $ip, + "lanforge.localnet" => "192.168.1.101", + "lanforge.localdomain" => "192.168.1.101", + ); my %address_map = ( "127.0.0.1" => "localhost.localdomain localhost localhost4.localdomain4 localhost4", "::1" => "localhost.localdomain localhost localhost6.loaldomain6 localhost6", $ip => $MgrHostname, "192.168.1.101" => "lanforge.localnet lanforge.localdomain", ); - print Dumper(\%address_map) if ($debug); + if ($debug){ + print Dumper(\%address_map); + print Dumper(\%host_map); + } + my $prevname = ""; my $previp = ""; @@ -92,28 +109,28 @@ if (-f "$fname") { print "\n HUNK",$counter2,"-:$hunk:- " if ($debug); $counter2++; next if ($hunk =~ /^localhost/); - next if ($hunk =~ /^lanforge-srv\b/); - next if ($hunk =~ /^lanforge\.local(domain|net)\b/); + next if ($hunk =~ /^lanforge-srv$/); + next if ($hunk =~ /^lanforge\.local(domain|net)$/); next if ($hunk =~ /^extra6?-\d+/); - if (($hunk =~ /^$ip\b/) - || ($hunk =~ /^$MgrHostname\b/)){ + if ($hunk =~ /^$ip$/) { $linehasip++; $lfhostname++; + } + elsif ($hunk =~ /^$MgrHostname$/) { + $lfhostname++; $prevname = $hunk; } if (($hunk =~ /^127\.0\.0\.1/) || ($hunk =~ /^192\.168\.1\.101/) - || ($hunk =~ /^::1\b/)){ + || ($hunk =~ /^::1$/)){ $previp = $hunk; $linehasip++; } - - if ($hunk =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) { + elsif ($hunk =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $linehasip++; print " IP4($hunk)" if ($debug); - $previp = $hunk; if ($counter2 > 0) { # we're not first item on line $middleip++ if ($counter2 > 0); print "middle" if ($debug); @@ -122,6 +139,13 @@ if (-f "$fname") { $address_map{$hunk} = ""; } print "+IP4" if ($debug); + + if (("" ne $prevname) && ($counter2 > 0)) { + print " hunk($hunk)prev($prevname)" if ($debug); + $address_map{$hunk} .= " $prevname" + if ($address_map{$hunk} !~ /\s*$prevname\s*/); + $host_map{$prevname} .= " $hunk"; + } $previp = $hunk; } elsif (($hunk =~ /[G-Zg-z]+\.?/) || ($hunk =~ /^[^:A-Fa-f0-9]+/)) { @@ -132,22 +156,26 @@ if (-f "$fname") { $address_map{$previp} .= " $hunk" if ($address_map{$previp} !~ /\b$hunk\b/); $prevname = $hunk; + $host_map{$prevname} .= " $previp"; } elsif ($linehasip) { print " prev($previp $hunk)" if ($debug); $address_map{$previp} .= " $hunk" - if ($address_map{$previp} !~ /\b$hunk\b/); + if ($address_map{$previp} !~ /\s*$hunk\s*/); + $host_map{$hunk} .= " $previp"; } elsif ($lfhostname) { $more_hostnames{$hunk} = 1; + $host_map{$hunk} .= " $previp"; } else { # strange word if ("" eq $previp) { print " hunk($hunk) has no IP***" if ($debug); $more_hostnames{$hunk} = 1; } - elsif ($address_map{$previp} !~ /\b$hunk\b/) { - $address_map{$previp} .= " $hunk" + elsif ($address_map{$previp} !~ /\s*$hunk\s*/) { + $address_map{$previp} .= " $hunk"; + $host_map{$hunk} .= " $previp"; } } } @@ -160,27 +188,25 @@ if (-f "$fname") { } $previp = $hunk; } - elsif ($hunk =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/) { - print " hunk($hunk)prev($prevname)" if ($debug); - $address_map{$hunk} .= " $prevname" - if ($address_map{$hunk} !~ /\b$prevname\b/); - $previp = $hunk; - } - elsif ($address_map{$previp} !~ /\b$hunk\b/) { # is hostname and not an ip + elsif ($address_map{$previp} !~ /\s*$hunk\s*/) { # is hostname and not an ip $address_map{$previp} .= " $hunk"; + $host_map{$hunk} .= " $previp"; } - } # ~foreach hunk - } # ~foreach line + if (($host_map{$MgrHostname} !~ /^\s*$/) && ($host_map{$MgrHostname} =~ /\S+\s+\S+/)) { + print("Multiple IPs for this hostname: ".$host_map{$MgrHostname}."\n"); + my @iphunks = split(/\s+/, $host_map{$MgrHostname}); + print "WARNING changing $MgrHostname for to $ip; line was <<$host_map{$MgrHostname}>> addrmap: <<$address_map{$ip}>>\n" + if ($debug); + $host_map{$MgrHostname} = $ip; + } for my $name (sort keys %more_hostnames) { $address_map{$ip} .= " $name"; print "NEWSTUFF $ip $address_map{$ip}\n" if ($debug); } - print Dumper(\%address_map) if ($debug); - unshift(@newlines, "192.168.1.101 ".$address_map{"192.168.1.101"}); unshift(@newlines, "127.0.0.1 ".$address_map{"127.0.0.1"}); unshift(@newlines, "::1 ".$address_map{"::1"}); @@ -189,8 +215,16 @@ if (-f "$fname") { delete($address_map{"127.0.0.1"}); delete($address_map{"::1"}); + print Dumper(\%address_map) if ($debug); + print Dumper(\%host_map) if ($debug); + for my $key (sort keys %address_map){ next if ($key eq $ip); + if ($address_map{$key} =~ /\s*$MgrHostname\s*/) { + print("SKIPPING $key / $address_map{$key}\n") + if ($debug); + next; + } push(@newlines, $key." ".$address_map{$key}); } push(@newlines, "###-LF-HOSTNAME-NEXT-###"); diff --git a/py-scripts/test_l3_powersave_traffic.py b/py-scripts/test_l3_powersave_traffic.py index 8b96f3f2..443212a0 100644 --- a/py-scripts/test_l3_powersave_traffic.py +++ b/py-scripts/test_l3_powersave_traffic.py @@ -38,6 +38,7 @@ class L3PowersaveTraffic(LFCliBase): self.cx_prof_upload = realm.L3CXProfile(self.host, self.port, self.local_realm, side_a_min_bps=side_a_min_rate, side_b_min_bps=0, side_a_max_bps=side_a_max_rate, side_b_max_bps=0, debug_=True) + #download self.cx_prof_download = realm.L3CXProfile(self.host, self.port, self.local_realm, side_a_min_bps=0, side_b_min_bps=side_b_min_rate, side_a_max_bps=0, @@ -47,6 +48,7 @@ class L3PowersaveTraffic(LFCliBase): security=self.security, number_template_=self.prefix, mode=0, up=True, dhcp=True, debug_=False) + self.station_profile.admin_up(resource=1) @@ -55,13 +57,15 @@ class L3PowersaveTraffic(LFCliBase): #download would set TXBps on B side of endpoint #build print("Creating stations for" + UorD + "traffic") - self.station_profile.use_wpa2(True, self.ssid, self.password) + self.station_profile.use_wpa2(False, self.ssid, self.password) self.station_profile.set_number_template(self.prefix) self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_param("set_port", "report_timer", 1500) self.station_profile.set_command_flag("set_port", "rpt_timer", 1) self.station_profile.set_command_flag("add_sta", "power_save_enable", 1) + self.station_profile.create(resource=1, radio="wiphy0", sta_names_=self.sta_list, debug=False) + self._pass("PASS: Station build for" + UorD + "finished") temp_sta_list = [] for name in list(self.local_realm.station_list()): @@ -71,13 +75,16 @@ class L3PowersaveTraffic(LFCliBase): self.cx_prof_upload.name_prefix = "UDP_up" self.cx_prof_download.name_prefix = "UDP_down" print("Beginning create upload") - self.cx_prof_upload.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) #create 2 cx profiles + self.cx_prof_upload.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + #create 2 cx profiles print("Beginning create download") - self.cx_prof_download.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + self.cx_prof_download.create(endp_type="lf_udp", side_a=temp_sta_list, side_b="1.eth1", sleep_time=.05) + def start(self): #start one test, measure #start second test, measure + #start upload, pass def stop(self): @@ -135,9 +142,10 @@ def main(): lfjson_host = "localhost" lfjson_port = 8080 #creates object of class L3PowersaveTraffic, inputs rates for upload and download - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) + #station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000) + ip_powersave_test = L3PowersaveTraffic(lfjson_host, lfjson_port, ssid = "jedway-open" , security = "open", - password ="[BLANK]", station_list = station_list , side_a_min_rate=56, side_b_min_rate=56, side_a_max_rate=0, + password ="[BLANK]", station_list = ["sta01", "sta02"] , side_a_min_rate=5600, side_b_min_rate=5600, side_a_max_rate=0, side_b_max_rate=0, prefix="00000", test_duration="5m", _debug_on=True, _exit_on_error=True, _exit_on_fail=True) #ip_powersave_test.cleanup()