From 309addc00a7211f21919c79649ea46563a432554 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Wed, 15 Apr 2020 23:35:12 +0800 Subject: [PATCH] fix: non-redfish baremetal might support jnlp console --- pkg/baremetal/handler/handlers.go | 7 +------ pkg/baremetal/manager.go | 18 ++++++++++++++++++ pkg/baremetal/profiles/profiles.go | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pkg/baremetal/handler/handlers.go b/pkg/baremetal/handler/handlers.go index f2370993d9..4927e3581b 100644 --- a/pkg/baremetal/handler/handlers.go +++ b/pkg/baremetal/handler/handlers.go @@ -163,12 +163,7 @@ func handleBaremetalCdromTask(ctx *Context, bm *baremetal.SBaremetalInstance) { } func handleBaremetalJnlpTask(ctx *Context, bm *baremetal.SBaremetalInstance) { - cli := bm.GetRedfishCli(ctx) - if cli == nil { - ctx.ResponseError(httperrors.NewNotSupportedError("Redfish API")) - return - } - jnlp, err := cli.GetConsoleJNLP(ctx) + jnlp, err := bm.GetConsoleJNLP(ctx) if err != nil { ctx.ResponseError(errors.Wrap(err, "GetConsoleJNLP")) return diff --git a/pkg/baremetal/manager.go b/pkg/baremetal/manager.go index 978f75d552..f03f09b7bc 100644 --- a/pkg/baremetal/manager.go +++ b/pkg/baremetal/manager.go @@ -64,6 +64,7 @@ import ( "yunion.io/x/onecloud/pkg/util/influxdb" "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/redfish" + "yunion.io/x/onecloud/pkg/util/redfish/bmconsole" "yunion.io/x/onecloud/pkg/util/ssh" "yunion.io/x/onecloud/pkg/util/sysutils" ) @@ -1935,6 +1936,23 @@ func (b *SBaremetalInstance) fetchPowerThermalMetrics(ctx context.Context) ([]in return powerMetrics, thermalMetrics, nil } +func (b *SBaremetalInstance) GetConsoleJNLP(ctx context.Context) (string, error) { + cli := b.GetRedfishCli(ctx) + if cli != nil { + return cli.GetConsoleJNLP(ctx) + } + conf := b.GetIPMIConfig() + bmc := bmconsole.NewBMCConsole(conf.IpAddr, conf.Username, conf.Password, false) + manufacture := b.GetManufacture() + switch strings.ToLower(manufacture) { + case "hp", "hpe": + return bmc.GetIloConsoleJNLP(ctx) + case "dell", "dell inc.": + return bmc.GetIdracConsoleJNLP(ctx, "", "") + } + return "", httperrors.NewNotImplementedError("Unsupported manufacture %s", manufacture) +} + func (b *SBaremetalInstance) getTags() []influxdb.SKeyValue { tags := []influxdb.SKeyValue{ { diff --git a/pkg/baremetal/profiles/profiles.go b/pkg/baremetal/profiles/profiles.go index 06faacf96f..bb604dafca 100644 --- a/pkg/baremetal/profiles/profiles.go +++ b/pkg/baremetal/profiles/profiles.go @@ -43,7 +43,7 @@ func InspurProfile() IPMIProfile { func LenovoProfile() IPMIProfile { return IPMIProfile{ - LanChannel: []int{8}, + LanChannel: []int{1, 8}, RootName: "root", RootId: 2, } @@ -51,7 +51,7 @@ func LenovoProfile() IPMIProfile { func HpProfile() IPMIProfile { return IPMIProfile{ - LanChannel: []int{2}, + LanChannel: []int{1, 2}, RootName: "root", RootId: 1, }