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

This commit is contained in:
Patrick Hilhorst 2021-11-19 23:02:30 +01:00
parent a8f693ed48
commit 9e71014ede
No known key found for this signature in database
GPG key ID: 3BB083304DADC0FF
2 changed files with 7 additions and 1 deletions

View file

@ -1184,6 +1184,10 @@ class Driver:
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)
}

View file

@ -134,7 +134,9 @@ rec {
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