mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Removed unused functions in collect.go
This commit is contained in:
parent
3078770247
commit
a65c640aab
1 changed files with 0 additions and 137 deletions
|
|
@ -228,101 +228,6 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
return nil
|
||||
}
|
||||
|
||||
// CollectInventory() fetches inventory data from all of the BMC hosts provided.
|
||||
func CollectInventory(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
||||
// open BMC session and update driver registry
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Second*time.Duration(q.Timeout))
|
||||
client.Registry.FilterForCompatible(ctx)
|
||||
err := client.PreferProvider(q.Preferred).Open(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to open client: %v", err)
|
||||
}
|
||||
|
||||
inventory, err := client.Inventory(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to get inventory: %v", err)
|
||||
}
|
||||
|
||||
// retrieve inventory data
|
||||
data := map[string]any{"Inventory": inventory}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
ctxCancel()
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// TODO: DELETE ME!!!
|
||||
func CollectPowerState(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Second*time.Duration(q.Timeout))
|
||||
client.Registry.FilterForCompatible(ctx)
|
||||
err := client.PreferProvider(q.Preferred).Open(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to open client: %v", err)
|
||||
}
|
||||
|
||||
powerState, err := client.GetPowerState(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to get inventory: %v", err)
|
||||
}
|
||||
|
||||
// retrieve inventory data
|
||||
data := map[string]any{"PowerState": powerState}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
ctxCancel()
|
||||
return b, nil
|
||||
|
||||
}
|
||||
|
||||
// TODO: DELETE ME!!!
|
||||
func CollectUsers(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
||||
// open BMC session and update driver registry
|
||||
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Second*time.Duration(q.Timeout))
|
||||
client.Registry.FilterForCompatible(ctx)
|
||||
err := client.Open(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to connect to bmc: %v", err)
|
||||
}
|
||||
|
||||
defer client.Close(ctx)
|
||||
|
||||
users, err := client.ReadUsers(ctx)
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to get users: %v", err)
|
||||
}
|
||||
|
||||
// retrieve inventory data
|
||||
data := map[string]any{"Users": users}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
ctxCancel()
|
||||
return nil, fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
ctxCancel()
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// TODO: DELETE ME!!!
|
||||
func CollectBios(client *bmclib.Client, q *QueryParams) ([]byte, error) {
|
||||
b, err := makeRequest(client, client.GetBiosConfiguration, q.Timeout)
|
||||
return b, err
|
||||
}
|
||||
|
||||
// CollectEthernetInterfaces() collects all of the ethernet interfaces found
|
||||
// from all systems from under the "/redfish/v1/Systems" endpoint.
|
||||
//
|
||||
|
|
@ -398,32 +303,6 @@ func CollectChassis(c *gofish.APIClient, q *QueryParams) ([]map[string]any, erro
|
|||
return chassis, nil
|
||||
}
|
||||
|
||||
// TODO: DELETE ME!!!
|
||||
func CollectStorage(c *gofish.APIClient, q *QueryParams) ([]byte, error) {
|
||||
systems, err := c.Service.StorageSystems()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query storage systems (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
services, err := c.Service.StorageServices()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query storage services (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"Storage": map[string]any{
|
||||
"Systems": systems,
|
||||
"Services": services,
|
||||
},
|
||||
}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// CollectSystems pulls system information from each BMC node via Redfish using the
|
||||
// `gofish` library.
|
||||
//
|
||||
|
|
@ -502,22 +381,6 @@ func CollectSystems(c *gofish.APIClient, q *QueryParams) ([]map[string]any, erro
|
|||
return systems, nil
|
||||
}
|
||||
|
||||
// TODO: DELETE ME!!!
|
||||
func CollectRegisteries(c *gofish.APIClient, q *QueryParams) ([]byte, error) {
|
||||
registries, err := c.Service.Registries()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query storage systems (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
data := map[string]any{"Registries": registries}
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal JSON: %v", err)
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// TODO: MAYBE DELETE???
|
||||
func CollectProcessors(q *QueryParams) ([]byte, error) {
|
||||
url := baseRedfishUrl(q) + "/Systems"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue