Merge pull request #55 from bodepd/dev

Nova Refactor
This commit is contained in:
Dan Bode 2012-04-06 15:21:46 -07:00
commit d878f99cd1
28 changed files with 287 additions and 392 deletions

View File

@ -113,10 +113,7 @@ node compute {
node glance {
# set up glance server
class { 'glance::api':
swift_store_user => 'foo_user',
swift_store_key => 'foo_pass',
}
class { 'glance::api': }
class { 'glance::registry': }
@ -124,7 +121,9 @@ node glance {
node rabbitmq {
if($::operatingsystem == 'Ubuntu') {
class { 'rabbitmq::repo::apt': }
class { 'rabbitmq::repo::apt':
stage => 'nova_ppa',
}
}
class { 'nova::rabbitmq':
userid => $rabbit_user,
@ -167,7 +166,9 @@ node all {
# components on one node.
class { 'mysql::server': }
if($::operatingsystem == 'Ubuntu') {
class { 'rabbitmq::repo::apt': }
class { 'rabbitmq::repo::apt':
stage => 'nova_ppa',
}
}
class { 'nova::all':
db_password => 'password',

View File

@ -1,5 +1,6 @@
#
# TODO - this is currently hardcoded to be a xenserver
# TODO - this needs to be updated
class nova::all(
$db_password,
$db_name = 'nova',
@ -98,10 +99,7 @@ class nova::all(
}
# set up glance server
class { 'glance::api':
swift_store_user => 'foo_user',
swift_store_key => 'foo_pass',
}
class { 'glance::api': }
class { 'glance::registry': }

View File

@ -1,34 +1,21 @@
class nova::api($enabled=false) {
Exec['post-nova_config'] ~> Service['nova-api']
Exec['nova-db-sync'] ~> Service['nova-api']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
class nova::api(
$enabled=false
) inherits nova {
# 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,
require => [Package[$::nova::params::common_package_name], Nova_config['sql_connection']],
}
if($::nova::params::api_package_name != undef) {
package { 'nova-api':
name => $::nova::params::api_package_name,
ensure => present,
notify => Service['nova-api'],
before => Exec['initial-db-sync']
}
}
Package<| title == 'nova-api' |> -> Exec['initial-db-sync']
service { "nova-api":
name => $::nova::params::api_service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package[$::nova::params::common_package_name],
#subscribe => File["/etc/nova/nova.conf"]
nova::generic_service { 'api':
enabled => $enabled,
package_name => $::nova::params::api_package_name,
service_name => $::nova::params::api_service_name,
}
}

View File

@ -1,19 +1,11 @@
class nova::cert( $enabled=false ) {
class nova::cert(
$enabled=false
) inherits nova{
Exec['post-nova_config'] ~> Service['nova-cert']
Exec['nova-db-sync'] ~> Service['nova-cert']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
nova::generic_service { 'cert':
enabled => $enabled,
package_name => $::nova::params::cert_package_name,
service_name => $::nova::params::cert_service_name,
}
service { "nova-cert":
name => 'openstack-nova-cert',
ensure => $service_ensure,
enable => $enabled,
require => Package["openstack-nova"],
#subscribe => File["/etc/nova/nova.conf"]
}
}

9
manifests/client.pp Normal file
View File

@ -0,0 +1,9 @@
class nova::client(
) {
package { 'python-novaclient':
ensure => present,
}
}

View File

@ -2,30 +2,13 @@
# from the virtualization implementation of the compute node
class nova::compute(
$enabled = false,
) {
) inherits nova {
Exec['post-nova_config'] ~> Service['nova-compute']
Exec['nova-db-sync'] ~> Service['nova-compute']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
nova::generic_service { 'compute':
enabled => $enabled,
package_name => $::nova::params::compute_package_name,
service_name => $::nova::params::compute_service_name,
before => Exec['networking-refresh']
}
if($::nova::params::compute_package_name != undef) {
package { 'nova-compute':
name => $::nova::params::compute_package_name,
ensure => present,
notify => Service['nova-compute'],
}
}
service { "nova-compute":
name => $::nova::params::compute_service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package[$::nova::params::common_package_name],
before => Exec['networking-refresh'],
}
}

12
manifests/compute/kvm.pp Normal file
View File

@ -0,0 +1,12 @@
class nova::compute::kvm(
) {
nova_config {
'libvirt_type': value => 'kvm',
}
package { 'nova-compute-kvm':
ensure => present
}
}

View File

@ -14,7 +14,7 @@ class nova::compute::xenserver(
}
package { 'xenapi':
ensure => installed,
ensure => present,
provider => pip
}
}

View File

@ -5,6 +5,7 @@ class nova::controller(
$db_name = 'nova',
$db_user = 'nova',
$db_host = 'localhost',
$db_allowed_hosts = undef,
$rabbit_port = undef,
$rabbit_userid = undef,

View File

@ -11,8 +11,8 @@ class nova::db(
Mysql::Db[$dbname] -> Anchor<| title == "nova-start" |>
Mysql::Db[$dbname] ~> Exec<| title == 'initial-db-sync' |>
# now this requires storedconfigs
# TODO - worry about the security implications
# I am not sure if I want to use storeconfigs for this...
@@nova_config { 'database_url':
value => "mysql://${user}:${password}@${host}/${dbname}",
tag => $zone,
@ -25,7 +25,6 @@ class nova::db(
charset => 'latin1',
# I may want to inject some sql
require => Class['mysql::server'],
# notify => Exec["initial-db-sync"],
}
if $allowed_hosts {

View File

@ -0,0 +1,53 @@
#
# This class implements basic nova services.
# It is introduced to attempt to consolidate
# common code.
#
# It also allows users to specify ad-hoc services
# as needed
#
#
# This define creates a service resource with title nova-${name} and
# conditionally creates a package resource with title nova-${name}
#
define nova::generic_service(
$package_name,
$service_name,
$enabled = false,
) {
include nova::params
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
$nova_title = "nova-${name}"
# ensure that the service is only started after
# all nova config entries have been set
Exec['post-nova_config'] ~> Service[$nova_title]
# ensure that the service has only been started
# after the initial db sync
Exec['nova-db-sync'] ~> Service[$nova_title]
# I need to mark that ths package should be
# installed before nova_config
if($package_name) {
package { $nova_title:
name => $package_name,
ensure => present,
notify => Service[$nova_title],
}
}
service { $nova_title:
name => $service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package['nova-common'],
}
}

View File

@ -28,10 +28,14 @@ class nova(
$root_helper = $::nova::params::root_helper
) inherits nova::params {
# all nova_config resources should be applied
# after the nova common package
# before the file resource for nova.conf is managed
# and before the post config resource
Nova_config<| |> {
require +> Package[$::nova::params::common_package_name],
before +> File['/etc/nova/nova.conf'],
notify +> Exec['post-nova_config']
before +> File['/etc/nova/nova.conf'],
notify +> Exec['post-nova_config']
}
File {
@ -40,7 +44,8 @@ class nova(
group => 'nova',
}
# TODO - why is this required?
# TODO - see if these packages can be removed
# they should be handled as package deps by the OS
package { 'python':
ensure => present,
}
@ -63,7 +68,7 @@ class nova(
package { 'nova-common':
name =>$::nova::params::common_package_name,
ensure => present,
require => [Package["python-greenlet"], Anchor['nova-start']]
require => [Package["python-nova"], Anchor['nova-start']]
}
group { 'nova':
@ -77,6 +82,7 @@ class nova(
system => true,
require => Package['nova-common'],
}
file { $logdir:
ensure => directory,
mode => '0751',
@ -84,6 +90,9 @@ class nova(
file { '/etc/nova/nova.conf':
mode => '0640',
}
# I need to ensure that I better understand this resource
# this is potentially constantly resyncing a central DB
exec { "nova-db-sync":
command => "/usr/bin/nova-manage db sync",
refreshonly => "true",

11
manifests/keystone.pp Normal file
View File

@ -0,0 +1,11 @@
# configure to use keystone
class nova_keystone(
) {
nova_config {
'use_deprecated_auth': value => false;
'auth_strategy' : value => 'keystone';
'keystone_ec2_url' : value => 'http://10.42.0.6:5000/v2.0/ec2tokens';
}
}

View File

@ -1,28 +1,12 @@
class nova::network( $enabled=false ) {
class nova::network(
$enabled=false
) inherits nova {
Exec['post-nova_config'] ~> Service['nova-network']
Exec['nova-db-sync'] ~> Service['nova-network']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
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($::nova::params::network_package_name != undef) {
package { 'nova-network':
name => $::nova::params::network_package_name,
ensure => present,
notify => Service['nova-network'],
}
}
service { "nova-network":
name => $::nova::params::network_service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package[$::nova::params::common_package_name],
before => Exec['networking-refresh'],
#subscribe => File["/etc/nova/nova.conf"]
}
}

View File

@ -1,29 +1,11 @@
class nova::objectstore( $enabled=false ) {
class nova::objectstore(
$enabled=false
) inherits nova {
include nova::params
Exec['post-nova_config'] ~> Service['nova-objectstore']
Exec['nova-db-sync'] ~> Service['nova-objectstore']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
nova::generic_service { 'objectstore':
enabled => $enabled,
package_name => $::nova::params::objectstore_package_name,
service_name => $::nova::params::objectstore_service_name,
}
if($::nova::params::objectstore_package_name != undef) {
package { 'nova-objectstore':
name => $::nova::params::objectstore_package_name,
ensure => present,
notify => Service['nova-objectstore'],
}
}
service { "nova-objectstore":
name => $::nova::params::objectstore_service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package[$::nova::params::common_package_name],
#subscribe => File["/etc/nova/nova.conf"]
}
}

View File

@ -4,18 +4,24 @@ class nova::params {
case $::osfamily {
'RedHat': {
# package names
$api_package_name = false
$cert_package_name = false
$common_package_name = 'openstack-nova'
$api_package_name = undef
$compute_package_name = undef
$network_package_name = undef
$objectstore_package_name = undef
$scheduler_package_name = undef
$compute_package_name = false
$doc_package_name = 'openstack-nova-doc'
$network_package_name = false
$objectstore_package_name = false
$scheduler_package_name = false
$volume_package_name = false
# service names
$api_service_name = 'openstack-nova-api'
$cert_service_name = 'openstack-nova-cert'
$compute_service_name = 'openstack-nova-compute'
$network_service_name = 'openstack-nova-network'
$objectstore_service_name = 'openstack-nova-objectstore'
$scheduler_service_name = 'openstack-nova-scheduler'
$volume_service_name = 'openstack-nova-volume'
$libvirt_package_name = 'libvirt'
$libvirt_service_name = 'libvirtd'
$special_service_provider = 'init'
@ -23,18 +29,24 @@ class nova::params {
$root_helper = 'sudo nova-rootwrap'
}
'Debian': {
$common_package_name = 'nova-common'
# package names
$api_package_name = 'nova-api'
$cert_package_name = 'nova-cert'
$common_package_name = 'nova-common'
$compute_package_name = 'nova-compute'
$doc_package_name = 'nova-doc'
$network_package_name = 'nova-network'
$objectstore_package_name = 'nova-objectstore'
$scheduler_package_name = 'nova-scheduler'
$doc_package_name = 'nova-doc'
$volume_package_name = 'nova-volume'
# service names
$api_service_name = 'nova-api'
$cert_service_name = 'nova-cert'
$compute_service_name = 'nova-compute'
$network_service_name = 'nova-network'
$objectstore_service_name = 'nova-objectstore'
$scheduler_service_name = 'nova-scheduler'
$volume_service_name = 'nova-volume'
$libvirt_package_name = 'libvirt-bin'
$libvirt_service_name = 'libvirt-bin'
# some of the services need to be started form the special upstart provider

View File

@ -6,26 +6,19 @@ class nova::rabbitmq(
$userid='guest',
$password='guest',
$port='5672',
$virtual_host='/',
$install_repo = false
$virtual_host='/'
) {
# only configure nova after the queue is up
Class['rabbitmq::service'] -> Anchor<| title == 'nova-start' |>
# work around hostname bug, LP #653405
# TODO - see if this is still required
host { $hostname:
ip => $ipaddress,
host_aliases => $fqdn,
}
if $install_repo {
# this is debian specific
class { 'rabbitmq::repo::apt':
pin => 900,
before => Class['rabbitmq::server']
}
}
if $userid == 'guest' {
$delete_guest_user = false
} else {

View File

@ -1,29 +1,11 @@
class nova::scheduler( $enabled = false) {
class nova::scheduler(
$enabled = false
) inherits nova {
include nova::params
Exec['post-nova_config'] ~> Service['nova-scheduler']
Exec['nova-db-sync'] -> Service['nova-scheduler']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
nova::generic_service { 'scheduler':
enabled => $enabled,
package_name => $::nova::params::scheduler_package_name,
service_name => $::nova::params::scheduler_service_name,
}
if($::nova::params::scheduler_package_name != undef) {
package { 'nova-scheduler':
name => $::nova::params::scheduler_package_name,
ensure => present,
notify => Service['nova-scheduler'],
}
}
service { "nova-scheduler":
name => $::nova::params::scheduler_service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package[$::nova::params::common_package_name],
#subscribe => File["/etc/nova/nova.conf"]
}
}

View File

@ -1,85 +0,0 @@
#
# TODO - this is currently hardcoded to be a xenserver
class nova::ubuntu::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,
$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 = undef,
$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":
api_server => $ipaddress,
enabled => true,
}
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,
}
class { "nova::objectstore": enabled => true }
class { "nova::scheduler": enabled => true }
class { 'nova::db':
# pass in db config as params
password => $db_password,
dbname => $db_name,
user => $db_user,
host => $db_host,
}
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],
}
}

View File

@ -1,71 +0,0 @@
#
# TODO - this is currently hardcoded to be a xenserver
class nova::ubuntu::cc (
$db_password,
$db_name = 'nova',
$db_user = 'nova',
$db_host = 'localhost',
$db_allowed_hosts = undef,
$flat_network_bridge = 'br100',
$flat_network_bridge_ip = '11.0.0.1',
$flat_network_bridge_netmask = '255.255.255.0',
$image_service = 'nova.image.local.LocalImageService',
$glance_api_servers = 'localhost:9292',
$nova_network = '11.0.0.0/24',
$available_ips = '256',
$admin_user = 'novaadmin',
$project_name = 'nova'
) {
class { 'nova::rabbitmq':
port => $rabbitmq_port,
userid => $rabbitmq_userid,
password => $rabbitmq_password,
virtual_host => $rabbitmq_virtual_host,
}
class { "nova":
logdir => $logdir,
verbose => $verbose,
sql_connection => "mysql://${db_user}:${db_password}@${db_host}/${db_name}",
image_service => $image_service,
glance_api_servers => $glance_api_servers,
}
class { "nova::api": enabled => true }
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,
}
class { "nova::objectstore": enabled => true }
class { "nova::scheduler": enabled => true }
class { 'nova::db':
# pass in db config as params
password => $db_password,
dbname => $db_name,
user => $db_user,
host => $db_host,
allowed_hosts => $db_allowed_hosts,
}
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],
}
}

View File

@ -1,43 +0,0 @@
# compute.pp
class nova::ubuntu::compute (
$api_server,
$rabbit_host,
$db_host,
# default to local image service.
$image_service = undef,
$glance_api_servers = undef,
$flat_network_bridge,
$flat_network_bridge_ip,
$flat_network_bridge_netmask,
$rabbit_port = undef,
$rabbit_userid = undef,
$rabbit_virtual_host = undef,
$db_user = 'nova',
$db_password = 'nova',
$db_name = 'nova',
$enabled = 'false'
) {
class { "nova":
logdir => $logdir,
verbose => $verbose,
image_service => $image_service,
rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port,
rabbit_userid => $rabbit_userid,
rabbit_virtual_host => $rabbit_virtual_host,
sql_connection => "mysql://${db_user}:${db_password}@${db_host}/${db_name}",
glance_api_servers => $glance_api_servers,
}
nova::network::bridge { $flat_network_bridge:
ip => $flat_network_bridge_ip,
netmask => $flat_network_bridge_netmask,
}
class { "nova::compute":
api_server => $api_server,
enabled => $enabled,
}
}

10
manifests/vncproxy.pp Normal file
View File

@ -0,0 +1,10 @@
class nova::vncproxy(
) {
Package['nova-vncproxy'] -> Exec<| title == 'initial-db-sync' |>
package { 'nova-vncproxy':
ensure => present,
}
}

View File

@ -1,29 +1,21 @@
class nova::volume( $enabled=false ) {
class nova::volume(
$enabled=false
) inherits nova {
Exec['post-nova_config'] ~> Service['nova-volume']
Exec['nova-db-sync'] ~> Service['nova-volume']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
exec {volumes:
exec { 'volumes':
command => 'dd if=/dev/zero of=/tmp/nova-volumes.img bs=1M seek=20k count=0 && /sbin/vgcreate nova-volumes `/sbin/losetup --show -f /tmp/nova-volumes.img`',
onlyif => 'test ! -e /tmp/nova-volumes.img',
path => ["/usr/bin", "/bin", "/usr/local/bin"],
before => Service['nova-volume'],
}
service { "nova-volume":
name => 'openstack-nova-volume',
ensure => $service_ensure,
enable => $enabled,
require => Package["openstack-nova"],
#subscribe => File["/etc/nova/nova.conf"]
ova::generic_service { 'volume':
enabled => $enabled,
package_name => $::nova::params::volume_package_name,
service_name => $::nova::params::volume_service_name,
}
# TODO is this fedora specific?
service {'tgtd':
ensure => $service_ensure,
enable => $enabled,

View File

@ -11,19 +11,24 @@ describe 'nova::cert' do
{ :osfamily => 'Debian' }
end
it { should contain_service('nova-cert').with(
'name' => 'openstack-nova-cert',
'name' => 'nova-cert',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-cert').with(
'name' => 'nova-cert',
'ensure' => 'present',
'notify' => 'Service[nova-cert]'
)}
describe 'with enabled as true' do
let :params do
{:enabled => true}
end
it { should contain_service('nova-cert').with(
'name' => 'openstack-nova-cert',
'ensure' => 'running',
'enable' => true
)}
it { should contain_service('nova-cert').with(
'name' => 'nova-cert',
'ensure' => 'running',
'enable' => true
)}
end
end
describe 'on rhel' do
@ -35,6 +40,6 @@ describe 'nova::cert' do
'ensure' => 'stopped',
'enable' => false
)}
it { should_not contain_package('nova-network') }
it { should_not contain_package('nova-cert') }
end
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe 'nova::client' do
it { should contain_package('python-novaclient').with_ensure('present') }
end

View File

@ -1,6 +1,7 @@
require 'spec_helper'
describe 'nova' do
let :facts do
{ :osfamily => 'Debian' }
end

View File

@ -0,0 +1,28 @@
require 'spec_helper'
describe 'nova::vncproxy' do
let :pre_condition do
'include nova'
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it { should contain_package('nova-vncproxy').with(
'ensure' => 'present',
'before' => nil
)}
describe 'when deployed on the API server' do
let :pre_condition do
'include nova::api'
end
it { should contain_package('nova-vncproxy').with(
'ensure' => 'present',
'before' => 'Exec[initial-db-sync]'
)}
end
end
end

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'nova::volume' do
let :pre_condition do
'include nova'
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it { should contain_service('nova-volume').with(
'name' => 'nova-volume',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-volume').with(
'name' => 'nova-volume',
'ensure' => 'present',
'notify' => 'Service[nova-volume]'
)}
describe 'with enabled as true' do
let :params do
{:enabled => true}
end
it { should contain_service('nova-volume').with(
'name' => 'nova-volume',
'ensure' => 'running',
'enable' => true
)}
end
end
describe 'on rhel' do
let :facts do
{ :osfamily => 'RedHat' }
end
it { should contain_service('nova-volume').with(
'name' => 'openstack-nova-volume',
'ensure' => 'stopped',
'enable' => false
)}
it { should_not contain_package('nova-volume') }
end
end