extend token time limit

This commit is contained in:
Jake 2024-07-18 09:15:59 +08:00
parent 130968e4a9
commit 0693cb6876
1 changed files with 17 additions and 23 deletions

View File

@ -1,11 +1,5 @@
package slurm
import (
"gitlink.org.cn/JointCloud/pcm-hpc/utils"
gossh "golang.org/x/crypto/ssh"
"strings"
)
type client struct {
adapterId string
clusterId string
@ -55,23 +49,23 @@ func newClient(options ClientOptions) (Client, error) {
adaptMode: options.AdaptMode,
clientVersion: options.ClientVersion,
}
cli := utils.Cli{
Addr: strings.Split(options.URL, ":")[1][2:],
User: options.CmdUserName,
Pwd: options.Password,
}
// 建立连接对象
cl, _ := cli.ConnectWithPrivateKey()
// 退出时关闭连接
defer func(Client *gossh.Client) {
err := Client.Close()
if err != nil {
}
}(cl.Client)
res, _ := cl.Run(`scontrol token username=root lifespan=30000`)
arr := strings.Split(res, "=")
c.token = strings.Replace(arr[1], "\n", "", -1)
//cli := utils.Cli{
// Addr: strings.Split(options.URL, ":")[1][2:],
// User: options.CmdUserName,
// Pwd: options.Password,
//}
//// 建立连接对象
//cl, _ := cli.ConnectWithPrivateKey()
//// 退出时关闭连接
//defer func(Client *gossh.Client) {
// err := Client.Close()
// if err != nil {
//
// }
//}(cl.Client)
//res, _ := cl.Run(`scontrol token username=root lifespan=30000`)
//arr := strings.Split(res, "=")
//c.token = strings.Replace(arr[1], "\n", "", -1)
return c, nil
}