test-driver.py: always export single machine as 'machine'

Changed files
+7 -1
nixos
+4
nixos/lib/test-driver/test-driver.py
···
Machine=Machine, # for typing
machine_symbols = {m.name: m for m in self.machines}
+
# If there's exactly one machine, make it available under the name
+
# "machine", even if it's not called that.
+
if len(self.machines) == 1:
+
(machine_symbols["machine"],) = self.machines
vlan_symbols = {
f"vlan{v.nr}": self.vlans[idx] for idx, v in enumerate(self.vlans)
+3 -1
nixos/lib/testing-python.nix
···
vlans = map (m: m.config.virtualisation.vlans) (lib.attrValues nodes);
vms = map (m: m.config.system.build.vm) (lib.attrValues nodes);
-
nodeHostNames = map (c: c.config.system.name) (lib.attrValues nodes);
+
nodeHostNames = let
+
nodesList = map (c: c.config.system.name) (lib.attrValues nodes);
+
in nodesList ++ lib.optional (lib.length nodesList == 1) "machine";
# TODO: This is an implementation error and needs fixing
# the testing famework cannot legitimately restrict hostnames further