Signed-off-by: Zhang Yale zhangyale3@huawei.com --- daemon/sshd | 63 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 20 deletions(-)
diff --git a/daemon/sshd b/daemon/sshd index 98f31d77..6d958dc6 100755 --- a/daemon/sshd +++ b/daemon/sshd @@ -1,6 +1,10 @@ #!/bin/sh # pub_key # email +# uuid + +. $LKP_SRC/lib/transfer_port.sh +. $LKP_SRC/lib/http.sh
run_ssh() { @@ -11,40 +15,59 @@ run_ssh() systemctl start sshd }
-compose_email() +data_success() { - deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S") data="To: $email -Subject: [NOTIFY compass-ci] $testbox ready to ssh +Subject: [NOTIFY Compass-ci] $testbox ready to use
-Dear $email: - Thanks for your participation in Kunpeng and software ecosystem! - According to your application, $testbox has been provisioned. - The datails are as follows: +Dear $user_name: + Thanks for your participation in software ecosystem! + According to your application, $testbox has been provisioned. + The datails are as follows:
- Login: - ssh root@$PUB_IP - Due time: - $deadline + login: + ssh root@api.compass-ci.openeuler.org -p $port + Due time: + $deadline
- HW: - nr_cpu: $nr_cpu - memory: $memory - testbox: $testbox - OS: - $os $os_version $os_arch +Regards +Compass-ci +" +} + +data_failure() +{ + data="To: $email +Subject: [NOTIFY Compass-ci] Applying $testbox failed + +Dear $user_name: + Sorry to inform you that your application failed. + You may need to wait for a while and then try again.
Regards -compass-ci +Compass-ci " }
+compose_email() +{ + deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S") + if [ -n "$port" ]; then + data_success + else + data_failure + fi +} + run_email() { - [ -n "$email" ] || return 0 + [ -n "$email" ] && [ -n "$uuid" ] || return 0 + user_name=$(echo "$email" | awk -F '@' '{print $1}') compose_email - curl -XPOST "$MAIL_HOST:$MAIL_PORT/send_mail_text" -d "$data" + curl -XPOST "${MAIL_HOST:-$LKP_SERVER}:${MAIL_PORT:-11312}/send_mail_text" -d "$data" }
run_ssh +port=$(get_port) +report_ssh_port $port run_email