Minor refactor and update README.md

This commit is contained in:
David J. Allen 2023-09-29 09:32:06 -06:00
parent 2a6ffd16bb
commit 9f848113c7
3 changed files with 16 additions and 12 deletions

View file

@ -1,7 +1,8 @@
# Magellan # Magellan
Magellan is a small tool designed to scan a network and collect BMC information Magellan is a board management controller discovery tool designed to scan a network
to load the data into an [`hms-smd`](https://github.com/alexlovelltroy/hms-smd/tree/master) instance. and collect information about a BMC node and load that data into an
[`hms-smd`](https://github.com/bikeshack/smd/tree/master) instance.
## How It Works ## How It Works
@ -13,9 +14,13 @@ Magellan is designed to do three things:
Magellan first tries to probe for specified hosts using the [`dora`](https://github.com/bmc-toolbox/dora) Magellan first tries to probe for specified hosts using the [`dora`](https://github.com/bmc-toolbox/dora)
API. If that fails, it then tries to use its own built-in, simpler scanner as a fallback. API. If that fails, it then tries to use its own built-in, simpler scanner as a fallback.
Next, it tries to query information about the BMC node using `bmclib` functions, but requires This is done by sending a raw TCP request to a number of potential hosts over a
access to a redfish interface on the node to work. Once the BMC information is received, network, and noting which requests are successful. At this point, `magellan` sees
it is then stored into `hms-smd` using its API. no difference between a services.
Next, it tries to query information about the BMC node using `bmclib` functions,
but requires access to a redfish interface on the node to work. Once the BMC
information is received, it is then stored into `hms-smd` using its API.
In summary, `magellan` needs at minimum the following configured to work on each node: In summary, `magellan` needs at minimum the following configured to work on each node:
@ -33,7 +38,7 @@ cd magellan
go mod tidy && go build go mod tidy && go build
``` ```
This should find and download all of the required dependencies. Although other This should find and download all of the required dependencies. Although other
versions of Go may work, the project has only been tested with v1.20. versions of Go may work, the project has only been tested with v1.20.
## Usage ## Usage

View file

@ -51,9 +51,7 @@ func AddRedfishEndpoint(data []byte, headers map[string]string) error {
// Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint // Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := makeEndpointUrl("/Inventory/RedfishEndpoints") url := makeEndpointUrl("/Inventory/RedfishEndpoints")
res, body, err := util.MakeRequest(url, "POST", data, headers) res, body, err := util.MakeRequest(url, "POST", data, headers)
fmt.Printf("smd url: %v\n", url) fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
fmt.Printf("res: %v\n", res.Status)
fmt.Printf("body: %v\n", string(body))
if res != nil { if res != nil {
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
return fmt.Errorf("could not add redfish endpoint") return fmt.Errorf("could not add redfish endpoint")
@ -69,9 +67,7 @@ func UpdateRedfishEndpoint(xname string, data []byte, headers map[string]string)
// Update redfish endpoint via PUT `/hsm/v2/Inventory/RedfishEndpoints` endpoint // Update redfish endpoint via PUT `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := makeEndpointUrl("/Inventory/RedfishEndpoints/" + xname) url := makeEndpointUrl("/Inventory/RedfishEndpoints/" + xname)
res, body, err := util.MakeRequest(url, "PUT", data, headers) res, body, err := util.MakeRequest(url, "PUT", data, headers)
fmt.Printf("smd url: %v\n", url) fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
fmt.Printf("res: %v\n", res.Status)
fmt.Printf("body: %v\n", string(body))
if res != nil { if res != nil {
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
return fmt.Errorf("could not update redfish endpoint") return fmt.Errorf("could not update redfish endpoint")

View file

@ -638,6 +638,9 @@ func QueryProcessors(q *QueryParams) ([]byte, error) {
func connectGofish(q *QueryParams) (*gofish.APIClient, error) { func connectGofish(q *QueryParams) (*gofish.APIClient, error) {
config := makeGofishConfig(q) config := makeGofishConfig(q)
c, err := gofish.Connect(config) c, err := gofish.Connect(config)
if err != nil {
return nil, err
}
c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{ c.Service.ProtocolFeaturesSupported = gofish.ProtocolFeaturesSupported{
ExpandQuery: gofish.Expand{ ExpandQuery: gofish.Expand{
ExpandAll: true, ExpandAll: true,