Refactor nova::compute vncproxy settings

This commit refactors the vncproxy params for nova::compute. 

Splits up base_url into host,port,path,protocol.
  - This has been done to make it easier for the user
    to just set the host without having to worry about the
    other settings (all of which have reasonable defaults).

This commit also changes the code to assume that if vnc is enabled and
no vnc proxy host is supplied that the proxy host config should be collected.
This commit is contained in:
Dan Bode 2012-04-30 09:33:10 -07:00
parent 108687d98b
commit 8c32b4a7b5
3 changed files with 88 additions and 45 deletions

View File

@ -186,14 +186,13 @@ class { 'nova::consoleauth':
enabled => true
}
class { 'nova::vncproxy':
host => $public_hostname,
}
class { 'nova::vncproxy': }
class { 'nova::compute':
enabled => true,
vnc_enabled => true,
vncserver_proxyclient_address => '127.0.0.1',
vncproxy_host => $public_hostname,
}
class { 'nova::compute::libvirt':

View File

@ -1,11 +1,32 @@
#schedulee this class should probably never be declared except
# from the virtualization implementation of the compute node
class nova::compute(
$enabled = false,
$vnc_enabled = true,
$enabled = false,
$vnc_enabled = true,
$vncserver_proxyclient_address = '127.0.0.1',
$novncproxy_base_url = 'http://127.0.0.1:6080/vnc_auto.html'
) {
$vncproxy_host = false,
$vncproxy_protocol = 'http',
$vncproxy_port = '6080',
$vncproxy_path = '/vnc_auto.html'
) {
if ($vnc_enabled) {
if !($vncproxy_host) {
warning("VNC is enabled and \$vncproxy_host must be specified nova::compute assumes that it can collect the exported resource: Nova_config[vncproxy_base_url]")
Nova_config <<| title == 'vncproxy_base_url' |>>
} else {
$vncproxy_base_url = "${vncproxy_protocol}://${vncproxy_host}:${vncproxy_port}${vncproxy_path}"
# config for vnc proxy
nova_config {
'novncproxy_base_url': value => $vncproxy_base_url;
}
}
}
nova_config {
'vnc_enabled': value => $vnc_enabled;
'vncserver_proxyclient_address': value => $vncserver_proxyclient_address;
}
nova::generic_service { 'compute':
enabled => $enabled,
@ -14,11 +35,4 @@ class nova::compute(
before => Exec['networking-refresh']
}
# config for vnc proxy
nova_config {
'vnc_enabled': value => $vnc_enabled;
'vncserver_proxyclient_address': value => $vncserver_proxyclient_address;
'novncproxy_base_url': value => $novncproxy_base_url;
}
}

View File

@ -6,40 +6,70 @@ describe 'nova::compute' do
'include nova'
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
describe 'with required params provided' do
let :params do
{
:vncproxy_host => '127.0.0.1'
}
end
it { should contain_service('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'present',
'notify' => 'Service[nova-compute]'
) }
describe 'with enabled as true' do
let :params do
{:enabled => true}
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it { should contain_nova_config('vnc_enabled').with_value('true') }
it { should contain_nova_config('vncserver_proxyclient_address').with_value('127.0.0.1') }
it { should contain_nova_config('novncproxy_base_url').with_value(
'http://127.0.0.1:6080/vnc_auto.html'
) }
it { should contain_service('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'present',
'notify' => 'Service[nova-compute]'
) }
describe 'with enabled as true' do
let :params do
{
:enabled => true,
:vncproxy_host => '127.0.0.1'
}
end
it { should contain_service('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'running',
'enable' => true
)}
end
describe 'with vnc_enabled set to false' do
let :params do
{:vnc_enabled => false}
end
it { should contain_nova_config('vnc_enabled').with_value('false') }
it { should contain_nova_config('vncserver_proxyclient_address').with('127.0.0.1')}
it { should_not contain_nova_config('novncproxy_base_url') }
end
it { should contain_service('nova-compute').with(
'name' => 'nova-compute',
'ensure' => 'running',
'enable' => true
)}
end
end
describe 'on rhel' do
let :facts do
{ :osfamily => 'RedHat' }
describe 'on rhel' do
let :facts do
{ :osfamily => 'RedHat' }
end
it { should contain_service('nova-compute').with(
'name' => 'openstack-nova-compute',
'ensure' => 'stopped',
'enable' => false
)}
it { should_not contain_package('nova-compute') }
end
it { should contain_service('nova-compute').with(
'name' => 'openstack-nova-compute',
'ensure' => 'stopped',
'enable' => false
)}
it { should_not contain_package('nova-compute') }
end
end