store more fields in db
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
queries "vctp/db/queries"
|
queries "vctp/db/queries"
|
||||||
"vctp/internal/vcenter"
|
"vctp/internal/vcenter"
|
||||||
@@ -74,6 +75,8 @@ func (h *Handler) VmCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
params := queries.CreateInventoryParams{
|
params := queries.CreateInventoryParams{
|
||||||
Name: vm.CloudEvent.Data.VM.Name,
|
Name: vm.CloudEvent.Data.VM.Name,
|
||||||
Vcenter: vm.CloudEvent.Source,
|
Vcenter: vm.CloudEvent.Source,
|
||||||
|
EventId: sql.NullString{String: vm.CloudEvent.ID, Valid: vm.CloudEvent.ID != ""},
|
||||||
|
EventKey: sql.NullString{String: strconv.Itoa(vm.CloudEvent.Data.Key), Valid: strconv.Itoa(vm.CloudEvent.Data.Key) != ""},
|
||||||
VmId: sql.NullString{String: "VirtualMachine-" + vm.CloudEvent.Data.VM.VM.Value, Valid: vm.CloudEvent.Data.VM.VM.Value != ""},
|
VmId: sql.NullString{String: "VirtualMachine-" + vm.CloudEvent.Data.VM.VM.Value, Valid: vm.CloudEvent.Data.VM.VM.Value != ""},
|
||||||
Datacenter: sql.NullString{String: vmObject.Datacenter, Valid: vmObject.Datacenter != ""},
|
Datacenter: sql.NullString{String: vmObject.Datacenter, Valid: vmObject.Datacenter != ""},
|
||||||
CreationTime: sql.NullInt64{Int64: unixTimestamp, Valid: unixTimestamp > 0},
|
CreationTime: sql.NullInt64{Int64: unixTimestamp, Valid: unixTimestamp > 0},
|
||||||
@@ -81,7 +84,7 @@ func (h *Handler) VmCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
InitialRam: sql.NullInt64{Int64: int64(numRam), Valid: numRam > 0},
|
InitialRam: sql.NullInt64{Int64: int64(numRam), Valid: numRam > 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Logger.Debug("database params", "vm", vm)
|
h.Logger.Debug("database params", "params", params)
|
||||||
|
|
||||||
// Insert the new inventory record into the database
|
// Insert the new inventory record into the database
|
||||||
result, err := h.Database.Queries().CreateInventory(context.Background(), params)
|
result, err := h.Database.Queries().CreateInventory(context.Background(), params)
|
||||||
|
Reference in New Issue
Block a user