PerformScan: Extract apply{Bind,Disable}Action() from run()
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ic05dba3ee9f2544166df36a4ee0f051aaba1087f
diff --git a/src/PerformScan.cpp b/src/PerformScan.cpp
index a6fc794..51228b5 100644
--- a/src/PerformScan.cpp
+++ b/src/PerformScan.cpp
@@ -343,6 +343,27 @@
return matchIt;
}
+static void applyBindExposeAction(nlohmann::json& exposedObject,
+ nlohmann::json& expose,
+ const std::string& propertyName)
+{
+ if (boost::starts_with(propertyName, "Bind"))
+ {
+ std::string bind = propertyName.substr(sizeof("Bind") - 1);
+ exposedObject["Status"] = "okay";
+ expose[bind] = exposedObject;
+ }
+}
+
+static void applyDisableExposeAction(nlohmann::json& exposedObject,
+ const std::string& propertyName)
+{
+ if (propertyName == "DisableNode")
+ {
+ exposedObject["Status"] = "disabled";
+ }
+}
+
void PerformScan::run()
{
boost::container::flat_set<std::string> dbusProbeInterfaces;
@@ -569,18 +590,10 @@
matches.erase(*match);
- if (isBind)
- {
- std::string bind = keyPair.key().substr(
- sizeof("Bind") - 1);
-
- exposedObject["Status"] = "okay";
- expose[bind] = exposedObject;
- }
- else if (isDisable)
- {
- exposedObject["Status"] = "disabled";
- }
+ applyBindExposeAction(exposedObject, expose,
+ keyPair.key());
+ applyDisableExposeAction(exposedObject,
+ keyPair.key());
}
}
if (!matches.empty())