diff --git a/connect/connect.go b/connect/connect.go index 27ba7af..cb84f8e 100644 --- a/connect/connect.go +++ b/connect/connect.go @@ -13,7 +13,6 @@ import ( "github.com/metal-stack/go-hal" "github.com/metal-stack/go-hal/internal/dmi" "github.com/metal-stack/go-hal/internal/redfish" - "github.com/metal-stack/go-hal/internal/vendors/lenovo" "github.com/metal-stack/go-hal/internal/vendors/supermicro" "github.com/metal-stack/go-hal/pkg/api" ) @@ -31,8 +30,6 @@ func InBand(log logger.Logger) (hal.InBand, error) { b.Vendor = api.GuessVendor(b.VendorString) log.Debugw("connect", "vendor", b) switch b.Vendor { - case api.VendorLenovo: - return lenovo.InBand(b, log) case api.VendorSupermicro, api.VendorNovarion: return supermicro.InBand(b, log) case api.VendorVagrant: @@ -62,8 +59,6 @@ func OutBand(ip string, ipmiPort int, user, password string, log logger.Logger, b.Vendor = api.GuessVendor(b.VendorString) log.Debugw("connect", "board", b) switch b.Vendor { - case api.VendorLenovo: - return lenovo.OutBand(r, b), nil case api.VendorSupermicro, api.VendorNovarion: return supermicro.OutBand(r, b, ip, ipmiPort, user, password, log) case api.VendorVagrant: diff --git a/connect/connect_test.go b/connect/connect_test.go deleted file mode 100644 index 8e2bc8e..0000000 --- a/connect/connect_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package connect - -// func _TestDetectInBand(t *testing.T) { -// tests := []struct { -// name string -// want api.Vendor -// wantErr bool -// }{ -// { -// name: "simple", -// want: api.VendorLenovo, -// wantErr: false, -// }, -// } -// for i := range tests { -// tt := tests[i] -// t.Run(tt.name, func(t *testing.T) { -// got, err := inBand() -// if (err != nil) != tt.wantErr { -// t.Errorf("DetectInBand() error = %v, wantErr %v", err, tt.wantErr) -// return -// } -// if !reflect.DeepEqual(got, tt.want) { -// t.Errorf("DetectInBand() = %v, want %v", got, tt.want) -// } -// }) -// } -// } diff --git a/internal/ipmi/ipmitool.go b/internal/ipmi/ipmitool.go index a3a093e..9b0ecac 100644 --- a/internal/ipmi/ipmitool.go +++ b/internal/ipmi/ipmitool.go @@ -621,7 +621,7 @@ func GetBootOrderQualifiers(bootTarget hal.BootTarget, vendor api.Vendor) (uefiQ switch vendor { case api.VendorSupermicro, api.VendorNovarion: bootDevQualifier = supermicroHDQualifier - case api.VendorLenovo, api.VendorDell, api.VendorVagrant, api.VendorUnknown, api.VendorGigabyte: + case api.VendorDell, api.VendorVagrant, api.VendorUnknown, api.VendorGigabyte: fallthrough default: bootDevQualifier = hdQualifier diff --git a/internal/ipmi/rawCommands_test.go b/internal/ipmi/rawCommands_test.go index 5c80f72..5cf2553 100644 --- a/internal/ipmi/rawCommands_test.go +++ b/internal/ipmi/rawCommands_test.go @@ -25,10 +25,6 @@ func TestRawCommands(t *testing.T) { require.Equal(t, []string{"raw", "6", "71", "2", "1"}, RawEnableUser(uid)) require.Equal(t, []string{"raw", "6", "71", "130", "2", "115", "101", "99", "114", "101", "116", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"}, RawSetUserPassword(uid, userPassword)) - require.Equal(t, []string{"raw", "0", "8", "5", "224", "4", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetPXE, api.VendorLenovo)) - require.Equal(t, []string{"raw", "0", "8", "5", "224", "8", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetDisk, api.VendorLenovo)) - require.Equal(t, []string{"raw", "0", "8", "5", "160", "24", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetBIOS, api.VendorLenovo)) - require.Equal(t, []string{"raw", "0", "8", "5", "224", "4", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetPXE, api.VendorSupermicro)) require.Equal(t, []string{"raw", "0", "8", "5", "224", "36", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetDisk, api.VendorSupermicro)) require.Equal(t, []string{"raw", "0", "8", "5", "160", "24", "0", "0", "0"}, RawSetSystemBootOptions(hal.BootTargetBIOS, api.VendorSupermicro)) diff --git a/internal/vendors/lenovo/lenovo.go b/internal/vendors/lenovo/lenovo.go deleted file mode 100644 index 0450b9d..0000000 --- a/internal/vendors/lenovo/lenovo.go +++ /dev/null @@ -1,238 +0,0 @@ -package lenovo - -import ( - "fmt" - - "github.com/gliderlabs/ssh" - "github.com/google/uuid" - "github.com/metal-stack/go-hal" - "github.com/metal-stack/go-hal/internal/inband" - "github.com/metal-stack/go-hal/internal/ipmi" - "github.com/metal-stack/go-hal/internal/outband" - "github.com/metal-stack/go-hal/internal/redfish" - "github.com/metal-stack/go-hal/pkg/api" - "github.com/metal-stack/go-hal/pkg/logger" -) - -var ( - // errorNotImplemented for all functions that are not implemented yet - errorNotImplemented = fmt.Errorf("not implemented yet") -) - -const ( - vendor = api.VendorLenovo -) - -type ( - inBand struct { - *inband.InBand - } - outBand struct { - *outband.OutBand - } - bmcConnection struct { - *inBand - } - bmcConnectionOutBand struct { - *outBand - } -) - -// InBand creates an inband connection to a Lenovo server. -func InBand(board *api.Board, log logger.Logger) (hal.InBand, error) { - ib, err := inband.New(board, true, log) - if err != nil { - return nil, err - } - return &inBand{ - InBand: ib, - }, nil -} - -// OutBand creates an outband connection to a Lenovo server. -func OutBand(r *redfish.APIClient, board *api.Board) hal.OutBand { - return &outBand{ - OutBand: outband.ViaRedfish(r, board), - } -} - -// InBand -func (ib *inBand) PowerOff() error { - return ib.IpmiTool.SetChassisControl(ipmi.ChassisControlPowerDown) -} - -func (ib *inBand) PowerCycle() error { - return ib.IpmiTool.SetChassisControl(ipmi.ChassisControlPowerCycle) -} - -func (ib *inBand) PowerReset() error { - return ib.IpmiTool.SetChassisControl(ipmi.ChassisControlHardReset) -} - -func (ib *inBand) IdentifyLEDState(state hal.IdentifyLEDState) error { - return ib.IpmiTool.SetChassisIdentifyLEDState(state) -} - -func (ib *inBand) IdentifyLEDOn() error { - return ib.IpmiTool.SetChassisIdentifyLEDOn() -} - -func (ib *inBand) IdentifyLEDOff() error { - return ib.IpmiTool.SetChassisIdentifyLEDOff() -} - -func (ib *inBand) BootFrom(bootTarget hal.BootTarget) error { - return ib.IpmiTool.SetBootOrder(bootTarget, vendor) -} - -func (ib *inBand) SetFirmware(hal.FirmwareMode) error { - return errorNotImplemented //TODO -} - -func (ib *inBand) Describe() string { - return "InBand connected to Lenovo" -} - -func (ib *inBand) BMCConnection() api.BMCConnection { - return &bmcConnection{ - inBand: ib, - } -} - -func (c *bmcConnection) BMC() (*api.BMC, error) { - return c.IpmiTool.BMC() -} - -func (c *bmcConnection) PresentSuperUser() api.BMCUser { - return api.BMCUser{ - Name: "USERID", - Id: "2", - ChannelNumber: 1, - } -} - -func (c *bmcConnection) SuperUser() api.BMCUser { - return api.BMCUser{ - Name: "root", - Id: "4", - ChannelNumber: 1, - } -} - -func (c *bmcConnection) User() api.BMCUser { - return api.BMCUser{ - Name: "metal", - Id: "3", - ChannelNumber: 1, - } -} - -func (c *bmcConnection) Present() bool { - return c.IpmiTool.DevicePresent() -} - -func (c *bmcConnection) CreateUserAndPassword(user api.BMCUser, privilege api.IpmiPrivilege) (string, error) { - return c.IpmiTool.CreateUser(user, privilege, "", c.Board().Vendor.PasswordConstraints(), ipmi.LowLevel) -} - -func (c *bmcConnection) CreateUser(user api.BMCUser, privilege api.IpmiPrivilege, password string) error { - _, err := c.IpmiTool.CreateUser(user, privilege, password, nil, ipmi.LowLevel) - return err -} - -func (c *bmcConnection) NeedsPasswordChange(user api.BMCUser, password string) (bool, error) { - return true, nil -} - -func (c *bmcConnection) ChangePassword(user api.BMCUser, newPassword string) error { - return c.IpmiTool.ChangePassword(user, newPassword, ipmi.LowLevel) -} - -func (c *bmcConnection) SetUserEnabled(user api.BMCUser, enabled bool) error { - return c.IpmiTool.SetUserEnabled(user, enabled, ipmi.LowLevel) -} - -func (ib *inBand) ConfigureBIOS() (bool, error) { - //return false, errorNotImplemented // do not throw an error to not break manual tests - return false, nil //TODO https://github.com/metal-stack/go-hal/issues/11 -} - -func (ib *inBand) EnsureBootOrder(bootloaderID string) error { - //return errorNotImplemented // do not throw an error to not break manual tests - return nil //TODO https://github.com/metal-stack/go-hal/issues/11 -} - -// OutBand -func (ob *outBand) UUID() (*uuid.UUID, error) { - u, err := ob.Redfish.MachineUUID() - if err != nil { - return nil, err - } - us, err := uuid.Parse(u) - if err != nil { - return nil, err - } - return &us, nil -} - -func (ob *outBand) PowerState() (hal.PowerState, error) { - return ob.Redfish.PowerState() -} - -func (ob *outBand) PowerOff() error { - return ob.Redfish.PowerOff() -} - -func (ob *outBand) PowerOn() error { - return ob.Redfish.PowerReset() // PowerOn is not supported -} - -func (ob *outBand) PowerReset() error { - return ob.Redfish.PowerReset() -} - -func (ob *outBand) PowerCycle() error { - return ob.Redfish.PowerReset() // PowerCycle is not supported -} - -func (ob *outBand) IdentifyLEDState(state hal.IdentifyLEDState) error { - return errorNotImplemented //TODO https://github.com/metal-stack/go-hal/issues/11 -} - -func (ob *outBand) IdentifyLEDOn() error { - return errorNotImplemented //TODO https://github.com/metal-stack/go-hal/issues/11 -} - -func (ob *outBand) IdentifyLEDOff() error { - return errorNotImplemented //TODO https://github.com/metal-stack/go-hal/issues/11 -} - -func (ob *outBand) BootFrom(target hal.BootTarget) error { - return errorNotImplemented -} - -func (ob *outBand) Describe() string { - return "OutBand connected to Lenovo" -} - -func (ob *outBand) Console(s ssh.Session) error { - return errorNotImplemented // https://github.com/metal-stack/go-hal/issues/11 -} - -func (ob *outBand) UpdateBIOS(url string) error { - return nil -} - -func (ob *outBand) UpdateBMC(url string) error { - return nil -} - -func (ob *outBand) BMCConnection() api.OutBandBMCConnection { - return &bmcConnectionOutBand{ - outBand: ob, - } -} - -func (c *bmcConnectionOutBand) BMC() (*api.BMC, error) { - return c.Redfish.BMC() -} diff --git a/pkg/api/types.go b/pkg/api/types.go index 21b9e68..784a771 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -194,8 +194,6 @@ const ( VendorSupermicro // VendorNovarion identifies all Novarion servers VendorNovarion - // VendorLenovo identifies all Lenovo servers - VendorLenovo // VendorDell identifies all Dell servers VendorDell // VendorVagrant is a virtual machine. @@ -208,13 +206,12 @@ var ( vendors = [...]string{ VendorSupermicro: "Supermicro", VendorNovarion: "Novarion-Systems", - VendorLenovo: "Lenovo", VendorDell: "Dell", VendorVagrant: "Vagrant", VendorUnknown: "UNKNOWN", VendorGigabyte: "Giga Computing", } - allVendors = [...]Vendor{VendorSupermicro, VendorNovarion, VendorLenovo, VendorDell, VendorVagrant, VendorUnknown, VendorGigabyte} + allVendors = [...]Vendor{VendorSupermicro, VendorNovarion, VendorDell, VendorVagrant, VendorUnknown, VendorGigabyte} ) func (v Vendor) String() string { return vendors[v] } diff --git a/pkg/api/types_test.go b/pkg/api/types_test.go index 7974ffc..b75564b 100644 --- a/pkg/api/types_test.go +++ b/pkg/api/types_test.go @@ -12,7 +12,6 @@ func TestVendor_String(t *testing.T) { }{ {name: "smc", v: VendorSupermicro, want: "Supermicro"}, {name: "dell", v: VendorDell, want: "Dell"}, - {name: "lenovo", v: VendorLenovo, want: "Lenovo"}, {name: "unknown", v: VendorUnknown, want: "UNKNOWN"}, } for i := range tests { @@ -33,8 +32,6 @@ func TestGuessVendor(t *testing.T) { }{ {name: "smc", vendor: "Supermicro", want: VendorSupermicro}, {name: "smc with space", vendor: " Supermicro ", want: VendorSupermicro}, - {name: "lenovo", vendor: "Lenovo", want: VendorLenovo}, - {name: "lenovolower", vendor: "lenovo", want: VendorLenovo}, {name: "empty", vendor: "", want: VendorUnknown}, {name: "unknown", vendor: "unknown", want: VendorUnknown}, {name: "vagrant", vendor: "vagrant", want: VendorVagrant},