allow setting custom url for spice proxy

The current logic does not allow setting an url without
an explicit port. By adding this option, we allow an expert
to set a custom url (eg one without a port).

Change-Id: I9e14696d6d5cd17a00b6ac7462c0a2f8cfd6fff1
This commit is contained in:
Benedikt Trefzer
2025-01-18 21:32:48 +01:00
parent 8640de3615
commit 0143792933
3 changed files with 39 additions and 14 deletions

View File

@@ -17,6 +17,11 @@
# listen on the compute host.
# Defaults to $facts['os_service_default']
#
# [*html5proxy_base_url*]
# (optional) URL for the html5 console proxy
# only used if $proxy_host is not set explicitly
# Defaults to $facts['os_service_default']
#
# [*proxy_host*]
# (optional) Host for the html5 console proxy
# Defaults to undef
@@ -37,6 +42,7 @@ class nova::compute::spice(
Boolean $agent_enabled = true,
$server_listen = $facts['os_service_default'],
$server_proxyclient_address = $facts['os_service_default'],
$html5proxy_base_url = $facts['os_service_default'],
Optional[String[1]] $proxy_host = undef,
Enum['http', 'https'] $proxy_protocol = 'http',
Stdlib::Port $proxy_port = 6082,
@@ -46,19 +52,15 @@ class nova::compute::spice(
include nova::deps
if $proxy_host {
$html5proxy_base_url = "${proxy_protocol}://${proxy_host}:${proxy_port}${proxy_path}"
nova_config {
'spice/html5proxy_base_url': value => $html5proxy_base_url;
}
$html5proxy_base_url_real = "${proxy_protocol}://${proxy_host}:${proxy_port}${proxy_path}"
} else {
nova_config {
'spice/html5proxy_base_url': value => $facts['os_service_default'];
}
$html5proxy_base_url_real = $html5proxy_base_url
}
nova_config {
'spice/agent_enabled': value => $agent_enabled;
'spice/server_listen': value => $server_listen;
'spice/server_proxyclient_address': value => $server_proxyclient_address;
'spice/html5proxy_base_url': value => $html5proxy_base_url_real;
}
}

View File

@@ -0,0 +1,5 @@
---
features:
- |
Allow setting custom url for spice proxy. This makes it possible
to specify an URL without explicit port setting.

View File

@@ -2,24 +2,42 @@ require 'spec_helper'
describe 'nova::compute::spice' do
shared_examples 'nova::compute::spice' do
it { should contain_nova_config('spice/agent_enabled').with_value('true')}
it { should contain_nova_config('spice/server_proxyclient_address').with_value('<SERVICE DEFAULT>')}
it { should contain_nova_config('spice/html5proxy_base_url').with_value('<SERVICE DEFAULT>')}
it { should contain_nova_config('spice/server_listen').with_value('<SERVICE DEFAULT>')}
context 'with default params' do
let :params do
{}
end
it { should contain_nova_config('spice/agent_enabled').with_value('true')}
it { should contain_nova_config('spice/server_proxyclient_address').with_value('<SERVICE DEFAULT>')}
it { should contain_nova_config('spice/html5proxy_base_url').with_value('<SERVICE DEFAULT>')}
it { should contain_nova_config('spice/server_listen').with_value('<SERVICE DEFAULT>')}
end
context 'when overriding params' do
let :params do
{
:proxy_host => '10.10.10.10',
:server_listen => '10.10.11.11',
:agent_enabled => false
:proxy_host => '10.10.10.10',
:server_listen => '10.10.11.11',
:server_proxyclient_address => '192.168.12.12',
:agent_enabled => false
}
end
it { should contain_nova_config('spice/html5proxy_base_url').with_value('http://10.10.10.10:6082/spice_auto.html')}
it { should contain_nova_config('spice/server_listen').with_value('10.10.11.11')}
it { should contain_nova_config('spice/server_proxyclient_address').with_value('192.168.12.12')}
it { should contain_nova_config('spice/agent_enabled').with_value('false')}
end
context 'when setting html5proxy_base_url params' do
let :params do
{
:html5proxy_base_url => 'https://my.custom.url/test.html',
}
end
it { should contain_nova_config('spice/html5proxy_base_url').with_value('https://my.custom.url/test.html')}
end
end
on_supported_os({