Add constructor new to MultiNodeFilesLogNamer
Add a constructor to MultiNodeFilesLogNamer allowing a aos
configuration to be specified. This is necessary when doing a
rerun and saving a log while using MultiNodeFilesLogNamer.
Change-Id: Ia991df8343f739e7b1cb2981bcd036333e6731d9
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 3b50ab4..f2488a5 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -1163,6 +1163,30 @@
return nullptr;
}
+bool IsNodeFromConfiguration(const Configuration *config, const Node *node) {
+ if (config == nullptr) {
+ return false;
+ }
+
+ // Check if is multinode
+ if (MultiNode(config)) {
+ if (node == nullptr) {
+ return false;
+ }
+ for (const Node *node_from_config : *config->nodes()) {
+ if (node_from_config == node) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ // nullptr is the node for all single node configurations. Return true so
+ // this function can be used in the same way for single or multinode
+ // configurations.
+ return node == nullptr;
+ }
+}
+
std::string_view NodeName(const Configuration *config, size_t node_index) {
if (!configuration::MultiNode(config)) {
return "(singlenode)";