diff --git a/README.md b/README.md index b2053b8..f27368a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,14 @@ nix build .#tests.x86_64-linux..driverInteractive ./result/bin/nixos-test-driver ``` +#### Dashboard access + +The NixOS tests configure some port forwarding in order to allow access to the +OpenStack dashboard. The port forwarding can be configured via +`openstack-testing.dashboardHostPort` and the default host port used is `8080`. +While a NixOS test is running, the dashboard can be accessed via +`127.0.0.1:8080` or the configured host port. + ## Scope OpenStack is a very large and super actively maintained project. We are aware that we cannot keep track of all its development or offer every single configuration option via NixOS modules. diff --git a/modules/compute/nova.nix b/modules/compute/nova.nix index 565a63b..e0baf74 100644 --- a/modules/compute/nova.nix +++ b/modules/compute/nova.nix @@ -91,6 +91,11 @@ let username = nova password = nova + [serial_console] + enabled = true + serialproxy_host = 0.0.0.0 + proxyclient_address = $my_ip + [vnc] enabled = true server_listen = 0.0.0.0 diff --git a/modules/controller/nova.nix b/modules/controller/nova.nix index b4f3d2c..1ea834b 100644 --- a/modules/controller/nova.nix +++ b/modules/controller/nova.nix @@ -50,6 +50,9 @@ let username = nova password = nova + [serial_console] + enabled = true + [vnc] enabled = true server_listen = $my_ip @@ -299,5 +302,30 @@ in TimeoutStopSec = 15; }; }; + + systemd.services.nova-serialproxy = { + description = "OpenStack Nova serial proxy"; + after = [ + "nova.service" + "mysql.service" + "keystone.service" + "rabbitmq.service" + "network-online.target" + ]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ cfg.novaPackage ]; + serviceConfig = { + User = "nova"; + Group = "nova"; + Type = "simple"; + ExecStart = pkgs.writeShellScript "nova-serialproxy.sh" '' + nova-serialproxy --config-file ${cfg.config} + ''; + Restart = "on-failure"; + LimitNOFILE = 65535; + TimeoutStopSec = 15; + }; + }; }; } diff --git a/modules/testing/default.nix b/modules/testing/default.nix index 413d4ce..5104c0a 100644 --- a/modules/testing/default.nix +++ b/modules/testing/default.nix @@ -38,6 +38,52 @@ let environment.variables = adminEnv; }; }; + + portForwarding = + { config, lib, ... }: + with lib; + let + cfg = config.openstack-testing; + in + { + options.openstack-testing = { + enable = mkEnableOption "Enable port forwarding." // { + default = true; + }; + dashboardHostPort = mkOption { + default = 8080; + type = types.port; + description = '' + Host port to make the OpenStack dashboard accessible when running + the OpenStack controller in a VM. Dashboard can be accessed via: + localhost: + ''; + }; + serialProxyHostPort = mkOption { + default = 6083; + type = types.port; + description = '' + Host port to make the web console feature available for the + OpenStack dashboard. Changing the value might requires to change + the configuration of the dashboard. + ''; + }; + }; + config = mkIf cfg.enable { + virtualisation.forwardPorts = [ + { + from = "host"; + host.port = cfg.dashboardHostPort; + guest.port = 80; + } + { + from = "host"; + host.port = cfg.serialProxyHostPort; + guest.port = 6083; + } + ]; + }; + }; in { testController = @@ -49,7 +95,10 @@ in }; in { - imports = [ common ]; + imports = [ + common + portForwarding + ]; virtualisation = { cores = 4;