Skip to content

Commit 7d81879

Browse files
committed
fix: add option to disable ssh port forwarding
In out CI we need an option to disable all port forwardings to avoid port collisions in parallel pipeline runs. Signed-off-by: Paul Kroeher <paul.kroeher@cyberus-technology.de> On-behalf-of: SAP paul.kroeher@sap.com
1 parent eea92d5 commit 7d81879

1 file changed

Lines changed: 50 additions & 17 deletions

File tree

modules/testing/default.nix

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,35 @@ let
5454
};
5555
};
5656

57+
portForwardingStorage =
58+
{ config, lib, ... }:
59+
with lib;
60+
let
61+
cfg = config.openstack-testing;
62+
in
63+
{
64+
options.openstack-testing = {
65+
enable = mkEnableOption "Enable port forwarding." // {
66+
default = true;
67+
};
68+
sshHostPort = mkOption {
69+
type = types.port;
70+
description = ''
71+
Host port to make the ssh server availalbe.
72+
'';
73+
};
74+
};
75+
config = mkIf cfg.enable {
76+
virtualisation.forwardPorts = [
77+
{
78+
from = "host";
79+
host.port = cfg.sshHostPort;
80+
guest.port = 22;
81+
}
82+
];
83+
};
84+
};
85+
5786
portForwarding =
5887
{ config, lib, ... }:
5988
with lib;
@@ -92,6 +121,12 @@ let
92121
the configuration of the dashboard.
93122
'';
94123
};
124+
sshHostPort = mkOption {
125+
type = types.port;
126+
description = ''
127+
Host port to make the ssh server availalbe.
128+
'';
129+
};
95130
};
96131
config = mkIf cfg.enable {
97132
virtualisation.forwardPorts = [
@@ -110,6 +145,11 @@ let
110145
host.port = cfg.vncProxyHostPort;
111146
guest.port = 6080;
112147
}
148+
{
149+
from = "host";
150+
host.port = cfg.sshHostPort;
151+
guest.port = 22;
152+
}
113153
];
114154
};
115155
};
@@ -132,6 +172,9 @@ in
132172
portForwarding
133173
];
134174

175+
openstack-testing.enable = true; # enable / disable all port forwardings
176+
openstack-testing.sshHostPort = 1122;
177+
135178
virtualisation = {
136179
cores = 4;
137180
memorySize = 6144;
@@ -144,14 +187,6 @@ in
144187
vlan = 2;
145188
};
146189
};
147-
# enable ssh access
148-
forwardPorts = [
149-
{
150-
from = "host";
151-
host.port = 1122;
152-
guest.port = 22;
153-
}
154-
];
155190
};
156191

157192
systemd.services.openstack-create-vm = {
@@ -278,7 +313,13 @@ in
278313
{ ... }:
279314
{
280315

281-
imports = [ common ];
316+
imports = [
317+
common
318+
portForwardingStorage
319+
];
320+
321+
openstack-testing.enable = true; # enable / disable all port forwardings
322+
openstack-testing.sshHostPort = 2022;
282323

283324
virtualisation = {
284325
memorySize = 4096;
@@ -296,14 +337,6 @@ in
296337
vlan = 2;
297338
};
298339
};
299-
# enable ssh access
300-
forwardPorts = [
301-
{
302-
from = "host";
303-
host.port = 2022;
304-
guest.port = 22;
305-
}
306-
];
307340
};
308341

309342
systemd.network = {

0 commit comments

Comments
 (0)