Don't handle leftover template vars for "Probe" string
As "Probe" string does not contain any template variable, we should not
check for leftover template variables in it after performing template
variable replacement which can mistakenly treat the regex token "$" as a
template variable.
This commit also skips handling leftover template variables for
"Exposes" object when the replacement is performed on the record for the
first time. The handling will be done when the replacement is targeted
for "Exposes" object later.
Tested on configurations with regex patterns in Probe string and and on
meta's fan boards that have math operations for more than 2 template
variables in the same JSON pair value. e.g:
```
"in0_Name": "FCB_$bus % 2 FAN_$bus % 2 * 2 VOLT_V",
```
Fixes: I4499baf3ebe9560e13932a49e324d1c8b0255623
Change-Id: I86ba103fec67c79908aa7a09755582e76b4cdee1
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
diff --git a/src/entity_manager/perform_scan.cpp b/src/entity_manager/perform_scan.cpp
index 4a3696f..305363e 100644
--- a/src/entity_manager/perform_scan.cpp
+++ b/src/entity_manager/perform_scan.cpp
@@ -487,8 +487,13 @@
{
if (keyPair.key() != "Name")
{
+ // "Probe" string does not contain template variables
+ // Handle left-over variables for "Exposes" later below
+ const bool handleLeftOver =
+ (keyPair.key() != "Probe") && (keyPair.key() != "Exposes");
em_utils::templateCharReplace(keyPair, dbusObject,
- foundDeviceIdx, replaceStr);
+ foundDeviceIdx, replaceStr,
+ handleLeftOver);
}
}