fix: non-redfish baremetal might support jnlp console

This commit is contained in:
Qiu Jian
2020-04-15 23:35:12 +08:00
parent 1284538005
commit 309addc00a
3 changed files with 21 additions and 8 deletions
+1 -6
View File
@@ -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
+18
View File
@@ -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{
{
+2 -2
View File
@@ -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,
}