Add automatic controller propagation for dualpath machines

When a PC is assigned to control equipment that has a dualpath relationship,
the controller is now automatically propagated to the dualpath partner machine.

Changes:
- includes/db_helpers.asp: Add PropagateControllerToDualpathMachines() and
  PropagateControllerFromDualpathMachine() helper functions
- savemachine_direct.asp: Call propagation on new equipment creation
- savemachineedit.asp: Call propagation when editing equipment relationships
- api.asp: Add PropagateControllerToDualpathMachinesAPI() for PowerShell API

Also includes one-time fix script (sql/fix_dualpath_controller_relationships.sql)
that fixes 140 backwards relationships (Equipment->PC to PC->Equipment) and
propagates controllers to 30 dualpath machines that were missing them.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-10 20:04:01 -05:00
parent 30ea1bb42f
commit f8083be467
5 changed files with 407 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
%>
<!--#include file="./includes/sql.asp"-->
<!--#include file="./includes/response.asp"-->
<!--#include file="./includes/db_helpers.asp"-->
<%
' Get and validate all inputs
Dim machineid, modelid, businessunitid, alias, machinenotes, mapleft, maptop, fqdn
@@ -597,6 +598,11 @@
cmdRelPC.Execute
Set cmdRelPC = Nothing
On Error Goto 0
' Propagate controller to dualpath machines (only for equipment, not PC)
If Not isPC Then
Call PropagateControllerToDualpathMachines(objConn, CLng(machineid), tempControllingPC)
End If
End If
' Create Dualpath relationship (bidirectional)
@@ -637,6 +643,9 @@
cmdRelDual2.Execute
Set cmdRelDual2 = Nothing
On Error Goto 0
' Propagate controller from dualpath partner if exists
Call PropagateControllerFromDualpathMachine(objConn, CLng(machineid), tempDualpathID)
End If
'=============================================================================