Add more GetNodeIndex options

We will want to use strings to find a node index.

Change-Id: I5b54b3e06a4804c05bf1dbe4ea125be50aac7262
diff --git a/aos/configuration.cc b/aos/configuration.cc
index bdbb463..2d4b867 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -682,7 +682,7 @@
   CHECK(result != nullptr);
 
   {
-    int node_index = GetNodeIndexFromConfig(config, node);
+    int node_index = GetNodeIndexFromConfig(config, result);
     if (node_index != -1) {
       return node_index;
     }
@@ -692,6 +692,23 @@
              << " not found in the configuration.";
 }
 
+int GetNodeIndex(const Configuration *config, std::string_view name) {
+  if (!MultiNode(config)) {
+    return 0;
+  }
+
+  {
+    int node_index = 0;
+    for (const Node *iterated_node : *config->nodes()) {
+      if (iterated_node->name()->string_view() == name) {
+        return node_index;
+      }
+      ++node_index;
+    }
+  }
+  LOG(FATAL) << "Node " << name << " not found in the configuration.";
+}
+
 std::vector<const Node *> GetNodes(const Configuration *config) {
   std::vector<const Node *> nodes;
   if (MultiNode(config)) {