UPM: Automatic VLAN assignment for POE devices

This UPM script automatically assigns a VLAN to a connected POE device and resets the port when a non POE device is connected.

The variable POEVLAN contains the VLAN for POE devices. Uplinkports and ports that should not be configured automatically can be added to the list of the variable uplinkports.  
create upm profile port_auth
set var CLI.OUT 0
show inline-power stats ports $EVENT.LOG_PARAM_0
set var poe_state $TCL(split ${CLI.OUT})
set var POEVLAN Default
set var uplinkports $TCL(list "1:25" "1:26")
set var poe_searching $TCL(regexp -all -nocase {searching} $poe_state)
set var poe_delivering $TCL(regexp -all -nocase {delivering} $poe_state)
set var isuplink $TCL(regexp $EVENT.LOG_PARAM_0 $uplinkports)
if (($poe_searching == 1) && ($isuplink == -1)) then
create log entry NON_POE_PORT_Activity_DETECTED_$EVENT.LOG_PARAM_0
create log entry activating_authentication_on_$EVENT.LOG_PARAM_0
configure vlan $POEVLAN delete ports $EVENT.LOG_PARAM_0
enable netlogin ports $EVENT.LOG_PARAM_0 dot1x mac
endif
if (($poe_delivering == 1) && ($isuplink == -1)) then
create log entry POE_PORT_Activity_DETECTED_Enabling_$EVENT.LOG_PARAM_0
create log entry disabling_authentication_on_$EVENT.LOG_PARAM_0
disable netlogin ports $EVENT.LOG_PARAM_0 dot1x mac
configure vlan $POEVLAN add ports $EVENT.LOG_PARAM_0
endif

.

create log filter port_with_auth
configure log filter port_with_auth add event vlan.msgs.portLinkStateUp
create log target upm port_auth
configure log target upm port_auth filter port_with_auth
enable log target upm port_auth
enable upm profile port_auth
  The script is triggered by a logevent that is written when the linkstatus of a port changes from down to up.