inital release refactor

This commit is contained in:
Alex Lovell-Troy 2023-09-14 15:10:08 -04:00
parent 34367f830a
commit 3351de48a6
12 changed files with 215 additions and 84 deletions

View file

@ -1,31 +1,32 @@
package dora
import (
"davidallendj/magellan/internal/api"
"encoding/json"
"fmt"
"github.com/bikeshack/magellan/internal/api"
"github.com/jmoiron/sqlx"
)
const (
Host = "http://localhost"
DbType = "sqlite3"
DbPath = "../data/assets.db"
Host = "http://localhost"
DbType = "sqlite3"
DbPath = "../data/assets.db"
BaseEndpoint = "/v1"
Port = 8000
Port = 8000
)
type ScannedResult struct {
id string
site any
cidr string
ip string
port int
id string
site any
cidr string
ip string
port int
protocol string
scanner string
state string
updated string
scanner string
state string
updated string
}
func makeEndpointUrl(endpoint string) string {
@ -67,8 +68,8 @@ func LoadScannedPortsFromDB(dbPath string, dbType string) {
for rows.Next() {
var r ScannedResult
rows.Scan(
&r.id, &r.site, &r.cidr, &r.ip, &r.port, &r.protocol, &r.scanner,
&r.id, &r.site, &r.cidr, &r.ip, &r.port, &r.protocol, &r.scanner,
&r.state, &r.updated,
)
}
}
}

View file

@ -4,18 +4,18 @@ package smd
// https://github.com/Cray-HPE/hms-smd/blob/master/docs/examples.adoc
// https://github.com/alexlovelltroy/hms-smd
import (
"davidallendj/magellan/internal/api"
"fmt"
"github.com/bikeshack/magellan/internal/api"
// hms "github.com/alexlovelltroy/hms-smd"
)
var (
Host = "http://localhost"
Host = "http://localhost"
BaseEndpoint = "/hsm/v2"
Port = 27779
Port = 27779
)
func makeEndpointUrl(endpoint string) string {
return Host + ":" + fmt.Sprint(Port) + BaseEndpoint + endpoint
}
@ -49,7 +49,7 @@ func AddRedfishEndpoint(data []byte, headers map[string]string) error {
// var ep hms.RedfishEP
// _ = ep
// Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint
// Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := makeEndpointUrl("/Inventory/RedfishEndpoints")
res, body, _ := api.MakeRequest(url, "POST", data, headers)
fmt.Println("smd url: ", url)
@ -60,4 +60,4 @@ func AddRedfishEndpoint(data []byte, headers map[string]string) error {
func UpdateRedfishEndpoint() {
// Update redfish endpoint via PUT `/hsm/v2/Inventory/RedfishEndpoints` endpoint
}
}