This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"vctp/db"
|
||||
"vctp/internal/secrets"
|
||||
"vctp/internal/settings"
|
||||
"vctp/internal/vcenter"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
// Handler handles requests.
|
||||
@@ -24,6 +20,7 @@ type Handler struct {
|
||||
Settings *settings.Settings
|
||||
}
|
||||
|
||||
/*
|
||||
func (h *Handler) html(ctx context.Context, w http.ResponseWriter, status int, t templ.Component) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.WriteHeader(status)
|
||||
@@ -32,3 +29,4 @@ func (h *Handler) html(ctx context.Context, w http.ResponseWriter, status int, t
|
||||
h.Logger.Error("Failed to render component", "error", err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -116,22 +116,23 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
params.UpdateType = "reconfigure"
|
||||
}
|
||||
case "config.managedBy": // This changes when a VM becomes a placeholder or vice versa
|
||||
if change["newValue"] == "(extensionKey = \"com.vmware.vcDr\", type = \"placeholderVm\")" {
|
||||
switch change["newValue"] {
|
||||
case "(extensionKey = \"com.vmware.vcDr\", type = \"placeholderVm\")":
|
||||
params.PlaceholderChange = sql.NullString{String: "placeholderVm", Valid: true}
|
||||
h.Logger.Debug("placeholderVm")
|
||||
changeFound = true
|
||||
params.UpdateType = "srm"
|
||||
} else if change["newValue"] == "<unset>" {
|
||||
case "<unset>":
|
||||
params.PlaceholderChange = sql.NullString{String: "Vm", Valid: true}
|
||||
h.Logger.Debug("vm")
|
||||
changeFound = true
|
||||
params.UpdateType = "srm"
|
||||
} else if change["newValue"] == "testVm" {
|
||||
case "testVm":
|
||||
h.Logger.Debug("testVm")
|
||||
params.PlaceholderChange = sql.NullString{String: "testVm", Valid: true}
|
||||
changeFound = true
|
||||
params.UpdateType = "srm"
|
||||
} else {
|
||||
default:
|
||||
h.Logger.Error("Unexpected value for managedBy configuration", "new_value", change["newValue"])
|
||||
}
|
||||
|
||||
@@ -145,12 +146,13 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO - track when this happens, maybe need a new database column?
|
||||
case "config.managedBy.type":
|
||||
h.Logger.Debug("config.managedBy.type")
|
||||
if change["newValue"] == "testVm" {
|
||||
switch change["newValue"] {
|
||||
case "testVm":
|
||||
h.Logger.Debug("testVm")
|
||||
params.PlaceholderChange = sql.NullString{String: "testVm", Valid: true}
|
||||
changeFound = true
|
||||
params.UpdateType = "srm"
|
||||
} else if change["newValue"] == "\\\"placeholderVm\\\"" {
|
||||
case "\\\"placeholderVm\\\"":
|
||||
h.Logger.Debug("placeholderVm")
|
||||
params.PlaceholderChange = sql.NullString{String: "placeholderVm", Valid: true}
|
||||
changeFound = true
|
||||
|
||||
Reference in New Issue
Block a user