store event type
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-26 14:21:07 +10:00
parent 00d474b937
commit 8931cb4891
7 changed files with 16 additions and 12 deletions

View File

@@ -68,6 +68,7 @@ func (h *Handler) VmCleanup(w http.ResponseWriter, r *http.Request) {
return
} else {
// Successful cleanup
h.Logger.Debug("VM successfully removed from inventory", "vm_name", vm.Name, "iid", vm.Iid, "vm_id", vmId, "datacenter_name", datacenterName)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]string{

View File

@@ -14,8 +14,8 @@ import (
models "vctp/server/models"
)
// VmCreate receives the CloudEvent for a VM creation
func (h *Handler) VmCreate(w http.ResponseWriter, r *http.Request) {
// VmCreateEvent receives the CloudEvent for a VM creation
func (h *Handler) VmCreateEvent(w http.ResponseWriter, r *http.Request) {
var (
unixTimestamp int64
//numVcpus int32
@@ -67,6 +67,7 @@ func (h *Handler) VmCreate(w http.ResponseWriter, r *http.Request) {
Source: event.CloudEvent.Source,
CloudId: event.CloudEvent.ID,
EventTime: sql.NullInt64{Int64: unixTimestamp, Valid: unixTimestamp > 0},
EventType: sql.NullString{String: event.CloudEvent.Type, Valid: event.CloudEvent.Type != ""},
ChainId: strconv.Itoa(e.ChainID),
VmId: sql.NullString{String: e.VM.VM.Value, Valid: e.VM.VM.Value != ""},
VmName: sql.NullString{String: e.VM.Name, Valid: e.VM.Name != ""},

View File

@@ -13,7 +13,7 @@ import (
)
// VmUpdate receives the CloudEvent for a VM modification or move
func (h *Handler) VmDelete(w http.ResponseWriter, r *http.Request) {
func (h *Handler) VmDeleteEvent(w http.ResponseWriter, r *http.Request) {
var (
deletedTimestamp int64
)

View File

@@ -18,8 +18,8 @@ import (
"github.com/vmware/govmomi/vim25/types"
)
// VmModify receives the CloudEvent for a VM modification or move
func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
// VmModifyEvent receives the CloudEvent for a VM modification or move
func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
var configChanges []map[string]string
params := queries.CreateUpdateParams{}
var unixTimestamp int64