mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-05 21:28:03 +00:00
Merge branch 'master' of github.com:greearb/lanforge-scripts
This commit is contained in:
@@ -33,8 +33,8 @@ function Jurl() {
|
|||||||
echo "=J====================================================================================="
|
echo "=J====================================================================================="
|
||||||
}
|
}
|
||||||
|
|
||||||
#url="http://jed-f24m64-9119:8080"
|
url="http://jedtest.jbr:8080"
|
||||||
url="http://127.0.0.1:8080"
|
#url="http://127.0.0.1:8080"
|
||||||
data_file="/var/tmp/data.$$"
|
data_file="/var/tmp/data.$$"
|
||||||
result_file="/var/tmp/result_file.$$"
|
result_file="/var/tmp/result_file.$$"
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ unset http_proxy
|
|||||||
Q='"'
|
Q='"'
|
||||||
q="'"
|
q="'"
|
||||||
S='*'
|
S='*'
|
||||||
m=40
|
series=(10000 10001 10002 11000 11001 11002 12000 12001 12002)
|
||||||
n=42
|
ra=1
|
||||||
|
rb=2
|
||||||
application_json="application/json"
|
application_json="application/json"
|
||||||
accept_json="Accept: $application_json"
|
accept_json="Accept: $application_json"
|
||||||
accept_html='Accept: text/html'
|
accept_html='Accept: text/html'
|
||||||
@@ -46,23 +47,24 @@ function Kuurl() {
|
|||||||
set -x
|
set -x
|
||||||
curl "$@" ||:
|
curl "$@" ||:
|
||||||
set +x
|
set +x
|
||||||
grep 'HTTP/1.1 200' $headers || (echo "${@:$#}"; cat $headers)
|
grep 'HTTP/1.1 200' $headers || (echo "${@:$#}"; cat $headers; exit 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#url="http://jed-f24m64-9119:8080"
|
HOST=${1:-jedtest.jbr}
|
||||||
url="http://127.0.0.1:8080"
|
url="http://${HOST}:8080"
|
||||||
|
#url="http://127.0.0.1:8080"
|
||||||
|
|
||||||
function PortDown() {
|
function PortDown() {
|
||||||
switches="-s -D $headers -o $result"
|
switches="-s -D $headers -o $result"
|
||||||
echo "{\"shelf\":1,\"resource\":3,\"port\":\"$1\",\"current_flags\":1, \"interest\":8388610}" > $data_file
|
echo "{\"shelf\":1,\"resource\":$ra,\"port\":\"$1\",\"current_flags\":1, \"interest\":8388610}" > $data_file
|
||||||
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/set_port"
|
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/set_port"
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
for f in `seq 1 10`; do
|
for try in `seq 1 100`; do
|
||||||
echo "{\"shelf\":1,\"resource\":3,\"port\":\"$1\"}" > $data_file
|
echo "{\"shelf\":1,\"resource\":$ra,\"port\":\"$1\"}" > $data_file
|
||||||
cat $data_file
|
cat $data_file
|
||||||
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/nc_show_ports"
|
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/nc_show_ports"
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
Kuurl $switches "$url/port/1/3/$1?fields=alias,ip,down"
|
Kuurl $switches "$url/port/1/$ra/$1?fields=alias,ip,down"
|
||||||
json_pp < $result || cat $result
|
json_pp < $result || cat $result
|
||||||
grep '"down".*true' $result && break || :
|
grep '"down".*true' $result && break || :
|
||||||
done
|
done
|
||||||
@@ -70,15 +72,15 @@ function PortDown() {
|
|||||||
|
|
||||||
function PortUp() {
|
function PortUp() {
|
||||||
#set_port 1 3 sta3101 NA NA NA NA 0 NA NA NA NA 8388610
|
#set_port 1 3 sta3101 NA NA NA NA 0 NA NA NA NA 8388610
|
||||||
echo "{\"shelf\":1,\"resource\":3,\"port\":\"$1\",\"current_flags\":0, \"interest\":8388610}" > $data_file
|
echo "{\"shelf\":1,\"resource\":$ra,\"port\":\"$1\",\"current_flags\":0, \"interest\":8388610}" > $data_file
|
||||||
curl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/set_port"
|
curl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/set_port"
|
||||||
sleep 1
|
sleep 1
|
||||||
for f in `seq 1 100`; do
|
for try in `seq 1 100`; do
|
||||||
echo "{\"shelf\":1,\"resource\":3,\"port\":\"$1\"}" > $data_file
|
echo "{\"shelf\":1,\"resource\":$ra,\"port\":\"$1\"}" > $data_file
|
||||||
#Jurl -d"@$data_file" "$url/cli-json/nc_show_ports"
|
#Jurl -d"@$data_file" "$url/cli-json/nc_show_ports"
|
||||||
curl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/nc_show_ports"
|
curl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/nc_show_ports"
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
curl $switches "$url/port/1/3/$1?fields=alias,ip,down"
|
curl $switches "$url/port/1/$ra/$1?fields=alias,ip,down"
|
||||||
json_pp < $result || cat $result
|
json_pp < $result || cat $result
|
||||||
grep '"down".*false' $result && break || :
|
grep '"down".*false' $result && break || :
|
||||||
done
|
done
|
||||||
@@ -91,11 +93,11 @@ function CxToggle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CxCreate() { # alias, port
|
function CxCreate() { # alias, port
|
||||||
echo "{\"alias\":\"$1-A\",\"shelf\":1,\"resource\":3,\"port\":\"$2\",\"type\":\"lf_udp\",\"ip_port\":\"AUTO\",\"is_rate_bursty\":\"NO\",\"min_rate\":164000,\"min_pkt\":-1,\"max_pkt\":0}" > $data_file
|
echo "{\"alias\":\"$1-A\",\"shelf\":1,\"resource\":$ra,\"port\":\"$2\",\"type\":\"lf_udp\",\"ip_port\":\"AUTO\",\"is_rate_bursty\":\"NO\",\"min_rate\":164000,\"min_pkt\":-1,\"max_pkt\":0}" > $data_file
|
||||||
cat $data_file
|
cat $data_file
|
||||||
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/add_endp"
|
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/add_endp"
|
||||||
|
|
||||||
echo "{\"alias\":\"$1-B\",\"shelf\":1,\"resource\":2,\"port\":\"b2000\",\"type\":\"lf_udp\",\"ip_port\":\"AUTO\",\"is_rate_bursty\":\"NO\",\"min_rate\":64000,\"min_pkt\":-1,\"max_pkt\":0}" > $data_file
|
echo "{\"alias\":\"$1-B\",\"shelf\":1,\"resource\":$rb,\"port\":\"b2000\",\"type\":\"lf_udp\",\"ip_port\":\"AUTO\",\"is_rate_bursty\":\"NO\",\"min_rate\":64000,\"min_pkt\":-1,\"max_pkt\":0}" > $data_file
|
||||||
cat $data_file
|
cat $data_file
|
||||||
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/add_endp"
|
Kuurl $switches -H "$accept_json" -H "$content_json" -X POST -d"@$data_file" "$url/cli-json/add_endp"
|
||||||
|
|
||||||
@@ -111,38 +113,39 @@ function CxCreate() { # alias, port
|
|||||||
}
|
}
|
||||||
|
|
||||||
# create some cx
|
# create some cx
|
||||||
for eidcx in `seq $m $n` ; do
|
for eidcx in "${series[@]}" ; do
|
||||||
CxCreate "udp-$eidcx" "sta$((3060 + $eidcx))"
|
CxCreate "udp-$eidcx" "vsta$eidcx"
|
||||||
sleep 1
|
sleep 1
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
||||||
done
|
done
|
||||||
|
|
||||||
sleep 5
|
sleep 4
|
||||||
while true; do
|
for try in 1 2; do
|
||||||
for eidcx in `seq $m $n` ; do
|
for eidcx in "${series[@]}" ; do
|
||||||
|
sleep 1
|
||||||
CxToggle "udp-$eidcx" "STOPPED"
|
CxToggle "udp-$eidcx" "STOPPED"
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
||||||
done
|
done
|
||||||
for sta in `seq 100 120`; do
|
for sta in "${series[@]}"; do
|
||||||
stb=$(( $sta + 3000))
|
PortDown "vsta$sta"
|
||||||
PortDown "sta$stb"
|
|
||||||
done
|
done
|
||||||
for sta in `seq 100 120`; do
|
sleep 5
|
||||||
stb=$(( $sta + 3000))
|
for sta in "${series[@]}"; do
|
||||||
PortUp "sta$stb"
|
PortUp "vsta$sta"
|
||||||
done
|
done
|
||||||
sleep 4
|
sleep 5
|
||||||
for eidcx in `seq $m $n` ; do
|
for eidcx in "${series[@]}" ; do
|
||||||
|
sleep 1
|
||||||
CxToggle "udp-$eidcx" "RUNNING"
|
CxToggle "udp-$eidcx" "RUNNING"
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-A?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
Kuurl $switches -H "$accept_json" "$url/endp/udp-$eidcx-B?fields=name,run"
|
||||||
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
Kuurl $switches -H "$accept_json" "$url/cx/udp-$eidcx?fields=name,state"
|
||||||
done
|
done
|
||||||
sleep 14
|
sleep 20
|
||||||
done
|
done
|
||||||
|
echo "DONE"
|
||||||
#
|
#
|
||||||
@@ -21,6 +21,7 @@ use LANforge::JsonUtils qw(logg err json_request get_links_from get_thru json_po
|
|||||||
|
|
||||||
package main;
|
package main;
|
||||||
# Default values for ye ole cmd-line args.
|
# Default values for ye ole cmd-line args.
|
||||||
|
|
||||||
our $Resource = 1;
|
our $Resource = 1;
|
||||||
our $quiet = "yes";
|
our $quiet = "yes";
|
||||||
our $Host = "localhost";
|
our $Host = "localhost";
|
||||||
@@ -28,9 +29,13 @@ our $Port = 8080;
|
|||||||
our $HostUri = "http://$Host:$Port";
|
our $HostUri = "http://$Host:$Port";
|
||||||
our $Web = LWP::UserAgent->new;
|
our $Web = LWP::UserAgent->new;
|
||||||
our $Decoder = JSON->new->utf8;
|
our $Decoder = JSON->new->utf8;
|
||||||
|
our $use_ssid = "kedtest-wpa2";
|
||||||
|
our $use_pass = "kedtest-wpa2";
|
||||||
|
|
||||||
my $usage = qq("$0 --host {ip or hostname} # connect to this
|
my $usage = qq("$0 --host {ip or hostname} # connect to this
|
||||||
--port {port number} # defaults to 8080
|
--port {port number} # defaults to 8080
|
||||||
|
--ssid {ssid}
|
||||||
|
--pass {passwd}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +49,8 @@ GetOptions
|
|||||||
(
|
(
|
||||||
'host=s' => \$::Host,
|
'host=s' => \$::Host,
|
||||||
'port=i' => \$::Port,
|
'port=i' => \$::Port,
|
||||||
|
'ssid=s' => \$::use_ssid,
|
||||||
|
'pass=s' => \$::use_pass,
|
||||||
) || (print($usage) && exit(1));
|
) || (print($usage) && exit(1));
|
||||||
|
|
||||||
$::HostUri = "http://$Host:$Port";
|
$::HostUri = "http://$Host:$Port";
|
||||||
@@ -69,7 +76,7 @@ for $uri (@$ra_links) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# destroy stations on resource 3
|
# destroy stations
|
||||||
my @radios = ();
|
my @radios = ();
|
||||||
my @destroy_me = ();
|
my @destroy_me = ();
|
||||||
for my $rh_alias_link (@$ra_alias_links) {
|
for my $rh_alias_link (@$ra_alias_links) {
|
||||||
@@ -157,8 +164,8 @@ for $rh_radio (@radios) {
|
|||||||
#'alias'=>'vsta'.$i, # deprecated, use set_port + interest.set_alias
|
#'alias'=>'vsta'.$i, # deprecated, use set_port + interest.set_alias
|
||||||
#'flags'=>68862086144, # has port-down set
|
#'flags'=>68862086144, # has port-down set
|
||||||
'flags'=>142609408,
|
'flags'=>142609408,
|
||||||
'ssid'=>'idtest-1200-wpa2',
|
'ssid'=> $::use_ssid,
|
||||||
'key'=>'idtest-1200-wpa2',
|
'key'=> $::use_pass,
|
||||||
'mac'=>'xx:xx:xx:xx:*:xx',
|
'mac'=>'xx:xx:xx:xx:*:xx',
|
||||||
'mode'=>0,
|
'mode'=>0,
|
||||||
'rate'=>'DEFAULT'
|
'rate'=>'DEFAULT'
|
||||||
|
|||||||
@@ -45,9 +45,16 @@ GetOptions
|
|||||||
|
|
||||||
$HostUri = "http://$Host:$Port";
|
$HostUri = "http://$Host:$Port";
|
||||||
|
|
||||||
my $uri = "/port/1/1/sta0200";
|
my $uri = "/port/1/1/list";
|
||||||
my $rh = json_request($uri);
|
my $rh = json_request($uri);
|
||||||
print Dumper($rh);
|
#print Dumper($rh->{interfaces});
|
||||||
|
for my $rh_e (@{$rh->{interfaces}}) {
|
||||||
|
my @keys = keys(%$rh_e);
|
||||||
|
my $rh_val = $rh_e->{$keys[0]};
|
||||||
|
next if ($keys[0] !~ /sta/);
|
||||||
|
my $resp = json_request($rh_val->{_links}."?fields=alias,port,mode");
|
||||||
|
print Dumper($resp->{interface});
|
||||||
|
sleep 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -210,6 +210,7 @@ def main():
|
|||||||
print("Wanlink is stopped.")
|
print("Wanlink is stopped.")
|
||||||
|
|
||||||
print("Wanlink info:")
|
print("Wanlink info:")
|
||||||
|
<<<<<<< HEAD
|
||||||
lf_r = LFRequest.LFRequest(base_url+"/wl/wl_eg1")
|
lf_r = LFRequest.LFRequest(base_url+"/wl/wl_eg1")
|
||||||
json_response = lf_r.getAsJson()
|
json_response = lf_r.getAsJson()
|
||||||
LFUtils.debug_printer.pprint(json_response)
|
LFUtils.debug_printer.pprint(json_response)
|
||||||
@@ -221,6 +222,9 @@ def main():
|
|||||||
lf_r = LFRequest.LFRequest(base_url+"/wl_ep/wl_eg1-B")
|
lf_r = LFRequest.LFRequest(base_url+"/wl_ep/wl_eg1-B")
|
||||||
json_response = lf_r.getAsJson()
|
json_response = lf_r.getAsJson()
|
||||||
LFUtils.debug_printer.pprint(json_response)
|
LFUtils.debug_printer.pprint(json_response)
|
||||||
|
=======
|
||||||
|
json_response = LFRequest.LFRequest(base_url+"/")
|
||||||
|
>>>>>>> create_wanlink fixes perl dict values
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
63
test_perl_json.sh
Executable file
63
test_perl_json.sh
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
unset proxy
|
||||||
|
unset http_proxy
|
||||||
|
## ----- ----- ----- ----- ----- ----- ----- ----- ----- -----#
|
||||||
|
## tests to exercise perl-json api #
|
||||||
|
## ----- ----- ----- ----- ----- ----- ----- ----- ----- -----#
|
||||||
|
|
||||||
|
|
||||||
|
# ares-f30m64.jbr.candelatech.com
|
||||||
|
HOST=${1:-localhost}
|
||||||
|
BASEURL="http://${HOST}:8080"
|
||||||
|
HELPURL="${BASEURL}/help"
|
||||||
|
FORMURL="${BASEURL}/cli-form"
|
||||||
|
JSONURL="${BASEURL}/cli-json"
|
||||||
|
|
||||||
|
function Get() {
|
||||||
|
[ -f /tmp/$$.result ] && rm -f /tmp/$$.result
|
||||||
|
curl -sq -H 'Accept: application/json' "${BASEURL}${@}" &> /tmp/$$.result
|
||||||
|
wc -l /tmp/$$.result
|
||||||
|
if [[ $? = 0 ]]; then
|
||||||
|
json_reformat < /tmp/$$.result
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# test that we have a connection to lfclient
|
||||||
|
echo "Testing $HOST $BASEURL"
|
||||||
|
Get /port/1/1/eth1 || exit 1
|
||||||
|
|
||||||
|
cd json
|
||||||
|
./port_test.pl --host $HOST --ssid kedtest-wpa2 --pass kedtest-wpa2
|
||||||
|
sleep 1
|
||||||
|
./test_sta_mode.pl --host $HOST
|
||||||
|
sleep 1
|
||||||
|
./json_port_test3.sh $HOST
|
||||||
|
|
||||||
|
|
||||||
|
## ----- ----- ----- ----- ----- ----- ----- ----- ----- -----#
|
||||||
|
|
||||||
|
# create a pair of redirect ports
|
||||||
|
RDD=('rd0a' 'rd0b' 'rd1a' 'rd1b')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# create a wanlink between two of them
|
||||||
|
WL='wl1'
|
||||||
|
WLEP=("${WL}-A" "${WL}-B")
|
||||||
|
|
||||||
|
# create a layer 3 connection between the a-side rdds
|
||||||
|
CX='tcp1'
|
||||||
|
EPS=("${CX}-A" "${CX}-B")
|
||||||
|
|
||||||
|
# start the wanlink
|
||||||
|
|
||||||
|
# start the layer3
|
||||||
|
|
||||||
|
# print port stats after 30 seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
###
|
||||||
|
###
|
||||||
Reference in New Issue
Block a user