Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

refactor: Remove dead HandleTestExistingNode function

rcourtmanb21fad833ea1
diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go
index b3b371ab3d..671a5c0f92 100644
--- a/internal/api/config_handlers.go
+++ b/internal/api/config_handlers.go
@@ -2329,129 +2329,6 @@ func (h *ConfigHandlers) triggerPVEHostCleanup(host string) {
Msg("Queued PVE host cleanup via sensor proxy")
}
-// HandleTestExistingNode tests a connection for an existing node using stored credentials
-func (h *ConfigHandlers) HandleTestExistingNode(w http.ResponseWriter, r *http.Request) {
- nodeID := strings.TrimPrefix(r.URL.Path, "/api/config/nodes/")
- nodeID = strings.TrimSuffix(nodeID, "/test")
- if nodeID == "" {
- http.Error(w, "Node ID required", http.StatusBadRequest)
- return
- }
-
- // Parse node ID
- parts := strings.Split(nodeID, "-")
- if len(parts) != 2 {
- http.Error(w, "Invalid node ID", http.StatusBadRequest)
- return
- }
-
- nodeType := parts[0]
- index := 0
- if _, err := fmt.Sscanf(parts[1], "%d", &index); err != nil {
- http.Error(w, "Invalid node ID", http.StatusBadRequest)
- return
- }
-
- // Get the node configuration
- var host, user, password, tokenName, tokenValue, fingerprint string
- var verifySSL bool
-
- if nodeType == "pve" && index < len(h.config.PVEInstances) {
- pve := h.config.PVEInstances[index]
- host = pve.Host
- user = pve.User
- password = pve.Password
- tokenName = pve.TokenName
- tokenValue = pve.TokenValue
- fingerprint = pve.Fingerprint
- verifySSL = pve.VerifySSL
- } else if nodeType == "pbs" && index < len(h.config.PBSInstances) {
- pbs := h.config.PBSInstances[index]
- host = pbs.Host
- user = pbs.User
- password = pbs.Password
- tokenName = pbs.TokenName
- tokenValue = pbs.TokenValue
- fingerprint = pbs.Fingerprint
- verifySSL = pbs.VerifySSL
- } else {
- http.Error(w, "Node not found", http.StatusNotFound)
- return
- }
-
- // Test the connection based on type
- if nodeType == "pve" {
- clientConfig := proxmox.ClientConfig{
- Host: host,
- User: user,
- Password: password,
- TokenName: tokenName,
- TokenValue: tokenValue,
- VerifySSL: verifySSL,
- Fingerprint: fingerprint,
- }
-
- tempClient, err := proxmox.NewClient(clientConfig)
- if err != nil {
- http.Error(w, sanitizeErrorMessage(err, "create_client"), http.StatusBadRequest)
- return
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
-
- nodes, err := tempClient.GetNodes(ctx)
- if err != nil {
- http.Error(w, sanitizeErrorMessage(err, "connection"), http.StatusBadRequest)
- return
- }
-
- response := map[string]interface{}{
- "status": "success",
- "message": fmt.Sprintf("Successfully connected to %d node(s)", len(nodes)),
- "nodeCount": len(nodes),
- }
-
- w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
- } else {
- // PBS test
- clientConfig := pbs.ClientConfig{
- Host: host,
- User: user,
- Password: password,
- TokenName: tokenName,
- TokenValue: tokenValue,
- VerifySSL: verifySSL,
- Fingerprint: fingerprint,
- }
-
- tempClient, err := pbs.NewClient(clientConfig)
- if err != nil {
- http.Error(w, sanitizeErrorMessage(err, "create_client"), http.StatusBadRequest)
- return
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
-
- datastores, err := tempClient.GetDatastores(ctx)
- if err != nil {
- http.Error(w, sanitizeErrorMessage(err, "connection"), http.StatusBadRequest)
- return
- }
-
- response := map[string]interface{}{
- "status": "success",
- "message": fmt.Sprintf("Successfully connected. Found %d datastore(s)", len(datastores)),
- "datastoreCount": len(datastores),
- }
-
- w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(response)
- }
-}
-
// HandleTestNodeConfig tests a node connection from provided configuration
func (h *ConfigHandlers) HandleTestNodeConfig(w http.ResponseWriter, r *http.Request) {
var req NodeConfigRequest