mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-19 19:17:02 -07:00
Merge branch 'main' into alt-releaser
This commit is contained in:
commit
4c45afce8d
7 changed files with 39 additions and 45 deletions
|
|
@ -30,11 +30,11 @@ var collectCmd = &cobra.Command{
|
|||
User: user,
|
||||
Pass: pass,
|
||||
Drivers: drivers,
|
||||
Preferred: preferredDriver,
|
||||
Timeout: timeout,
|
||||
Threads: threads,
|
||||
Verbose: verbose,
|
||||
WithSecureTLS: withSecureTLS,
|
||||
|
||||
}
|
||||
magellan.CollectInfo(&probeStates, l, q)
|
||||
|
||||
|
|
|
|||
24
cmd/root.go
24
cmd/root.go
|
|
@ -8,19 +8,19 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
timeout int
|
||||
threads int
|
||||
ports []int
|
||||
hosts []string
|
||||
withSecureTLS bool
|
||||
certPoolFile string
|
||||
user string
|
||||
pass string
|
||||
dbpath string
|
||||
drivers []string
|
||||
timeout int
|
||||
threads int
|
||||
ports []int
|
||||
hosts []string
|
||||
withSecureTLS bool
|
||||
certPoolFile string
|
||||
user string
|
||||
pass string
|
||||
dbpath string
|
||||
drivers []string
|
||||
preferredDriver string
|
||||
ipmitoolPath string
|
||||
verbose bool
|
||||
ipmitoolPath string
|
||||
verbose bool
|
||||
)
|
||||
|
||||
// TODO: discover bmc's on network (dora)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
|
||||
// url := getSmdEndpointUrl(endpoint)
|
||||
req, _ := http.NewRequest(httpMethod, url, bytes.NewBuffer(body))
|
||||
|
|
@ -25,4 +24,4 @@ func MakeRequest(url string, httpMethod string, body []byte, headers map[string]
|
|||
return nil, nil, fmt.Errorf("could not read response body: %v", err)
|
||||
}
|
||||
return res, b, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
IPMI_PORT = 623
|
||||
SSH_PORT = 22
|
||||
HTTPS_PORT = 443
|
||||
IPMI_PORT = 623
|
||||
SSH_PORT = 22
|
||||
HTTPS_PORT = 443
|
||||
)
|
||||
|
||||
type BMCProbeResult struct {
|
||||
|
|
@ -140,7 +140,7 @@ func CollectInfo(probeStates *[]BMCProbeResult, l *Logger, q *QueryParams) error
|
|||
}
|
||||
q.Host = ps.Host
|
||||
q.Port = ps.Port
|
||||
|
||||
|
||||
client, err := NewClient(l, q)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not make client: %v", err)
|
||||
|
|
@ -156,8 +156,7 @@ func CollectInfo(probeStates *[]BMCProbeResult, l *Logger, q *QueryParams) error
|
|||
// inventories
|
||||
inventory, err := QueryInventory(client, l, q)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not query inventory: %v", err)
|
||||
continue
|
||||
l.Log.Errorf("could not query inventory (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
// chassis
|
||||
|
|
@ -177,11 +176,12 @@ func CollectInfo(probeStates *[]BMCProbeResult, l *Logger, q *QueryParams) error
|
|||
data["Type"] = ""
|
||||
data["Name"] = ""
|
||||
data["FQDN"] = ps.Host
|
||||
data["User"] = q.User
|
||||
data["Password"] = q.Pass
|
||||
data["RediscoverOnUpdate"] = false
|
||||
data["Inventory"] = inventory
|
||||
data["Chassis"] = chassis
|
||||
|
||||
|
||||
|
||||
b, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not marshal JSON: %v", err)
|
||||
|
|
@ -419,13 +419,13 @@ func QueryChassis(q *QueryParams) ([]byte, error) {
|
|||
url += fmt.Sprintf("%s:%s@", q.User, q.Pass)
|
||||
}
|
||||
url += fmt.Sprintf("%s:%d", q.Host, q.Port)
|
||||
config := gofish.ClientConfig {
|
||||
Endpoint: url,
|
||||
Username: q.User,
|
||||
Password: q.Pass,
|
||||
Insecure: !q.WithSecureTLS,
|
||||
TLSHandshakeTimeout: q.Timeout,
|
||||
|
||||
|
||||
config := gofish.ClientConfig{
|
||||
Endpoint: url,
|
||||
Username: q.User,
|
||||
Password: q.Pass,
|
||||
Insecure: !q.WithSecureTLS,
|
||||
TLSHandshakeTimeout: q.Timeout,
|
||||
}
|
||||
c, err := gofish.Connect(config)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
package postgresql
|
||||
package postgresql
|
||||
|
|
|
|||
|
|
@ -4,23 +4,19 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
type Logger struct {
|
||||
Log *logrus.Logger
|
||||
Log *logrus.Logger
|
||||
Path string
|
||||
}
|
||||
|
||||
|
||||
func NewLogger(l *logrus.Logger, level logrus.Level) *Logger {
|
||||
l.SetLevel(level)
|
||||
return &Logger{
|
||||
Log: logrus.New(),
|
||||
Path: "",
|
||||
Log: logrus.New(),
|
||||
Path: "",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (l *Logger)WriteFile(path string) {
|
||||
func (l *Logger) WriteFile(path string) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
|
||||
func rawConnect(host string, ports []int, timeout int, keepOpenOnly bool) []BMCProbeResult {
|
||||
results := []BMCProbeResult{}
|
||||
for _, p := range ports {
|
||||
|
|
@ -52,11 +51,11 @@ func GenerateHosts(subnet string, begin uint8, end uint8) []string {
|
|||
}
|
||||
|
||||
func ScanForAssets(hosts []string, ports []int, threads int, timeout int) []BMCProbeResult {
|
||||
results := make([]BMCProbeResult, 0, len(hosts))
|
||||
done := make(chan struct{}, threads+1)
|
||||
chanHost := make(chan string, threads+1)
|
||||
results := make([]BMCProbeResult, 0, len(hosts))
|
||||
done := make(chan struct{}, threads+1)
|
||||
chanHost := make(chan string, threads+1)
|
||||
// chanPort := make(chan int, threads+1)
|
||||
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(threads)
|
||||
for i := 0; i < threads; i++ {
|
||||
|
|
@ -93,4 +92,4 @@ func ScanForAssets(hosts []string, ports []int, threads int, timeout int) []BMCP
|
|||
|
||||
func GetDefaultPorts() []int {
|
||||
return []int{HTTPS_PORT, IPMI_PORT}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue