fix hard coded URL, add proxmox URL to config

This commit is contained in:
Arthur Lu 2025-01-28 00:48:53 +00:00
parent 58cf403d26
commit 3cea9f6bcd
4 changed files with 10 additions and 15 deletions

View File

@ -28,7 +28,7 @@ func Run() {
log.Println("Initialized config from " + *configPath)
token := fmt.Sprintf(`%s@%s!%s`, config.PVE.Token.USER, config.PVE.Token.REALM, config.PVE.Token.ID)
client = NewClient(token, config.PVE.Token.Secret)
client = NewClient(config.PVE.URL, token, config.PVE.Token.Secret)
router := gin.Default()

View File

@ -15,7 +15,7 @@ type ProxmoxClient struct {
client *proxmox.Client
}
func NewClient(token string, secret string) ProxmoxClient {
func NewClient(url string, token string, secret string) ProxmoxClient {
HTTPClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
@ -24,7 +24,7 @@ func NewClient(token string, secret string) ProxmoxClient {
},
}
client := proxmox.NewClient("https://pve.tronnet.net/api2/json",
client := proxmox.NewClient(url,
proxmox.WithHTTPClient(&HTTPClient),
proxmox.WithAPIToken(token, secret),
)
@ -78,9 +78,9 @@ func (pve ProxmoxClient) Node(nodeName string) (*Host, error) {
}
host.Name = node.Name
host.Cores.Total = uint64(node.CPUInfo.CPUs)
host.Memory.Total = uint64(node.Memory.Total)
host.Swap.Total = uint64(node.Swap.Total)
host.Cores = uint64(node.CPUInfo.CPUs)
host.Memory = uint64(node.Memory.Total)
host.Swap = uint64(node.Swap.Total)
host.pvenode = node
return &host, err

View File

@ -15,9 +15,9 @@ type Cluster struct {
type Host struct {
lock sync.Mutex
Name string
Cores Resource
Memory Resource
Swap Resource
Cores uint64
Memory uint64
Swap uint64
Devices map[string]*Device
Instances map[uint]*Instance
pvenode *proxmox.Node
@ -47,12 +47,6 @@ type Instance struct {
configHostPCIs map[string]string
}
type Resource struct {
Reserved uint64
Free uint64
Total uint64
}
type Volume struct {
Path string
Format string

View File

@ -12,6 +12,7 @@ const MiB = 1024 * 1024
type Config struct {
ListenPort int `json:"listenPort"`
PVE struct {
URL string `json:"url"`
Token struct {
USER string `json:"user"`
REALM string `json:"realm"`