add vm name and placeholder change to updates table
This commit is contained in:
@@ -104,8 +104,17 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
params.NewRam = sql.NullInt64{Int64: i, Valid: i > 0}
|
||||
params.UpdateType = "reconfigure"
|
||||
}
|
||||
case "config.managedBy":
|
||||
// This changes when a VM becomes a placeholder or vice versa
|
||||
case "config.managedBy": // This changes when a VM becomes a placeholder or vice versa
|
||||
found = true
|
||||
params.UpdateType = "srm"
|
||||
|
||||
if change["newValue"] == "(extensionKey = \"com.vmware.vcDr\", type = \"placeholderVm\")" {
|
||||
params.PlaceholderChange = sql.NullString{String: "placeholderVm", Valid: true}
|
||||
} else if change["newValue"] == "<unset>" {
|
||||
params.PlaceholderChange = sql.NullString{String: "Vm", Valid: true}
|
||||
} else {
|
||||
h.Logger.Error("Unexpected value for managedBy configuration", "new_value", change["newValue"])
|
||||
}
|
||||
|
||||
// map[newValue:(extensionKey = \"com.vmware.vcDr\", type = \"placeholderVm\") type:config.managedBy]
|
||||
// map[newValue:\"testVm\" type:config.managedBy.type]
|
||||
@@ -187,12 +196,14 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// populate other parameters for the Update database record
|
||||
params.Name = sql.NullString{String: event.CloudEvent.Data.VM.Name, Valid: event.CloudEvent.Data.VM.Name != ""}
|
||||
params.EventId = sql.NullString{String: event.CloudEvent.ID, Valid: event.CloudEvent.ID != ""}
|
||||
params.EventKey = sql.NullString{String: strconv.Itoa(event.CloudEvent.Data.Key), Valid: event.CloudEvent.Data.Key > 0}
|
||||
params.UpdateTime = sql.NullInt64{Int64: unixTimestamp, Valid: unixTimestamp > 0}
|
||||
params.UserName = sql.NullString{String: event.CloudEvent.Data.UserName, Valid: event.CloudEvent.Data.UserName != ""}
|
||||
|
||||
// Create the Update database record
|
||||
h.Logger.Debug("Adding Update record", "params", params)
|
||||
result, err := h.Database.Queries().CreateUpdate(ctx, params)
|
||||
if err != nil {
|
||||
h.Logger.Error("unable to perform database insert", "error", err)
|
||||
|
Reference in New Issue
Block a user