[PATCH v2 lkp-tests] lib: add transfer_port.sh

Provide a login port for user, determine whether to send the ssh_port message based on the uuid. Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port" + break + done +} + -- 2.23.0

On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port"
^^^ this line is not aligned. Thanks, Baijing
+ break + done +} + -- 2.23.0

On Wed, Sep 30, 2020 at 04:29:51PM +0800, Bai Jing wrote:
On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port"
^^^ this line is not aligned. Thanks, Baijing
Ok, I got it. Thanks, Yale
+ break + done +} + -- 2.23.0

On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null
This line may be too long, can use '/' to split or put options into an array. Thanks, RenWen
+ [ $? -eq 0 ] || continue + echo "$port" + break + done +} + -- 2.23.0

On Wed, Sep 30, 2020 at 05:03:35PM +0800, Ren Wen wrote:
On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null
This line may be too long, can use '/' to split or put options into an array.
Thanks, RenWen
Ok, I got it. Thanks, Yale
+ [ $? -eq 0 ] || continue + echo "$port" + break + done +} + -- 2.23.0

On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return
+ for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333))
"10"(port range length?) and "11333" (port base?) we need define this 2 field. ssh_port_len and ssh_port_base?
+ ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port" + break + done +} + -- 2.23.0
-- Thanks. chief <tongqunfeng@huawei.com>

On Fri, Oct 09, 2020 at 11:21:29AM +0800, Tong Qunfeng wrote:
On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale <ylzhangah@qq.com> Signed-off-by: Luan Shengde <luanshengde2@huawei.com> --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return
+ for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333))
"10"(port range length?) and "11333" (port base?) we need define this 2 field. ssh_port_len and ssh_port_base?
Ok, I got it. Thanks, Yale
+ ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port" + break + done +} + -- 2.23.0
-- Thanks. chief <tongqunfeng@huawei.com>

On Fri, Oct 09, 2020 at 03:09:11PM +0800, Zhang Yale wrote:
On Fri, Oct 09, 2020 at 11:21:29AM +0800, Tong Qunfeng wrote:
On Wed, Sep 30, 2020 at 03:41:01PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
+sshr_ip=$LKP_SERVER +sshr_port=5050
+ for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333))
"10"(port range length?) and "11333" (port base?) we need define this 2 field. ssh_port_len and ssh_port_base?
Ok, I got it.
Thanks, Yale
need discussion. topo may like this: monitor lkp-tests port_rangeA port_rangeB port_22 <internet_user_side>---api.compass-ci.openeuler.org---nat?-+-scheduler-+-<testbox_side> +---sshr----+ port_rangeC -- Thanks. chief <tongqunfeng@huawei.com>
participants (4)
-
Bai Jing
-
Ren Wen
-
Tong Qunfeng
-
Zhang Yale