Skip to content

Commit f1118f2

Browse files
committed
nix: allow port forwarding configuration
We add a nixos module to the testing modules. This allows configuring ports for port forwarding for the dashboard and the serialproxy. This way, users can access the dashboard and the web serial console on the host when running the OpenStack controller in a VM.
1 parent 2747943 commit f1118f2

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

modules/testing/default.nix

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,52 @@ let
3838
environment.variables = adminEnv;
3939
};
4040
};
41+
42+
portForwarding =
43+
{ config, lib, ... }:
44+
with lib;
45+
let
46+
cfg = config.openstack-testing;
47+
in
48+
{
49+
options.openstack-testing = {
50+
enable = mkEnableOption "Enable port forwarding." // {
51+
default = true;
52+
};
53+
dashboardHostPort = mkOption {
54+
default = 8080;
55+
type = types.port;
56+
description = ''
57+
Host port to make the OpenStack dashboard accessible when running
58+
the OpenStack controller in a VM. Dashboard can be accessed via:
59+
localhost:<dashboardHostPort>
60+
'';
61+
};
62+
serialProxyHostPort = mkOption {
63+
default = 6083;
64+
type = types.port;
65+
description = ''
66+
Host port to make the web console feature available for the
67+
OpenStack dashboard. Changing the value might requires to change
68+
the configuration of the dashboard.
69+
'';
70+
};
71+
};
72+
config = mkIf cfg.enable {
73+
virtualisation.forwardPorts = [
74+
{
75+
from = "host";
76+
host.port = cfg.dashboardHostPort;
77+
guest.port = 80;
78+
}
79+
{
80+
from = "host";
81+
host.port = cfg.serialProxyHostPort;
82+
guest.port = 6083;
83+
}
84+
];
85+
};
86+
};
4187
in
4288
{
4389
testController =
@@ -49,7 +95,10 @@ in
4995
};
5096
in
5197
{
52-
imports = [ common ];
98+
imports = [
99+
common
100+
portForwarding
101+
];
53102

54103
virtualisation = {
55104
cores = 4;

0 commit comments

Comments
 (0)