Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mod 'neutron',
:git => 'https://github.com/stackforge/puppet-neutron.git'

mod 'nova',
:commit => '181991927131206d4ea59a679e8108e36dc86c77',
:commit => '482ca09469f97de8cfbb3fd4f4e08505dfdc8911',
:git => 'https://github.com/stackforge/puppet-nova.git'

mod 'nssdb',
Expand Down
1 change: 1 addition & 0 deletions nova/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
gem 'rake', '10.1.1'
gem 'rspec-puppet', '~> 1.0.1', :require => false
gem 'rspec', '< 2.99'
gem 'json'
gem 'webmock'
Expand Down
27 changes: 27 additions & 0 deletions nova/lib/puppet/parser/functions/check_array_of_hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'json'

def array_of_hash?(list)
return false unless !list.empty? && list.class == Array
list.each do |e|
return false unless e.class == Hash
end
true
end

module Puppet::Parser::Functions
newfunction(:check_array_of_hash, :arity =>1, :type => :rvalue, :doc => "Check
input String is a valid Array of Hash in JSON style") do |arg|
if arg[0].class == String
begin
list = JSON.load(arg[0].gsub("'","\""))
rescue JSON::ParserError
raise Puppet::ParseError, "Syntax error: #{arg[0]} is invalid"
else
return arg[0] if array_of_hash?(list)
end
else
raise Puppet::ParseError, "Syntax error: #{arg[0]} is not a String"
end
return ''
end
end
15 changes: 14 additions & 1 deletion nova/manifests/api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
# (optional) Shared secret to validate proxies Neutron metadata requests
# Defaults to undef
#
# [*pci_alias*]
# (optional) Pci passthrough for controller:
# Defaults to undef
# Example
# "[ {'vendor_id':'1234', 'product_id':'5678', 'name':'default'}, {...} ]"
#
# [*ratelimits*]
# (optional) A string that is a semicolon-separated list of 5-tuples.
# See http://docs.openstack.org/trunk/config-reference/content/configuring-compute-API.html
Expand Down Expand Up @@ -166,6 +172,7 @@
$sync_db = true,
$neutron_metadata_proxy_shared_secret = undef,
$osapi_v3 = false,
$pci_alias = undef,
$ratelimits = undef,
$ratelimits_factory =
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
Expand All @@ -176,6 +183,7 @@
$conductor_workers = undef,
) {

include nova::db
include nova::params
include nova::policy
require keystone::python
Expand Down Expand Up @@ -335,6 +343,12 @@
'filter:authtoken/auth_admin_prefix': ensure => absent;
}

if $pci_alias {
nova_config {
'DEFAULT/pci_alias': value => check_array_of_hash($pci_alias);
}
}

if $validate {
$defaults = {
'nova-api' => {
Expand All @@ -344,5 +358,4 @@
$validation_options_hash = merge ($defaults, $validation_options)
create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[nova-api]'})
}

}
4 changes: 2 additions & 2 deletions nova/manifests/cells.pp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@
case $cell_type {
'parent': {
nova_config { 'DEFAULT/compute_api_class': value => 'nova.compute.cells_api.ComputeCellsAPI' }
nova_config { 'DEFAULT/cell_type': value => 'api' }
nova_config { 'cells/cell_type': value => 'api' }
}
'child': {
nova_config { 'DEFAULT/quota_driver': value => 'nova.quota.NoopQuotaDriver' }
nova_config { 'DEFAULT/cell_type': value => 'compute' }
nova_config { 'cells/cell_type': value => 'compute' }
}
default: { fail("Unsupported cell_type parameter value: '${cell_type}'. Should be 'parent' or 'child'.") }
}
Expand Down
31 changes: 31 additions & 0 deletions nova/manifests/compute.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@
# (optional) Force backing images to raw format.
# Defaults to true
#
# [*reserved_host_memory*]
# Reserved host memory
# The amount of memory in MB reserved for the host.
# Defaults to '512'
#
# [*compute_manager*]
# Compute manager
# The driver that will manage the running instances.
# Defaults to nova.compute.manager.ComputeManager
#
# [*pci_passthrough_whitelist*]
# (optional) Pci passthrough hash in format of:
# Defaults to undef
# Example
# "[ { 'vendor_id':'1234','product_id':'5678' },
# { 'vendor_id':'4321','product_id':'8765','physical_network':'default' } ] "
#
class nova::compute (
$enabled = false,
$manage_service = true,
Expand All @@ -91,10 +108,18 @@
$instance_usage_audit = false,
$instance_usage_audit_period = 'month',
$force_raw_images = true,
$reserved_host_memory = '512',
$compute_manager = 'nova.compute.manager.ComputeManager',
$pci_passthrough = undef,
) {

include nova::params

nova_config {
'DEFAULT/reserved_host_memory_mb': value => $reserved_host_memory;
'DEFAULT/compute_manager': value => $compute_manager;
}

if ($vnc_enabled) {
if ($vncproxy_host) {
$vncproxy_base_url = "${vncproxy_protocol}://${vncproxy_host}:${vncproxy_port}${vncproxy_path}"
Expand Down Expand Up @@ -168,4 +193,10 @@
nova_config {
'DEFAULT/force_raw_images': value => $force_raw_images;
}

if ($pci_passthrough) {
nova_config {
'DEFAULT/pci_passthrough_whitelist': value => check_array_of_hash($pci_passthrough);
}
}
}
49 changes: 49 additions & 0 deletions nova/manifests/compute/ironic.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# == Class: nova::compute::ironic
#
# Configures Nova compute service to use Ironic.
#
# === Parameters:
#
# [*admin_user*]
# Admin username
# The admin username for Ironic to connect to Nova.
# Defaults to 'admin'
#
# [*admin_passwd*]
# Admin password
# The admin password for Ironic to connect to Nova.
# Defaults to 'ironic'
#
# [*admin_url*]
# Admin url
# The address of the Keystone api endpoint.
# Defaults to 'http://127.0.0.1:35357/v2.0'
#
# [*admin_tenant_name*]
# Admin tenant name
# The Ironic Keystone tenant name.
# Defaults to 'services'
#
# [*api_endpoint*]
# Api endpoint
# The url for Ironic api endpoint.
# Defaults to 'http://127.0.0.1:6385/v1'
#

class nova::compute::ironic (
$admin_user = 'admin',
$admin_passwd = 'ironic',
$admin_url = 'http://127.0.0.1:35357/v2.0',
$admin_tenant_name = 'services',
$api_endpoint = 'http://127.0.0.1:6385/v1',
) {

nova_config {
'ironic/admin_username': value => $admin_user;
'ironic/admin_password': value => $admin_passwd;
'ironic/admin_url': value => $admin_url;
'ironic/admin_tenant_name': value => $admin_tenant_name;
'ironic/api_endpoint': value => $api_endpoint;
'DEFAULT/compute_driver': value => 'nova.virt.ironic.IronicDriver';
}
}
20 changes: 20 additions & 0 deletions nova/manifests/compute/libvirt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
# will be removed from nova.conf completely.
# Defaults to an empty list
#
# [*libvirt_inject_password*]
# (optional) Inject the admin password at boot time, without an agent.
# Defaults to false
#
# [*libvirt_inject_key*]
# (optional) Inject the ssh public key at boot time.
# Defaults to false
#
# [*libvirt_inject_partition*]
# (optional) The partition to inject to : -2 => disable, -1 => inspect
# (libguestfs only), 0 => not partitioned, >0 => partition
# number (integer value)
# Defaults to -2
#
# [*remove_unused_base_images*]
# (optional) Should unused base images be removed?
# If undef is specified, remove the line in nova.conf
Expand Down Expand Up @@ -71,6 +85,9 @@
$migration_support = false,
$libvirt_cpu_mode = false,
$libvirt_disk_cachemodes = [],
$libvirt_inject_password = false,
$libvirt_inject_key = false,
$libvirt_inject_partition = -2,
$remove_unused_base_images = undef,
$remove_unused_kernels = undef,
$remove_unused_resized_minimum_age_seconds = undef,
Expand Down Expand Up @@ -150,6 +167,9 @@
'DEFAULT/vncserver_listen': value => $vncserver_listen;
'libvirt/virt_type': value => $libvirt_virt_type_real;
'libvirt/cpu_mode': value => $libvirt_cpu_mode_real;
'libvirt/inject_password': value => $libvirt_inject_password;
'libvirt/inject_key': value => $libvirt_inject_key;
'libvirt/inject_partition': value => $libvirt_inject_partition;
}

if size($libvirt_disk_cachemodes) > 0 {
Expand Down
1 change: 1 addition & 0 deletions nova/manifests/conductor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$workers = undef,
) {

include nova::db
include nova::params

nova::generic_service { 'conductor':
Expand Down
2 changes: 1 addition & 1 deletion nova/manifests/cron/archive_deleted_rows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

cron { 'nova-manage db archive_deleted_rows':
command => "nova-manage db archive_deleted_rows --max_rows ${max_rows} >>/var/log/nova/nova-rowsflush.log 2>&1",
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
user => $user,
minute => $minute,
hour => $hour,
Expand Down
56 changes: 56 additions & 0 deletions nova/manifests/db.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Class: nova::db
# Configures the nova database.
#
# == Parameters
#
# [*database_connection*]
# (optional) Connection url to connect to nova database.
# Defaults to undef
#
# [*database_idle_timeout*]
# (optional) Timeout before idle db connections are reaped.
# Defaults to undef
#
class nova::db (
$database_connection = undef,
$database_idle_timeout = undef,
) {

$database_connection_real = pick($database_connection, $::nova::database_connection, false)
$database_idle_timeout_real = pick($database_idle_timeout, $::nova::database_idle_timeout, false)

if $database_connection_real {
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
require 'mysql::bindings'
require 'mysql::bindings::python'
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {

} elsif($database_connection_real =~ /sqlite:\/\//) {

} else {
fail("Invalid db connection ${database_connection_real}")
}
nova_config {
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
}
}

}
36 changes: 3 additions & 33 deletions nova/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@
$os_region_name = undef,
) inherits nova::params {

# maintain backward compatibility
include nova::db

if $mysql_module {
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
}
Expand Down Expand Up @@ -498,39 +501,6 @@
refreshonly => true,
}

if $sql_connection {
warning('The sql_connection parameter is deprecated, use database_connection instead.')
$database_connection_real = $sql_connection
} else {
$database_connection_real = $database_connection
}

if $sql_idle_timeout {
warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
$database_idle_timeout_real = $sql_idle_timeout
} else {
$database_idle_timeout_real = $database_idle_timeout
}

# both the database_connection and rabbit_host are things
# that may need to be collected from a remote host
if $database_connection_real {
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
require 'mysql::bindings'
require 'mysql::bindings::python'
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {

} elsif($database_connection_real =~ /sqlite:\/\//) {

} else {
fail("Invalid db connection ${database_connection_real}")
}
nova_config {
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
}
}

nova_config { 'DEFAULT/image_service': value => $image_service }

if $image_service == 'nova.image.glance.GlanceImageService' {
Expand Down
1 change: 1 addition & 0 deletions nova/manifests/scheduler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$ensure_package = 'present'
) {

include nova::db
include nova::params

nova::generic_service { 'scheduler':
Expand Down
Loading