m/test/launch: order nodes in NodeIDs correctly

This ensures that referring to node by number via NodeIDs is possible -
ie. that NodeIDs[n] is the ID of the nth node as defined in NodeOpts or
as used as the 'idx' argument in RebootNode.

This was never and is still not correctly formalized, even in comments,
and is yet another proof that the cluster launch code deserves to be
rewritten from first principles.

Fixes #301.

Change-Id: I1ad13dc3bdd35a0c34f86e5d051ca9378491c876
Reviewed-on: https://review.monogon.dev/c/monogon/+/3168
Reviewed-by: Jan Schär <jan@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/labels.go b/metropolis/node/labels.go
index 08d0c6e..3e51aae 100644
--- a/metropolis/node/labels.go
+++ b/metropolis/node/labels.go
@@ -3,6 +3,8 @@
 import (
 	"fmt"
 	"regexp"
+
+	cpb "source.monogon.dev/metropolis/proto/common"
 )
 
 var (
@@ -62,3 +64,14 @@
 	}
 	return nil
 }
+
+// GetNodeLabel retrieves a node label by key, returning its value or an empty
+// string if no labels with this key is set on the node.
+func GetNodeLabel(labels *cpb.NodeLabels, key string) string {
+	for _, pair := range labels.Pairs {
+		if pair.Key == key {
+			return pair.Value
+		}
+	}
+	return ""
+}