Add html5 spice support

Change-Id: Idd23170df13bff7f78112fbe72f228bf84112af9
This commit is contained in:
Mehdi Abaakouk
2013-04-12 17:00:31 +02:00
parent bdd9e7a943
commit 72dc339f7e
6 changed files with 270 additions and 60 deletions

View File

@@ -0,0 +1,65 @@
# == Class: nova::compute::spice
#
# Configure spice on the compute side
#
# === Parameters:
#
# [*agent_enabled*]
# (optional) enable spice guest agent support
# true/false
#
# [*server_listen*]
# (optional) IP address on which instance spice servers should listen
# Defaults to undef
#
# [*server_proxyclient_address*]
# (optional) Management IP Address on which instance spiceservers will
# listen on the compute host.
# Defaults to 127.0.0.1
#
# [*keymap*]
# (optional) keymap for spice
# Defaults to en-us
#
# [*proxy_host*]
# (optional) Host for the html5 console proxy
# Defaults to false
#
# [*proxy_port*]
# (optional) Port for the html5 console proxy
# Defaults to 6082
#
# [*proxy_protocol*]
# (optional) Protocol for the html5 console proxy
# Defaults to http
#
# [*proxy_path*]
# (optional) Path of the spice html file for the html5 console proxy
# Defaults to /spice_auto.html
#
class nova::compute::spice(
$agent_enabled = true,
$server_listen = undef,
$server_proxyclient_address = '127.0.0.1',
$keymap = 'en-us',
$proxy_host = false,
$proxy_protocol = 'http',
$proxy_port = '6082',
$proxy_path = '/spice_auto.html'
) {
if $proxy_host {
$html5proxy_base_url = "${proxy_protocol}://${proxy_host}:${proxy_port}${proxy_path}"
nova_config {
'spice/html5proxy_base_url': value => $html5proxy_base_url;
}
}
nova_config {
'spice/enabled': value => true;
'spice/agent_enabled': value => $agent_enabled;
'spice/server_listen': value => $server_listen;
'spice/server_proxyclient_address': value => $server_proxyclient_address;
'spice/keymap': value => $keymap;
}
}

View File

@@ -20,6 +20,7 @@ class nova::params {
$tgt_package_name = 'scsi-target-utils'
$volume_package_name = 'openstack-nova-volume'
$vncproxy_package_name = 'openstack-nova-novncproxy'
$spicehtml5proxy_package_name = 'openstack-nova-console'
# service names
$api_service_name = 'openstack-nova-api'
$cert_service_name = 'openstack-nova-cert'
@@ -32,6 +33,7 @@ class nova::params {
$scheduler_service_name = 'openstack-nova-scheduler'
$tgt_service_name = 'tgtd'
$vncproxy_service_name = 'openstack-nova-novncproxy'
$spicehtml5proxy_service_name = 'openstack-nova-spicehtml5proxy'
$volume_service_name = 'openstack-nova-volume'
# redhat specific config defaults
$root_helper = 'sudo nova-rootwrap'
@@ -72,18 +74,21 @@ class nova::params {
$objectstore_service_name = 'nova-objectstore'
$scheduler_service_name = 'nova-scheduler'
$volume_service_name = 'nova-volume'
$spicehtml5proxy_service_name = 'nova-spicehtml5proxy'
$tgt_service_name = 'tgt'
# debian specific nova config
$root_helper = 'sudo nova-rootwrap'
$lock_path = '/var/lock/nova'
case $::operatingsystem {
'Debian': {
$spicehtml5proxy_package_name = 'nova-consoleproxy'
$vncproxy_package_name = 'novnc'
$vncproxy_service_name = 'novnc'
# Use default provider on Debian
$special_service_provider = undef
}
default: {
$spicehtml5proxy_package_name = 'nova-spicehtml5proxy'
$vncproxy_package_name = ['novnc', 'nova-novncproxy']
$vncproxy_service_name = 'nova-novncproxy'
# some of the services need to be started form the special upstart provider

View File

@@ -0,0 +1,48 @@
# == Class: nova::spice
#
# Configure spicehtml5 proxy
#
# SPICE is a new protocol which aims to address all the limitations in VNC,
# to provide good remote desktop support. This class aim to configure the nova
# services in charge of proxing websocket spicehtml5 request to kvm spice
#
# === Parameters:
#
# [*enabled*]
# (optional) enable spicehtml5proxy service
# true/false
#
# [*host*]
# (optional) Listen address for the html5 console proxy
# Defaults to 0.0.0.0
#
# [*port*]
# (optional) Listen port for the html5 console proxy
# Defaults to 6082
#
# [*ensure_package*]
# (optional) Ensure package state
# Defaults to 'present'
#
class nova::spicehtml5proxy(
$enabled = false,
$host = '0.0.0.0',
$port = '6082',
$ensure_package = 'present'
) {
include nova::params
nova_config {
'DEFAULT/spicehtml5proxy_host': value => $host;
'DEFAULT/spicehtml5proxy_port': value => $port;
}
nova::generic_service { 'spicehtml5proxy':
enabled => $enabled,
package_name => $::nova::params::spicehtml5proxy_package_name,
service_name => $::nova::params::spicehtml5proxy_service_name,
ensure_package => $ensure_package,
}
}

View File

@@ -19,11 +19,12 @@ class nova::vncproxy(
'DEFAULT/novncproxy_port': value => $port;
}
if ! defined(Package['python-numpy']) {
package { 'python-numpy':
name => $::nova::params::numpy_package_name,
ensure => present,
}
}
nova::generic_service { 'vncproxy':
enabled => $enabled,
package_name => $::nova::params::vncproxy_package_name,

View File

@@ -0,0 +1,23 @@
require 'spec_helper'
describe 'nova::compute::spice' do
it { should contain_nova_config('spice/enabled').with_value('true')}
it { should contain_nova_config('spice/agent_enabled').with_value('true')}
it { should contain_nova_config('spice/server_proxyclient_address').with_value('127.0.0.1')}
it { should_not contain_nova_config('spice/html5proxy_base_url')}
it { should contain_nova_config('spice/server_listen').with_value(nil)}
context 'when overriding params' do
let :params do
{
:proxy_host => '10.10.10.10',
:server_listen => '10.10.11.11',
: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/agent_enabled').with_value('false')}
end
end

View File

@@ -0,0 +1,68 @@
require 'spec_helper'
describe 'nova::spicehtml5proxy' do
let :pre_condition do
'include nova'
end
let :params do
{:enabled => true}
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it { should contain_nova_config('DEFAULT/spicehtml5proxy_host').with(:value => '0.0.0.0') }
it { should contain_nova_config('DEFAULT/spicehtml5proxy_port').with(:value => '6082') }
it { should contain_package('nova-spicehtml5proxy').with(
:name => 'nova-spicehtml5proxy',
:ensure => 'present'
) }
it { should contain_service('nova-spicehtml5proxy').with(
:name => 'nova-spicehtml5proxy',
:hasstatus => 'true',
:ensure => 'running'
)}
describe 'with package version' do
let :params do
{:ensure_package => '2012.1-2'}
end
it { should contain_package('nova-spicehtml5proxy').with(
'ensure' => '2012.1-2'
)}
end
end
describe 'on debian system' do
let :facts do
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
}
end
it { should contain_package('nova-spicehtml5proxy').with(
:name => 'nova-consoleproxy'
)}
end
describe 'on Redhatish platforms' do
let :facts do
{ :osfamily => 'Redhat' }
end
it { should contain_service('nova-spicehtml5proxy').with(
:name => 'openstack-nova-spicehtml5proxy',
:hasstatus => 'true',
:ensure => 'running'
)}
it { should contain_package('nova-spicehtml5proxy').with(
:name => 'openstack-nova-console'
)}
end
end