fix: baremetal server ssh no ip for project user (#25840)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2026-10-10 11:49:22 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 3f51b0f7c7
commit 792971e000
2 changed files with 7 additions and 4 deletions
+3 -3
View File
@@ -217,13 +217,13 @@ func handleSshShell(ctx context.Context, w http.ResponseWriter, r *http.Request)
}
switch sshConnInfo.ResourceType {
case "server":
err = tryServer()
err := tryServer()
if err != nil {
httperrors.GeneralServerError(ctx, w, err)
return
}
case "host":
err = tryHost()
err := tryHost()
if err != nil {
httperrors.GeneralServerError(ctx, w, err)
return
@@ -233,7 +233,7 @@ func handleSshShell(ctx context.Context, w http.ResponseWriter, r *http.Request)
tryServer,
tryHost,
} {
err = try()
err := try()
if err == nil {
s := session.NewSshSession(ctx, env.ClientSessin, sshConnInfo)
handleSshSession(ctx, s, w)
+4 -1
View File
@@ -24,9 +24,11 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modules/compute"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
webconsole_options "yunion.io/x/onecloud/pkg/webconsole/options"
)
type SSshConnectionInfo struct {
@@ -60,7 +62,8 @@ func resolveServerIPPortById(ctx context.Context, s *mcclient.ClientSession, id
True := true
input.Details = &True
input.ServerFilterListInput.Scope = "max"
result, err := compute.Servernetworks.List(s, jsonutils.Marshal(input))
adminSession := auth.GetAdminSession(ctx, webconsole_options.Options.Region)
result, err := compute.Servernetworks.List(adminSession, jsonutils.Marshal(input))
if err != nil {
return "", 0, nil, errors.Wrap(err, "Servernetworks.List")
}