Signed-off-by: Zhang Yale ylzhangah@qq.com Signed-off-by: Luan Shengde luanshengde2@huawei.com --- daemon/sshd | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
diff --git a/daemon/sshd b/daemon/sshd index d1fcae52..35809ffe 100755 --- a/daemon/sshd +++ b/daemon/sshd @@ -3,11 +3,9 @@ # email # uuid
+. $LKP_SRC/lib/transfer_port.sh . $LKP_SRC/lib/http.sh
-sshr_ip=$LKP_SERVER -sshr_port=5050 - run_ssh() { [ -n "$pub_key" ] || return @@ -17,49 +15,46 @@ run_ssh() systemctl start sshd }
-compose_email() +data_success() { - deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S") - if [ -n $port ]; then - data="To: $email + data="To: $email Subject: [NOTIFY compass-ci] $testbox ready to use
Dear $user_name: Thanks for your participation in software ecosystem! According to your application, $testbox has been provisioned. - Please use the following command to login: + The datails are as follows:
- ssh root@api.compass-ci.openeuler.org -p $port + login: ssh root@api.compass-ci.openeuler.org -p $port + Due time: $deadline
Regards -compassi-ci +compass-ci " - else - data="To: $email +} + +data_failure() +{ + data="To: $email Subject: [NOTIFY compass-ci] Applying $testbox failed
Dear $user_name: - Sorry to inform you than your application failed. - - You may need to wait sometime and then have a second try. + Sorry to inform you that your application failed. + You may need to wait for a while and then have a second try.
Regards compass-ci " - fi }
-get_port() +compose_email() { - [ -n "$uuid" ] || return - for i in $(seq 1 10) - do - port=$(($(date +%s%N)%10+11333)) - ssh -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -Nf -R $port:$PUB_IP:22 sshr@"$sshr_ip" -p "$sshr_port" > out 2>&1 - [ -z "`grep -i "error" out`" ] || continue - return "$port" - break - done + deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S") + if [ -n "$port" ]; then + data_success + else + data_failure + fi }
run_email() @@ -71,6 +66,6 @@ run_email() }
run_ssh -get_port +port=$(get_port) report_ssh_port $port run_email