commit
e08ce5a372
|
@ -22,6 +22,29 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
|
|||
end.compact
|
||||
end
|
||||
|
||||
def create
|
||||
optional_opts = []
|
||||
{
|
||||
# this needs to be converted from a project name to an id
|
||||
:project => '--project_id',
|
||||
:dns2 => '--dns2',
|
||||
:gateway => '--gateway',
|
||||
:bridge => '--bridge',
|
||||
:vlan_start => '--vlan'
|
||||
}.each do |param, opt|
|
||||
if resource[param]
|
||||
optional_opts.push(opt).push(resource[param])
|
||||
end
|
||||
end
|
||||
|
||||
nova_manage('network', 'create',
|
||||
"--label=#{resource[:label]}",
|
||||
"--fixed_range_v4=#{resource[:name]}",
|
||||
"--num_networks=#{resource[:num_networks]}",
|
||||
optional_opts
|
||||
)
|
||||
end
|
||||
|
||||
def exists?
|
||||
begin
|
||||
network_list = nova_manage("network", "list")
|
||||
|
@ -34,15 +57,9 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
|
|||
end
|
||||
end
|
||||
|
||||
def create
|
||||
mask=resource[:network].sub(/.*\/([1-3][0-9]?)/, '\1')
|
||||
available_ips=2**(32-mask.to_i)
|
||||
nova_manage("network", "create", resource[:label], resource[:network], "1", available_ips, "--bridge=#{resource[:bridge]}")
|
||||
end
|
||||
|
||||
def destroy
|
||||
nova_manage("network", "delete", resource[:network])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Puppet::Type.newtype(:nova_network) do
|
|||
# segments b/c it is actually the combination of network/prefix
|
||||
# that determine uniqueness
|
||||
newparam(:network, :namevar => true) do
|
||||
desc "Network (ie, 192.168.1.0/24)"
|
||||
desc "IPv4 Network (ie, 192.168.1.0/24)"
|
||||
newvalues(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0\/[0-9]{1,2}$/)
|
||||
end
|
||||
|
||||
|
@ -18,17 +18,34 @@ Puppet::Type.newtype(:nova_network) do
|
|||
defaultto "novanetwork"
|
||||
end
|
||||
|
||||
newparam(:available_ips) do
|
||||
desc "# of available IPs. Must be greater than 4."
|
||||
validate do |value|
|
||||
if value.to_i < 4
|
||||
raise Puppet::Error, "ERROR - nova_network: Parameter available_ips must be an integer greater than 4."
|
||||
end
|
||||
end
|
||||
newparam(:num_networks) do
|
||||
desc 'Number of networks to create'
|
||||
defaultto(1)
|
||||
end
|
||||
|
||||
newparam(:bridge) do
|
||||
defaultto 'br100'
|
||||
desc 'bridge to use for flat network'
|
||||
end
|
||||
|
||||
newparam(:project) do
|
||||
desc 'project that the network is associated with'
|
||||
end
|
||||
|
||||
# we are not currently using this stuff
|
||||
newparam(:gateway) do
|
||||
|
||||
end
|
||||
|
||||
newparam(:dns2) do
|
||||
|
||||
end
|
||||
|
||||
newparam(:vlan_start) do
|
||||
|
||||
end
|
||||
|
||||
validate do
|
||||
raise(Puppet::Error, 'Label must be set') unless self[:label]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
109
manifests/all.pp
109
manifests/all.pp
|
@ -1,109 +0,0 @@
|
|||
#
|
||||
# TODO - this is currently hardcoded to be a xenserver
|
||||
# TODO - this needs to be updated
|
||||
class nova::all(
|
||||
$db_password,
|
||||
$db_name = 'nova',
|
||||
$db_user = 'nova',
|
||||
$db_host = 'localhost',
|
||||
|
||||
$rabbit_port = undef,
|
||||
$rabbit_userid = undef,
|
||||
$rabbit_password = undef,
|
||||
$rabbit_virtual_host = undef,
|
||||
$rabbit_host = undef,
|
||||
|
||||
$libvirt_type = 'kvm',
|
||||
|
||||
$flat_network_bridge = 'br100',
|
||||
$flat_network_bridge_ip = '11.0.0.1',
|
||||
$flat_network_bridge_netmask = '255.255.255.0',
|
||||
|
||||
$nova_network = '11.0.0.0/24',
|
||||
$available_ips = '256',
|
||||
|
||||
$image_service = 'nova.image.glance.GlanceImageService',
|
||||
$glance_api_servers = 'localhost:9292',
|
||||
|
||||
$admin_user = 'novaadmin',
|
||||
$project_name = 'nova',
|
||||
|
||||
$verbose = undef
|
||||
) {
|
||||
|
||||
|
||||
class { 'nova::rabbitmq':
|
||||
port => $rabbit_port,
|
||||
userid => $rabbit_userid,
|
||||
password => $rabbit_password,
|
||||
virtual_host => $rabbit_virtual_host,
|
||||
}
|
||||
|
||||
class { "nova":
|
||||
verbose => $verbose,
|
||||
sql_connection => "mysql://${db_user}:${db_password}@${db_host}/${db_name}",
|
||||
image_service => $image_service,
|
||||
glance_api_servers => $glance_api_servers,
|
||||
rabbit_host => $rabbit_host,
|
||||
rabbit_port => $rabbit_port,
|
||||
rabbit_userid => $rabbit_userid,
|
||||
rabbit_password => $rabbit_password,
|
||||
rabbit_virtual_host => $rabbit_virtual_host,
|
||||
}
|
||||
|
||||
class { "nova::api":
|
||||
enabled => true
|
||||
}
|
||||
|
||||
class { "nova::compute":
|
||||
enabled => true,
|
||||
}
|
||||
class { 'nova::compute::libvirt':
|
||||
libvirt_type => $libvirt_type,
|
||||
flat_network_bridge => $flat_network_bridge,
|
||||
flat_network_bridge_ip => $flat_network_bridge_ip,
|
||||
flat_network_bridge_netmask => $flat_network_bridge_netmask,
|
||||
}
|
||||
|
||||
class { "nova::network::flat":
|
||||
enabled => true,
|
||||
flat_network_bridge => $flat_network_bridge,
|
||||
flat_network_bridge_ip => $flat_network_bridge_ip,
|
||||
flat_network_bridge_netmask => $flat_network_bridge_netmask,
|
||||
configure_bridge => false,
|
||||
}
|
||||
|
||||
class { "nova::objectstore": enabled => true }
|
||||
class { "nova::scheduler": enabled => true }
|
||||
class { 'nova::db::mysql':
|
||||
# pass in db config as params
|
||||
password => $db_password,
|
||||
dbname => $db_name,
|
||||
user => $db_user,
|
||||
host => $db_host,
|
||||
}
|
||||
|
||||
class { 'nova::cert': enabled => true }
|
||||
|
||||
class { 'nova::volume': enabled => true }
|
||||
|
||||
class { 'nova::vncproxy': enabled => true }
|
||||
|
||||
nova::manage::admin { $admin_user: }
|
||||
nova::manage::project { $project_name:
|
||||
owner => $admin_user,
|
||||
}
|
||||
|
||||
nova::manage::network { "${project_name}-net-${nova_network}":
|
||||
network => $nova_network,
|
||||
available_ips => $available_ips,
|
||||
require => Nova::Manage::Project[$project_name],
|
||||
}
|
||||
|
||||
# set up glance server
|
||||
class { 'glance::api': }
|
||||
|
||||
class { 'glance::registry': }
|
||||
|
||||
|
||||
}
|
|
@ -14,9 +14,6 @@ class nova::api(
|
|||
|
||||
$auth_uri = "${auth_protocol}://${auth_host}:${auth_port}/v2.0"
|
||||
|
||||
# TODO what exactly is this for?
|
||||
# This resource is adding a great deal of comlexity to the overall
|
||||
# modules. Removing it would be great
|
||||
exec { 'initial-db-sync':
|
||||
command => '/usr/bin/nova-manage db sync',
|
||||
refreshonly => true,
|
||||
|
|
|
@ -28,6 +28,11 @@ class nova::compute(
|
|||
'vncserver_proxyclient_address': value => $vncserver_proxyclient_address;
|
||||
}
|
||||
|
||||
package { 'bridge-utils':
|
||||
ensure => present,
|
||||
before => Nova::Generic_service['compute'],
|
||||
}
|
||||
|
||||
nova::generic_service { 'compute':
|
||||
enabled => $enabled,
|
||||
package_name => $::nova::params::compute_package_name,
|
||||
|
|
|
@ -31,6 +31,7 @@ define nova::generic_service(
|
|||
Exec['post-nova_config'] ~> Service<| title == $nova_title |>
|
||||
# ensure that the service has only been started
|
||||
# after the initial db sync
|
||||
Exec<| title == 'initial-db-sync' |> ~> Service<| title == $nova_title |>
|
||||
Exec['nova-db-sync'] ~> Service<| title == $nova_title |>
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,33 @@
|
|||
# This class is used to specify configuration parameters that are common
|
||||
# across all nova services.
|
||||
#
|
||||
# ==Parameters
|
||||
#
|
||||
# [sql_connection] Connection url to use to connect to nova sql database.
|
||||
# If specified as false, then it tries to collect the exported resource
|
||||
# Nova_config <<| title == 'sql_connection' |>>. Optional. Defaults to false.
|
||||
# [image_service] Service used to search for and retrieve images. Optional.
|
||||
# Defaults to 'nova.image.local.LocalImageService'
|
||||
# [glance_api_servers] List of addresses for api servers. Optional.
|
||||
# Defaults to localhost:9292.
|
||||
# [rabbit_host] Location of rabbitmq installation. Optional. Defaults to localhost.
|
||||
# [rabbit_password] Password used to connect to rabbitmq. Optional. Defaults to guest.
|
||||
# [rabbit_port] Port for rabbitmq instance. Optional. Defaults to 5672.
|
||||
# [rabbit_userid] User used to connect to rabbitmq. Optional. Defaults to guest.
|
||||
# [rabbit_virtual_host] The RabbitMQ virtual host. Optional. Defaults to /.
|
||||
# [auth_strategy]
|
||||
# [service_down_time] maximum time since last check-in for up service. Optional.
|
||||
# Defaults to 60
|
||||
# [logdir] Directory where logs should be stored. Optional. Defaults to '/var/log/nova'.
|
||||
# [state_path] Directory for storing state. Optional. Defaults to '/var/lib/nova'.
|
||||
# [lock_path] Directory for lock files. Optional. Distro specific default.
|
||||
# [verbose] Rather to print more verbose output. Optional. Defaults to false.
|
||||
# [periodic_interval] Seconds between running periodic tasks. Optional.
|
||||
# Defaults to '60'.
|
||||
# [report_interval] Interval at which nodes report to data store. Optional.
|
||||
# Defaults to '10'.
|
||||
# [root_helper] Command used for roothelper. Optional. Distro specific.
|
||||
#
|
||||
class nova(
|
||||
# this is how to query all resources from our clutser
|
||||
$nova_cluster_id='localcluster',
|
||||
|
@ -6,24 +36,17 @@ class nova(
|
|||
# these glance params should be optional
|
||||
# this should probably just be configured as a glance client
|
||||
$glance_api_servers = 'localhost:9292',
|
||||
$allow_admin_api = false,
|
||||
$rabbit_host = 'localhost',
|
||||
$rabbit_password='guest',
|
||||
$rabbit_port='5672',
|
||||
$rabbit_userid='guest',
|
||||
$rabbit_virtual_host='/',
|
||||
$auth_strategy = 'keystone',
|
||||
$network_manager = 'nova.network.manager.FlatManager',
|
||||
$multi_host_networking = false,
|
||||
$flat_network_bridge = 'br100',
|
||||
$vlan_interface = 'eth1',
|
||||
$vlan_start = 1000,
|
||||
$service_down_time = 60,
|
||||
$logdir = '/var/log/nova',
|
||||
$state_path = '/var/lib/nova',
|
||||
$lock_path = $::nova::params::lock_path,
|
||||
$verbose = false,
|
||||
$nodaemon = false,
|
||||
$periodic_interval = '60',
|
||||
$report_interval = '10',
|
||||
$root_helper = $::nova::params::root_helper
|
||||
|
@ -34,13 +57,13 @@ class nova(
|
|||
# before the file resource for nova.conf is managed
|
||||
# and before the post config resource
|
||||
Nova_config<| |> {
|
||||
require +> Package[$::nova::params::common_package_name],
|
||||
require +> Package['nova-common'],
|
||||
before +> File['/etc/nova/nova.conf'],
|
||||
notify +> Exec['post-nova_config']
|
||||
}
|
||||
|
||||
File {
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
require => Package['nova-common'],
|
||||
owner => 'nova',
|
||||
group => 'nova',
|
||||
}
|
||||
|
@ -67,7 +90,7 @@ class nova(
|
|||
}
|
||||
|
||||
package { 'nova-common':
|
||||
name =>$::nova::params::common_package_name,
|
||||
name => $::nova::params::common_package_name,
|
||||
ensure => present,
|
||||
require => [Package["python-nova"], Anchor['nova-start']]
|
||||
}
|
||||
|
@ -97,6 +120,7 @@ class nova(
|
|||
exec { "nova-db-sync":
|
||||
command => "/usr/bin/nova-manage db sync",
|
||||
refreshonly => "true",
|
||||
require => [Package['nova-common'], Nova_config['sql_connection']],
|
||||
}
|
||||
|
||||
# used by debian/ubuntu in nova::network_bridge to refresh
|
||||
|
@ -114,25 +138,19 @@ class nova(
|
|||
} else {
|
||||
Nova_config <<| title == 'sql_connection' |>>
|
||||
}
|
||||
if $rabbit_host {
|
||||
nova_config { 'rabbit_host': value => $rabbit_host }
|
||||
} else {
|
||||
Nova_config <<| title == 'rabbit_host' |>>
|
||||
}
|
||||
|
||||
nova_config { 'image_service': value => $image_service }
|
||||
|
||||
if $image_service == 'nova.image.glance.GlanceImageService' {
|
||||
if $glance_api_servers {
|
||||
nova_config {
|
||||
'glance_api_servers': value => $glance_api_servers
|
||||
}
|
||||
nova_config { 'glance_api_servers': value => $glance_api_servers }
|
||||
} else {
|
||||
# TODO this only supports setting a single address for the api server
|
||||
Nova_config <<| title == glance_api_servers |>>
|
||||
}
|
||||
}
|
||||
|
||||
nova_config {
|
||||
'auth_strategy': value => $auth_strategy;
|
||||
}
|
||||
nova_config { 'auth_strategy': value => $auth_strategy }
|
||||
|
||||
if $auth_strategy == 'keystone' {
|
||||
nova_config { 'use_deprecated_auth': value => false }
|
||||
|
@ -141,6 +159,11 @@ class nova(
|
|||
}
|
||||
|
||||
|
||||
if $rabbit_host {
|
||||
nova_config { 'rabbit_host': value => $rabbit_host }
|
||||
} else {
|
||||
Nova_config <<| title == 'rabbit_host' |>>
|
||||
}
|
||||
# I may want to support exporting and collecting these
|
||||
nova_config {
|
||||
'rabbit_password': value => $rabbit_password;
|
||||
|
@ -152,19 +175,11 @@ class nova(
|
|||
|
||||
nova_config {
|
||||
'verbose': value => $verbose;
|
||||
'nodaemon': value => $nodaemon;
|
||||
'logdir': value => $logdir;
|
||||
'image_service': value => $image_service;
|
||||
'allow_admin_api': value => $allow_admin_api;
|
||||
# Following may need to be broken out to different nova services
|
||||
'state_path': value => $state_path;
|
||||
'lock_path': value => $lock_path;
|
||||
'service_down_time': value => $service_down_time;
|
||||
# These network entries wound up in the common
|
||||
# config b/c they have to be set by both compute
|
||||
# as well as controller.
|
||||
'network_manager': value => $network_manager;
|
||||
'multi_host': value => $multi_host_networking;
|
||||
'root_helper': value => $root_helper;
|
||||
}
|
||||
|
||||
|
@ -173,24 +188,4 @@ class nova(
|
|||
refreshonly => true,
|
||||
}
|
||||
|
||||
if $network_manager == 'nova.network.manager.FlatManager' {
|
||||
nova_config {
|
||||
'flat_network_bridge': value => $flat_network_bridge
|
||||
}
|
||||
}
|
||||
|
||||
if $network_manager == 'nova.network.manager.FlatDHCPManager' {
|
||||
nova_config {
|
||||
'dhcpbridge': value => "/usr/bin/nova-dhcpbridge";
|
||||
'dhcpbridge_flagfile': value => "/etc/nova/nova.conf";
|
||||
}
|
||||
}
|
||||
|
||||
if $network_manager == 'nova.network.manager.VlanManager' {
|
||||
nova_config {
|
||||
'vlan_interface': value => $vlan_interface;
|
||||
'vlan_start': value => $vlan_start;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
define nova::manage::network ( $network ) {
|
||||
#
|
||||
# ==Parameters
|
||||
# [network] ipv4 CIDR of network to create. Required.
|
||||
# [num_networks] Number of networks to split $network into. Optional
|
||||
# Defaults to 1.
|
||||
# [project] Project that network should be associated with.
|
||||
#
|
||||
define nova::manage::network (
|
||||
$network,
|
||||
$num_networks = 1,
|
||||
$project = undef
|
||||
) {
|
||||
|
||||
File['/etc/nova/nova.conf'] -> Nova_network[$name]
|
||||
Exec<| title == 'initial-db-sync' |> -> Nova_network[$name]
|
||||
|
||||
nova_network { $name:
|
||||
ensure => present,
|
||||
network => $network,
|
||||
notify => Exec["nova-db-sync"],
|
||||
ensure => present,
|
||||
network => $network,
|
||||
num_networks => $num_networks,
|
||||
project => undef,
|
||||
notify => Exec['nova-db-sync'],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,113 @@
|
|||
#
|
||||
# [private_interface] Interface used by private network.
|
||||
# [public_interface] Interface used to connect vms to public network.
|
||||
# [fixed_range] Fixed private network range.
|
||||
# [num_networks] Number of networks that fixed range network should be
|
||||
# split into.
|
||||
# [floating_range] Range of floating ip addresses to create.
|
||||
# [enabled] Rather the network service should be enabled.
|
||||
# [network_manager] The type of network manager to use.
|
||||
# [network_config]
|
||||
# [create_networks] Rather actual nova networks should be created using
|
||||
# the fixed and floating ranges provided.
|
||||
#
|
||||
class nova::network(
|
||||
$enabled=false
|
||||
$private_interface,
|
||||
$fixed_range,
|
||||
$public_interface = undef,
|
||||
$num_networks = 1,
|
||||
$floating_range = false,
|
||||
$enabled = false,
|
||||
$network_manager = 'nova.network.manager.FlatDHCPManager',
|
||||
$config_overrides = {},
|
||||
$create_networks = true,
|
||||
$install_service = true
|
||||
) {
|
||||
|
||||
include nova::params
|
||||
|
||||
nova::generic_service { 'network':
|
||||
enabled => $enabled,
|
||||
package_name => $::nova::params::network_package_name,
|
||||
service_name => $::nova::params::network_service_name,
|
||||
before => Exec['networking-refresh']
|
||||
# forward all ipv4 traffic
|
||||
# this is required for the vms to pass through the gateways
|
||||
# public interface
|
||||
Exec {
|
||||
path => $::path
|
||||
}
|
||||
|
||||
sysctl::value { 'net.ipv4.ip_forward':
|
||||
value => '1'
|
||||
}
|
||||
|
||||
if $floating_range {
|
||||
nova_config { 'floating_range': value => $floating_range }
|
||||
}
|
||||
|
||||
if $install_service {
|
||||
nova::generic_service { 'network':
|
||||
enabled => $enabled,
|
||||
package_name => $::nova::params::network_package_name,
|
||||
service_name => $::nova::params::network_service_name,
|
||||
before => Exec['networking-refresh']
|
||||
}
|
||||
}
|
||||
|
||||
if $create_networks {
|
||||
nova::manage::network { 'nova-vm-net':
|
||||
network => $fixed_range,
|
||||
num_networks => $num_networks,
|
||||
}
|
||||
if $floating_range {
|
||||
nova::manage::floating { 'nova-vm-floating':
|
||||
network => $floating_range,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case $network_manager {
|
||||
|
||||
'nova.network.manager.FlatDHCPManager': {
|
||||
|
||||
$flat_network_bridge = $config_overrides['flat_network_bridge']
|
||||
$force_dhcp_release = $config_overrides['force_dhcp_release']
|
||||
$flat_injected = $config_overrides['flat_injected']
|
||||
$dhcpbridge = $config_overrides['dhcpbridge']
|
||||
$dhcpbridge_flagfile = $config_overrides['dhcpbridge_flagfile']
|
||||
|
||||
class { 'nova::network::flatdhcp':
|
||||
fixed_range => $fixed_range,
|
||||
public_interface => $public_interface,
|
||||
flat_interface => $private_interface,
|
||||
flat_network_bridge => $flat_network_bridge,
|
||||
force_dhcp_release => $force_dhcp_release,
|
||||
flat_injected => $flat_injected,
|
||||
dhcpbridge => $dhcpbridge,
|
||||
dhcpbridge_flagfile => $dhcpbridge_flagfile,
|
||||
}
|
||||
}
|
||||
'nova.network.manager.FlatManager': {
|
||||
|
||||
$flat_network_bridge = $config_overrides['flat_network_bridge']
|
||||
|
||||
class { 'nova::network::flat':
|
||||
fixed_range => $fixed_range,
|
||||
public_interface => $public_interface,
|
||||
flat_interface => $private_interface,
|
||||
flat_network_bridge => $flat_network_bridge,
|
||||
}
|
||||
}
|
||||
'nova.network.manager.VlanManager': {
|
||||
|
||||
$vlan_start = $config_overrides['vlan_start']
|
||||
|
||||
class { 'nova::network::vlan':
|
||||
fixed_range => $fixed_range,
|
||||
public_interface => $public_interface,
|
||||
vlan_interface => $private_interface,
|
||||
vlan_start => $vlan_start,
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported network manager: ${nova::network_manager} The supported network managers are nova.network.manager.FlatManager, nova.network.FlatDHCPManager and nova.network.manager.VlanManager")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
# flat.pp
|
||||
# Configuration settings for nova flat network
|
||||
# ==Parameters
|
||||
# [flat_interface] Interface that flat network will use for bridging.
|
||||
# [flat_network_bridge] Name of bridge.
|
||||
class nova::network::flat (
|
||||
$flat_network_bridge,
|
||||
$configure_bridge = true,
|
||||
$flat_network_bridge_ip,
|
||||
$flat_network_bridge_netmask,
|
||||
$enabled = "true"
|
||||
$flat_interface,
|
||||
$fixed_range,
|
||||
$public_interface = undef,
|
||||
$flat_network_bridge = 'br100'
|
||||
) {
|
||||
|
||||
class { 'nova::network':
|
||||
enabled => $enabled,
|
||||
if $public_interface {
|
||||
nova_config { 'public_interface': value => $public_interface }
|
||||
}
|
||||
|
||||
# flatManager requires a network bridge be manually setup.
|
||||
if $configure_bridge {
|
||||
nova::network::bridge { $flat_network_bridge:
|
||||
ip => $flat_network_bridge_ip,
|
||||
netmask => $flat_network_bridge_netmask,
|
||||
}
|
||||
nova_config {
|
||||
'network_manager': value => 'nova.network.manager.FlatManager';
|
||||
'fixed_range': value => $fixed_range;
|
||||
'flat_interface': value => $flat_interface;
|
||||
'flat_network_bridge': value => $flat_network_bridge;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
# flatdhcp.pp
|
||||
class nova::network::flatdhcp (
|
||||
$public_interface,
|
||||
$flat_interface,
|
||||
$flat_dhcp_start,
|
||||
$flat_injected = 'false',
|
||||
$dhcpbridge = '/usr/bin/nova-dhcpbridge',
|
||||
$dhcpbridge_flagfile='/etc/nova/nova.conf',
|
||||
$enabled = 'true'
|
||||
$fixed_range,
|
||||
$public_interface = undef,
|
||||
$flat_network_bridge = 'br100',
|
||||
$force_dhcp_release = true,
|
||||
$flat_injected = false,
|
||||
$dhcpbridge = '/usr/bin/nova-dhcpbridge',
|
||||
$dhcpbridge_flagfile = '/etc/nova/nova.conf'
|
||||
) {
|
||||
# we only need to setup configuration, nova does the rest
|
||||
class { 'nova::network':
|
||||
enabled => $enabled,
|
||||
|
||||
if $public_interface {
|
||||
nova_config { 'public_interface': value => $public_interface }
|
||||
}
|
||||
|
||||
nova_config {
|
||||
'public_interface': value => $public_interface;
|
||||
'flat_interface': value => $flat_interface;
|
||||
'flat_dhcp_start': value => $flat_dhcp_start;
|
||||
'flat_injected': value => $flat_injected;
|
||||
'dhcpbridge': value => $dhcpbridge;
|
||||
'network_manager': value => 'nova.network.manager.FlatDHCPManager';
|
||||
'fixed_range': value => $fixed_range;
|
||||
'flat_interface': value => $flat_interface;
|
||||
'flat_network_bridge': value => $flat_network_bridge;
|
||||
#'flat_dhcp_start': value => $flat_dhcp_start;
|
||||
'force_dhcp_release': value => $force_dhcp_release;
|
||||
'flat_injected': value => $flat_injected;
|
||||
'dhcpbridge': value => $dhcpbridge;
|
||||
'dhcpbridge_flagfile': value => $dhcpbridge_flagfile;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
#vlan.pp
|
||||
class nova::network::vlan (
|
||||
$enabled = true
|
||||
$fixed_range,
|
||||
$vlan_interface,
|
||||
$public_interface = undef,
|
||||
$vlan_start = '300'
|
||||
) {
|
||||
class { 'nova::network':
|
||||
enabled => $enabled,
|
||||
|
||||
if $public_interface {
|
||||
nova_config { 'public_interface': value => $public_interface }
|
||||
}
|
||||
|
||||
nova_config {
|
||||
'network_manager': value => 'nova.network.manager.VlanManager';
|
||||
'fixed_range': value => $fixed_range;
|
||||
'vlan_interface': value => $vlan_interface;
|
||||
'vlan_start': value => $vlan_start;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute::multi_host' do
|
||||
|
||||
let :pre_condition do
|
||||
'class { "nova": network_manager => "nova.network.manager.VlanManager" }'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should include_class('nova::api') }
|
||||
it { should contain_nova_config('enabled_apis').with_value('metadata') }
|
||||
end
|
||||
end
|
|
@ -35,6 +35,11 @@ describe 'nova::compute' do
|
|||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-compute]'
|
||||
) }
|
||||
it { should contain_package('bridge-utils').with(
|
||||
:ensure => 'present',
|
||||
:before => 'Nova::Generic_service[compute]'
|
||||
) }
|
||||
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{
|
||||
|
|
|
@ -16,6 +16,10 @@ describe 'nova' do
|
|||
'ensure' => 'present',
|
||||
'require' => 'Package[python-greenlet]'
|
||||
)}
|
||||
it { should contain_package('nova-common').with(
|
||||
'name' => 'nova-common',
|
||||
'ensure' => 'present'
|
||||
)}
|
||||
|
||||
it { should contain_group('nova').with(
|
||||
'ensure' => 'present',
|
||||
|
@ -57,27 +61,27 @@ describe 'nova' do
|
|||
|
||||
it { should_not contain_nova_config('sql_connection') }
|
||||
|
||||
it { should contain_nova_config('verbose').with_value(false) }
|
||||
it { should contain_nova_config('nodaemon').with_value('false') }
|
||||
it { should contain_nova_config('logdir').with_value('/var/log/nova') }
|
||||
it { should contain_nova_config('image_service').with_value('nova.image.local.LocalImageService') }
|
||||
it { should contain_nova_config('allow_admin_api').with_value('false') }
|
||||
it { should contain_nova_config('image_service').with_value('nova.image.glance.GlanceImageService') }
|
||||
it { should contain_nova_config('glance_api_servers').with_value('localhost:9292') }
|
||||
|
||||
it { should contain_nova_config('auth_strategy').with_value('keystone') }
|
||||
it { should contain_nova_config('use_deprecated_auth').with_value('false') }
|
||||
|
||||
it { should contain_nova_config('rabbit_host').with_value('localhost') }
|
||||
it { should contain_nova_config('rabbit_password').with_value('guest') }
|
||||
it { should contain_nova_config('rabbit_port').with_value('5672') }
|
||||
it { should contain_nova_config('rabbit_userid').with_value('guest') }
|
||||
it { should contain_nova_config('rabbit_virtual_host').with_value('/') }
|
||||
|
||||
it { should contain_nova_config('verbose').with_value(false) }
|
||||
it { should contain_nova_config('logdir').with_value('/var/log/nova') }
|
||||
it { should contain_nova_config('state_path').with_value('/var/lib/nova') }
|
||||
it { should contain_nova_config('lock_path').with_value('/var/lock/nova') }
|
||||
it { should contain_nova_config('service_down_time').with_value('60') }
|
||||
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatManager') }
|
||||
it { should_not contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
|
||||
it { should_not contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
|
||||
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
|
||||
|
||||
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
|
||||
it { should contain_nova_config('use_deprecated_auth').with_value('false') }
|
||||
|
||||
describe 'with parameters supplied' do
|
||||
|
||||
|
@ -85,45 +89,39 @@ describe 'nova' do
|
|||
{
|
||||
'sql_connection' => 'mysql://user:pass@db/db',
|
||||
'verbose' => true,
|
||||
'nodaemon' => true,
|
||||
'logdir' => '/var/log/nova2',
|
||||
'image_service' => 'nova.image.glance.GlanceImageService',
|
||||
'allow_admin_api' => true,
|
||||
'image_service' => 'nova.image.local.LocalImageService',
|
||||
'rabbit_host' => 'rabbit',
|
||||
'rabbit_userid' => 'rabbit_user',
|
||||
'rabbit_port' => '5672',
|
||||
'rabbit_userid' => 'rabbit_user',
|
||||
'rabbit_port' => '5673',
|
||||
'rabbit_password' => 'password',
|
||||
'lock_path' => '/var/locky/path',
|
||||
'state_path' => '/var/lib/nova2',
|
||||
'service_down_time' => '120',
|
||||
'network_manager' => 'nova.network.manager.FlatDHCPManager',
|
||||
'auth_strategy' => 'foo'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('use_deprecated_auth').with_value('true') }
|
||||
it { should contain_nova_config('sql_connection').with_value('mysql://user:pass@db/db') }
|
||||
|
||||
it { should contain_nova_config('verbose').with_value(true) }
|
||||
it { should contain_nova_config('nodaemon').with_value(true) }
|
||||
it { should contain_nova_config('logdir').with_value('/var/log/nova2') }
|
||||
# glance config
|
||||
it { should contain_nova_config('image_service').with_value('nova.image.glance.GlanceImageService') }
|
||||
it { should contain_nova_config('glance_api_servers').with_value('localhost:9292') }
|
||||
it { should contain_nova_config('allow_admin_api').with_value(true) }
|
||||
it { should contain_nova_config('image_service').with_value('nova.image.local.LocalImageService') }
|
||||
it { should_not contain_nova_config('glance_api_servers') }
|
||||
|
||||
it { should contain_nova_config('auth_strategy').with_value('foo') }
|
||||
it { should contain_nova_config('use_deprecated_auth').with_value(true) }
|
||||
|
||||
it { should contain_nova_config('rabbit_host').with_value('rabbit') }
|
||||
it { should contain_nova_config('rabbit_password').with_value('password') }
|
||||
it { should contain_nova_config('rabbit_port').with_value('5672') }
|
||||
it { should contain_nova_config('rabbit_port').with_value('5673') }
|
||||
it { should contain_nova_config('rabbit_userid').with_value('rabbit_user') }
|
||||
it { should contain_nova_config('rabbit_virtual_host').with_value('/') }
|
||||
|
||||
it { should contain_nova_config('verbose').with_value(true) }
|
||||
it { should contain_nova_config('logdir').with_value('/var/log/nova2') }
|
||||
it { should contain_nova_config('state_path').with_value('/var/lib/nova2') }
|
||||
it { should contain_nova_config('lock_path').with_value('/var/locky/path') }
|
||||
it { should contain_nova_config('service_down_time').with_value('120') }
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatDHCPManager') }
|
||||
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
|
||||
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
|
||||
|
||||
end
|
||||
|
||||
describe "When platform is RedHat" do
|
||||
|
@ -134,6 +132,7 @@ describe 'nova' do
|
|||
'name' => 'openstack-nova',
|
||||
'ensure' => 'present'
|
||||
)}
|
||||
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::network::flat' do
|
||||
|
||||
describe 'with only required parameters' do
|
||||
let :params do
|
||||
{
|
||||
:flat_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatManager') }
|
||||
it { should_not contain_nova_config('public_interface') }
|
||||
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
|
||||
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
|
||||
it { should contain_nova_config('flat_interface').with_value('eth1') }
|
||||
end
|
||||
|
||||
describe 'when overriding class parameters' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:flat_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => 'eth0',
|
||||
:flat_network_bridge => 'br1001',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('public_interface').with_value('eth0') }
|
||||
it { should contain_nova_config('flat_network_bridge').with_value('br1001') }
|
||||
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
|
||||
it { should contain_nova_config('flat_interface').with_value('eth1') }
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,49 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::network::flatdhcp' do
|
||||
|
||||
describe 'with only required parameters' do
|
||||
let :params do
|
||||
{
|
||||
:flat_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatDHCPManager') }
|
||||
it { should_not contain_nova_config('public_interface') }
|
||||
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
|
||||
it { should contain_nova_config('flat_interface').with_value('eth1') }
|
||||
it { should contain_nova_config('flat_interface').with_value('eth1') }
|
||||
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
|
||||
it { should contain_nova_config('force_dhcp_release').with_value('true') }
|
||||
it { should contain_nova_config('flat_injected').with_value('false') }
|
||||
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
|
||||
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
|
||||
end
|
||||
|
||||
describe 'when overriding class parameters' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:flat_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => 'eth0',
|
||||
:flat_network_bridge => 'br1001',
|
||||
:force_dhcp_release => false,
|
||||
:flat_injected => true,
|
||||
:dhcpbridge => '/usr/bin/dhcpbridge',
|
||||
:dhcpbridge_flagfile => '/etc/nova/nova-dhcp.conf'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('public_interface').with_value('eth0') }
|
||||
it { should contain_nova_config('flat_network_bridge').with_value('br1001') }
|
||||
it { should contain_nova_config('force_dhcp_release').with_value('false') }
|
||||
it { should contain_nova_config('flat_injected').with_value('true') }
|
||||
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/dhcpbridge') }
|
||||
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova-dhcp.conf') }
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -6,29 +6,181 @@ describe 'nova::network' do
|
|||
'include nova'
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{
|
||||
:private_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-network]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
|
||||
it { should contain_sysctl__value('net.ipv4.ip_forward').with_value('1') }
|
||||
|
||||
describe 'when installing service' do
|
||||
|
||||
it { should contain_package('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-network]'
|
||||
) }
|
||||
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
default_params.merge(:enabled => true)
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
describe 'when enabled is set to false' do
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'when not installing service' do
|
||||
|
||||
let :params do
|
||||
default_params.merge(:install_service => false)
|
||||
end
|
||||
|
||||
it { should_not contain_package('nova-network') }
|
||||
it { should_not contain_service('nova-network') }
|
||||
|
||||
end
|
||||
|
||||
describe 'when not creating networks' do
|
||||
let :params do
|
||||
default_params.merge(:create_networks => false)
|
||||
end
|
||||
it { should_not contain_nova__manage__network('nova-vm-net') }
|
||||
it { should_not contain_nova__manage__floating('nova-vm-floating') }
|
||||
end
|
||||
|
||||
describe 'when creating networks' do
|
||||
it { should contain_nova__manage__network('nova-vm-net').with(
|
||||
:network => '10.0.0.0/32',
|
||||
:num_networks => '1'
|
||||
) }
|
||||
it { should_not contain__nova__manage__floating('nova-vm-floating') }
|
||||
describe 'when number of networks is set' do
|
||||
let :params do
|
||||
default_params.merge(:num_networks => '2')
|
||||
end
|
||||
it { should contain_nova__manage__network('nova-vm-net').with(
|
||||
:num_networks => '2'
|
||||
) }
|
||||
end
|
||||
describe 'when floating range is set' do
|
||||
let :params do
|
||||
default_params.merge(:floating_range => '10.0.0.0/30')
|
||||
end
|
||||
it { should contain_nova_config('floating_range').with_value('10.0.0.0/30') }
|
||||
it { should contain_nova__manage__floating('nova-vm-floating').with_network('10.0.0.0/30') }
|
||||
end
|
||||
end
|
||||
describe 'when configuring networks' do
|
||||
describe 'when configuring flatdhcpmanager' do
|
||||
let :params do
|
||||
default_params.merge(:network_manager => 'nova.network.manager.FlatDHCPManager')
|
||||
end
|
||||
it { should contain_class('nova::network::flatdhcp').with(
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => nil,
|
||||
:flat_interface => 'eth1',
|
||||
:flat_network_bridge => 'br100',
|
||||
:force_dhcp_release => true,
|
||||
:flat_injected => false,
|
||||
:dhcpbridge => '/usr/bin/nova-dhcpbridge',
|
||||
:dhcpbridge_flagfile => '/etc/nova/nova.conf'
|
||||
) }
|
||||
describe 'when overriding parameters' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{
|
||||
:network_manager => 'nova.network.manager.FlatDHCPManager',
|
||||
:public_interface => 'eth0',
|
||||
:config_overrides =>
|
||||
{
|
||||
'flat_network_bridge' => 'br400',
|
||||
'force_dhcp_release' => false,
|
||||
'flat_injected' => true,
|
||||
'dhcpbridge' => '/tmp/bridge',
|
||||
'dhcpbridge_flagfile' => '/tmp/file',
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
it { should contain_class('nova::network::flatdhcp').with(
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => 'eth0',
|
||||
:flat_interface => 'eth1',
|
||||
:flat_network_bridge => 'br400',
|
||||
#:force_dhcp_release => false,
|
||||
:flat_injected => true,
|
||||
:dhcpbridge => '/tmp/bridge',
|
||||
:dhcpbridge_flagfile => '/tmp/file'
|
||||
) }
|
||||
|
||||
end
|
||||
end
|
||||
describe 'when configuring flatmanager' do
|
||||
let :params do
|
||||
default_params.merge(:network_manager => 'nova.network.manager.FlatManager')
|
||||
end
|
||||
it { should contain_class('nova::network::flat').with(
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => nil,
|
||||
:flat_interface => 'eth1',
|
||||
:flat_network_bridge => 'br100'
|
||||
) }
|
||||
describe 'when overriding flat network params' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{
|
||||
:network_manager => 'nova.network.manager.FlatManager',
|
||||
:public_interface => 'eth0',
|
||||
:config_overrides => {'flat_network_bridge' => 'br400' }
|
||||
}
|
||||
)
|
||||
end
|
||||
it { should contain_class('nova::network::flat').with(
|
||||
:public_interface => 'eth0',
|
||||
:flat_network_bridge => 'br400'
|
||||
) }
|
||||
end
|
||||
end
|
||||
describe 'when configuring vlan' do
|
||||
let :params do
|
||||
default_params.merge(:network_manager => 'nova.network.manager.VlanManager')
|
||||
end
|
||||
it { should contain_class('nova::network::vlan').with(
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => nil,
|
||||
:vlan_interface => 'eth1'
|
||||
) }
|
||||
describe 'when overriding parameters' do
|
||||
let :params do
|
||||
default_params.merge(
|
||||
{
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::network::vlan' do
|
||||
|
||||
describe 'with only required parameters' do
|
||||
let :params do
|
||||
{
|
||||
:vlan_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.VlanManager') }
|
||||
it { should_not contain_nova_config('public_interface') }
|
||||
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
|
||||
it { should contain_nova_config('vlan_start').with_value('300') }
|
||||
it { should contain_nova_config('vlan_interface').with_value('eth1') }
|
||||
|
||||
end
|
||||
|
||||
describe 'with parameters overridden' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:vlan_interface => 'eth1',
|
||||
:fixed_range => '10.0.0.0/32',
|
||||
:public_interface => 'eth0',
|
||||
:vlan_start => '100'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_nova_config('network_manager').with_value('nova.network.manager.VlanManager') }
|
||||
it { should contain_nova_config('public_interface').with_value('eth0') }
|
||||
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
|
||||
it { should contain_nova_config('vlan_start').with_value('100') }
|
||||
it { should contain_nova_config('vlan_interface').with_value('eth1') }
|
||||
end
|
||||
end
|
|
@ -1 +1 @@
|
|||
../../../
|
||||
../../../../nova
|
Loading…
Reference in New Issue