Add some initial files

This commit is contained in:
Ben McDonald 2025-06-05 15:30:15 -07:00
parent 04e1fb26c9
commit 7aeb3aa6c5
No known key found for this signature in database
5 changed files with 141 additions and 0 deletions

52
pkg/jaws/pdu-crawler.go Normal file
View file

@ -0,0 +1,52 @@
package jaws
import (
"fmt"
"net/http"
"time"
"github.com/OpenCHAMI/magellan/pkg/pdu"
)
type CrawlerConfig struct {
URI string
Username string
Password string
Insecure bool
Timeout time.Duration
}
// CrawlPDU connects to a single JAWS PDU and collects its inventory.
func CrawlPDU(config CrawlerConfig) (*pdu.PDUInventory, error) {
client := &http.Client{
Timeout: config.Timeout,
}
_ = client
inventory := &pdu.PDUInventory{
Hostname: config.URI,
}
// 1. Get System Info
// Should call /jaws/config/info/system
// Create a temporary struct to unmarshal the response
// and then populate PDU inventory, like is done in CSM.
// 2. Get Outlet Status
// Should call /jaws/outlet/status or similar endpoint
// It will return a list of outlets to parse
fmt.Printf("Crawling JAWS PDU at %s...\n", config.URI)
return inventory, nil
}
/*
func getSystemInfo(client *http.Client, config CrawlerConfig) (*SystemInfo, error) {
// GET to /jaws/config/info/system
}
func getOutletStatus(client *http.Client, config CrawlerConfig) ([]pdu.PDUOutlet, error) {
// GET to /jaws/outlet/status
}
*/

1
pkg/pdu/README.md Normal file
View file

@ -0,0 +1 @@
./magellan pdu collect x3000m0 --username admn --password admn

15
pkg/pdu/pdu-inventory.go Normal file
View file

@ -0,0 +1,15 @@
package pdu
type PDUOutlet struct {
ID string `json:"id"` // e.g., "35" or "BA35"
Name string `json:"name"` // e.g., "Link1_Outlet_35"
PowerState string `json:"power_state"` // e.g., "ON" or "OFF"
}
type PDUInventory struct {
Hostname string `json:"hostname"`
Model string `json:"model,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
FirmwareVersion string `json:"firmware_version,omitempty"`
Outlets []PDUOutlet `json:"outlets"`
}