Validate port values for console access

Ensure a value is a valid port value within the range. Note that string
values may no longer be accepted.

Change-Id: I957a4572e6998397f55f8bbb0e606c282e440077
This commit is contained in:
Takashi Kajinami
2025-01-19 11:35:51 +09:00
parent e683350348
commit 1ac88e4070
7 changed files with 19 additions and 9 deletions

View File

@@ -44,7 +44,7 @@
#
# [*vncproxy_port*]
# (optional) The port to communicate with the VNC proxy server
# Defaults to '6080'
# Defaults to 6080
#
# [*vncproxy_path*]
# (optional) The path at the end of the uri for communication with the VNC proxy server
@@ -271,7 +271,7 @@ class nova::compute (
$vncserver_proxyclient_address = $facts['os_service_default'],
Optional[String[1]] $vncproxy_host = undef,
Enum['http', 'https'] $vncproxy_protocol = 'http',
$vncproxy_port = '6080',
Stdlib::Port $vncproxy_port = 6080,
String $vncproxy_path = '/vnc_auto.html',
$force_config_drive = $facts['os_service_default'],
$instance_usage_audit = $facts['os_service_default'],

View File

@@ -23,7 +23,7 @@
#
# [*proxy_port*]
# (optional) Port for the html5 console proxy
# Defaults to '6082'
# Defaults to 6082
#
# [*proxy_protocol*]
# (optional) Protocol for the html5 console proxy
@@ -39,7 +39,7 @@ class nova::compute::spice(
$server_proxyclient_address = $facts['os_service_default'],
Optional[String[1]] $proxy_host = undef,
Enum['http', 'https'] $proxy_protocol = 'http',
$proxy_port = '6082',
Stdlib::Port $proxy_port = 6082,
String $proxy_path = '/spice_auto.html',
) {

View File

@@ -18,7 +18,7 @@
#
# [*port*]
# (optional) Port on which to listen for incoming requests
# Defaults to '6080'
# Defaults to 6080
#
# [*ensure_package*]
# (optional) The state of the nova-novncproxy package
@@ -66,7 +66,7 @@ class nova::vncproxy(
Boolean $manage_service = true,
Enum['http', 'https'] $vncproxy_protocol = 'http',
String[1] $host = '0.0.0.0',
$port = '6080',
Stdlib::Port $port = 6080,
String $vncproxy_path = '/vnc_auto.html',
$ensure_package = 'present',
Boolean $allow_noauth = true,

View File

@@ -19,7 +19,7 @@
class nova::vncproxy::common (
Optional[String[1]] $vncproxy_host = undef,
Optional[Enum['http', 'https']] $vncproxy_protocol = undef,
$vncproxy_port = undef,
Optional[Stdlib::Port] $vncproxy_port = undef,
Optional[String] $vncproxy_path = undef,
) {

View File

@@ -0,0 +1,9 @@
---
upgrade:
- |
The following parameters now require integer values.
- ``nova::compute::vncproxy_port``
- ``nova::compute::spice::proxy_port``
- ``nova::vncproxy::port``
- ``nova::vncproxy::common:vncproxy_port``

View File

@@ -84,6 +84,7 @@ describe 'nova::compute' do
{ :enabled => false,
:ensure_package => '2012.1-2',
:vncproxy_host => '127.0.0.1',
:vncproxy_port => 16080,
:use_cow_images => false,
:mkisofs_cmd => 'mkisofs',
:force_raw_images => false,
@@ -138,7 +139,7 @@ describe 'nova::compute' do
is_expected.to contain_nova_config('vnc/enabled').with_value(true)
is_expected.to contain_nova_config('vnc/server_proxyclient_address').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('vnc/novncproxy_base_url').with_value(
'http://127.0.0.1:6080/vnc_auto.html'
'http://127.0.0.1:16080/vnc_auto.html'
)
end

View File

@@ -14,7 +14,7 @@ describe 'nova::vncproxy' do
context 'with default parameters' do
it { is_expected.to contain_nova_config('vnc/novncproxy_host').with_value('0.0.0.0') }
it { is_expected.to contain_nova_config('vnc/novncproxy_port').with_value('6080') }
it { is_expected.to contain_nova_config('vnc/novncproxy_port').with_value(6080) }
it { is_expected.to contain_nova_config('vnc/auth_schemes').with_value('none') }
it { is_expected.to contain_nova_config('vnc/vencrypt_client_key').with_ensure('absent')}
it { is_expected.to contain_nova_config('vnc/vencrypt_client_cert').with_ensure('absent')}