[PATCH v4 lkp-tests] sshd: send emails to login services for users

Signed-off-by: Zhang Yale <ylzhangah@qq.com> --- daemon/sshd | 63 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/daemon/sshd b/daemon/sshd index 98f31d77..4a94ad45 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 $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@api.compass-ci.openeuler.org -p $port + Due time: + $deadline -Dear $email: - Thanks for your participation in Kunpeng and software ecosystem! - According to your application, $testbox has been provisioned. - The datails are as follows: +Regards +Compass-ci +" +} - Login: - ssh root@$PUB_IP - Due time: - $deadline +data_failure() +{ + data="To: $email +Subject: [NOTIFY Compass-ci] Applying $testbox failed - HW: - nr_cpu: $nr_cpu - memory: $memory - testbox: $testbox - OS: - $os $os_version $os_arch +Dear $user_name: + Sorry to inform you that your application failed. + You may need to wait for a while and then thy 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 -- 2.23.0

On Wed, Oct 14, 2020 at 05:31:03PM +0800, Zhang Yale wrote:
On Wed, Oct 14, 2020 at 12:23:47PM +0800, Wu Fengguang wrote:
+ ssh root@api.compass-ci.openeuler.org -p $port
Is it really "api."? Looks not very user friendly.
Thanks, Fengguang
Whether to apply for a new domain name with remove "api."?
Let's do with it for now. In future we may try applying a shorter DNS name to be more user friendly. Thanks, Fengguang

On Wed, Oct 14, 2020 at 07:42:41PM +0800, Wu Fengguang wrote:
On Wed, Oct 14, 2020 at 05:31:03PM +0800, Zhang Yale wrote:
On Wed, Oct 14, 2020 at 12:23:47PM +0800, Wu Fengguang wrote:
+ ssh root@api.compass-ci.openeuler.org -p $port
Is it really "api."? Looks not very user friendly.
Thanks, Fengguang
Whether to apply for a new domain name with remove "api."?
Let's do with it for now. In future we may try applying a shorter DNS name to be more user friendly.
Thanks, Fengguang
domain "compass-ci.openeuler.org" has not been applied yet and not ready to use. I'll update the script when the new domain is ready. Thanks, Yale

+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. + The datails are as follows:
details
+ + login: + ssh root@api.compass-ci.openeuler.org -p $port + Due time: + $deadline
+Dear $user_name: + Sorry to inform you that your application failed. + You may need to wait for a while and then thy again.
try Thanks, Jiaxin

On Wed, Oct 14, 2020 at 03:12:13PM +0800, Lin Jiaxin wrote:
+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. + The datails are as follows:
details
+ + login: + ssh root@api.compass-ci.openeuler.org -p $port + Due time: + $deadline
+Dear $user_name: + Sorry to inform you that your application failed. + You may need to wait for a while and then thy again.
try
Thanks, Jiaxin
Ok, I got it. Thanks, Yale
participants (3)
-
Lin Jiaxin
-
Wu Fengguang
-
Zhang Yale