-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supermicro X13 inventory/firmware support FS-1671 #394
base: main
Are you sure you want to change the base?
Changes from all commits
3b0f1ad
0ce25c2
9be85e1
ecdd50d
0b78af1
3bb5ad0
9a7a3e9
8a5cbb2
a5eaf9f
4bf550a
9ea6909
1c1c0c5
2a3bfc2
663935d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,10 +175,14 @@ func (c *Client) Open(ctx context.Context) (err error) { | |
return err | ||
} | ||
|
||
if !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=mainmenu`)) && | ||
!bytes.Contains(body, []byte(`url_redirect.cgi?url_name=topmenu`)) { | ||
// X13 appears to have dropped the initial 'mainmenu' redirect | ||
if !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=topmenu`)) { | ||
return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, "unexpected response contents")) | ||
} | ||
// if !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=mainmenu`)) && | ||
// !bytes.Contains(body, []byte(`url_redirect.cgi?url_name=topmenu`)) { | ||
// return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, "unexpected response contents")) | ||
// } | ||
|
||
contentsTopMenu, status, err := c.serviceClient.query(ctx, "cgi/url_redirect.cgi?url_name=topmenu", http.MethodGet, nil, nil, 0) | ||
if err != nil { | ||
|
@@ -197,6 +201,7 @@ func (c *Client) Open(ctx context.Context) (err error) { | |
c.serviceClient.setCsrfToken(csrfToken) | ||
|
||
c.bmc, err = c.bmcQueryor(ctx) | ||
|
||
if err != nil { | ||
return closeWithError(ctx, errors.Wrap(bmclibErrs.ErrLoginFailed, err.Error())) | ||
} | ||
|
@@ -281,17 +286,36 @@ func (c *Client) ResetBiosConfiguration(ctx context.Context) (err error) { | |
} | ||
|
||
func (c *Client) bmcQueryor(ctx context.Context) (bmcQueryor, error) { | ||
x11 := newX11Client(c.serviceClient, c.log) | ||
x12 := newX12Client(c.serviceClient, c.log) | ||
x11bmc := newX11Client(c.serviceClient, c.log) | ||
x12bmc := newX12Client(c.serviceClient, c.log) | ||
x13bmc := newX13Client(c.serviceClient, c.log) | ||
|
||
var queryor bmcQueryor | ||
|
||
for _, bmc := range []bmcQueryor{x11, x12} { | ||
expected := func(deviceModel string, bmc bmcQueryor) bool { | ||
deviceModel = strings.ToLower(deviceModel) | ||
switch bmc.(type) { | ||
case *x11: | ||
if strings.HasPrefix(deviceModel, "x11") { | ||
return true | ||
} | ||
case *x12: | ||
if strings.HasPrefix(deviceModel, "x12") { | ||
return true | ||
} | ||
case *x13: | ||
if strings.HasPrefix(deviceModel, "x13") { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
for _, bmc := range []bmcQueryor{x11bmc, x12bmc, x13bmc} { | ||
var err error | ||
|
||
// Note to maintainers: x12 lacks support for the ipmi.cgi endpoint, | ||
// which will lead to our graceful handling of ErrXMLAPIUnsupported below. | ||
_, err = bmc.queryDeviceModel(ctx) | ||
deviceModel, err := bmc.queryDeviceModel(ctx) | ||
if err != nil { | ||
if errors.Is(err, ErrXMLAPIUnsupported) { | ||
continue | ||
|
@@ -300,6 +324,11 @@ func (c *Client) bmcQueryor(ctx context.Context) (bmcQueryor, error) { | |
return nil, errors.Wrap(ErrModelUnknown, err.Error()) | ||
} | ||
|
||
// ensure the device model matches the expected queryor | ||
if !expected(deviceModel, bmc) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. include a |
||
continue | ||
} | ||
|
||
queryor = bmc | ||
break | ||
} | ||
|
@@ -309,8 +338,8 @@ func (c *Client) bmcQueryor(ctx context.Context) (bmcQueryor, error) { | |
} | ||
|
||
model := strings.ToLower(queryor.deviceModel()) | ||
if !strings.HasPrefix(model, "x12") && !strings.HasPrefix(model, "x11") { | ||
return nil, errors.Wrap(ErrModelUnsupported, "expected one of X11* or X12*, got:"+model) | ||
if !strings.HasPrefix(model, "x13") && !strings.HasPrefix(model, "x12") && !strings.HasPrefix(model, "x11") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With your new |
||
return nil, errors.Wrap(ErrModelUnsupported, "expected one of X11*, X12* or X13*, got:"+model) | ||
} | ||
|
||
return queryor, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note, if response is valid JSON but isn't a
redfish.Task
I believe you'll get no error and zero value for theTask
. It might be worth a sanity check that the task id isn't an empty string here.