re-factored code to make it more generic.

This commit is contained in:
Dan Bode
2011-05-31 17:57:19 -07:00
parent 52e9f93924
commit a855c609e8
15 changed files with 393 additions and 54 deletions

View File

@@ -1,6 +0,0 @@
# unzip swig screen parted curl euca2ools - extra packages
class extrapackages {
package { ['unzip', 'swig', 'screen', 'parted', 'curl', 'euca2ools']:
ensure => present
}
}

View File

@@ -1,16 +1,16 @@
#
# TODO - this is currently hardcoded to be a xenserver
class nova::all (
class nova::all(
$logdir,
$verbose,
$sql_connection,
# $sql_connection='mysql://root:<password>@127.0.0.1/nova',
$network_manager,
$image_service,
$flat_network_bridge = 'xenbr0',
$glance_host,
$glance_port,
$allow_admin_api = 'true',
$rabbit_host,
$rabbit_host=$::ipaddress,
$rabbit_password,
$rabbit_port,
$rabbit_userid,
@@ -28,10 +28,13 @@ class nova::all (
$quota_max_injected_file_content_bytes,
$quota_max_injected_file_path_bytes,
$host,
$compute_type = 'libvirt',
# do kvm and libvirt have extra config options?
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image = 'false'
$db_host =
) {
class { "nova":
@@ -64,7 +67,8 @@ class nova::all (
}
class { "nova::api": enabled => false }
class { "nova::compute::xenserver":
class { "nova::compute":
compute_type => $compute_type,
host => $host,
xenapi_connection_url => $xenapi_connection_url,
xenapi_connection_username => $xenapi_connection_username,
@@ -76,6 +80,7 @@ class nova::all (
class { "nova::objectstore": enabled => false }
class { "nova::scheduler": enabled => false }
class { 'nova::db':
# pass in db config as params
password => 'password',
name => 'nova',
user => 'nova',

View File

@@ -0,0 +1,89 @@
#
# TODO - this is currently hardcoded to be a xenserver
class nova::all(
$logdir,
$verbose,
$sql_connection='mysql://root:<password>@127.0.0.1/nova',
$network_manager,
$image_service,
$flat_network_bridge = 'xenbr0',
$glance_host,
$glance_port,
$allow_admin_api = 'true',
$rabbit_host=$::ipaddress,
$rabbit_password,
$rabbit_port,
$rabbit_userid,
$rabbit_virtual_host,
$state_path,
$lock_path,
$service_down_time,
$quota_instances,
$quota_cores,
$quota_volumes,
$quota_gigabytes,
$quota_floating_ips,
$quota_metadata_items,
$quota_max_injected_files,
$quota_max_injected_file_content_bytes,
$quota_max_injected_file_path_bytes,
$host,
$compute_type = 'libvirt',
# do kvm and libvirt have extra config options?
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image = 'false'
$db_host =
) {
class { "nova":
logdir => $logdir,
verbose => $verbose,
sql_connection => $sql_connection,
network_manager => $network_manager,
image_service => $image_service,
flat_network_bridge => $flat_network_bridge,
glance_host => $glance_host,
glance_port => $glance_port,
allow_admin_api => $allow_admin_api,
rabbit_host => $rabbit_host,
rabbit_password => $rabbit_password,
rabbit_port => $rabbit_port,
rabbit_userid => $rabbit_userid,
rabbit_virtual_host => $rabbit_virtual_host,
state_path => $state_path,
lock_path => $lock_path,
service_down_time => $service_down_time,
quota_instances => $quota_instances,
quota_cores => $quota_cores,
quota_volumes => $quota_volumes,
quota_gigabytes => $quota_gigabytes,
quota_floating_ips => $quota_floating_ips,
quota_metadata_items => $quota_metadata_items,
quota_max_injected_files => $quota_max_injected_files,
quota_max_injected_file_content_bytes => $quota_max_injected_file_content_bytes,
quota_max_injected_file_path_bytes => $quota_max_injected_file_path_bytes,
}
class { "nova::api": enabled => false }
class { "nova::compute":
compute_type => $compute_type,
host => $host,
xenapi_connection_url => $xenapi_connection_url,
xenapi_connection_username => $xenapi_connection_username,
xenapi_connection_password => $xenapi_connection_password,
xenapi_inject_image => $xenapi_inject_image,
enabled => false
}
class { "nova::network": enabled => false }
class { "nova::objectstore": enabled => false }
class { "nova::scheduler": enabled => false }
class { 'nova::db':
# pass in db config as params
password => 'password',
name => 'nova',
user => 'nova',
host => 'localhost',
}
}

View File

@@ -1,20 +1,26 @@
# this class should probably never be declared except
# from the virtualization implementation of the compute node
class nova::compute(
$host,
$compute_type = 'xenserver',
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image=false,
$enabled = false
# $type,
# $hash,
) {
# if $type == 'xenserver' {
# class { 'nova::compute::xenserver':
# xenapi_connection_url => $hash['xen_connection_url'],
# $xenapi_connection_url,
# $xenapi_connection_username,
# $xenapi_connection_password,
# $xenapi_inject_image=false,
# }
# }
if $compute_type == 'xenserver' {
class { 'nova::compute::xenserver':
xenapi_connection_url => $xenapi_connection_url,
xenapi_connection_username => $xenapi_connection_username,
xenapi_connection_password => $xenapi_connection_password,
xenapi_inject_image => $xenapi_inject_image,
host => $host,
}
} else {
fail("Unsupported compute type: ${compute_type}")
}
Nova_config<| |>~>Service['nova-compute']

View File

@@ -1,15 +1,11 @@
class nova::compute::xenserver(
# TODO - what does this host do?
$host,
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image=false,
$enabled = false
) inherits nova {
class { 'nova::compute':
enabled => $enabled,
}
$xenapi_inject_image=false
) {
nova_config {
'xenapi_connection_url': value => $xenapi_connection_url;

View File

@@ -2,14 +2,22 @@ class nova::db(
$password,
$name = 'nova',
$user = 'nova',
$host = 'localhost'
$host = '127.0.0.1'
$zone = 'localzone'
) {
# now this requires storedconfigs
# TODO - worry about the security implications
@@nova_config { 'database_url':
value => "mysql://${user}:${password}@${host}/${name}"
tag => $zone,
}
mysql::db { $name:
user => $user,
password => $password,
host => $host,
# I may want to inject some sql
# sql='',
require => Class['mysql::server'],
}
}

View File

@@ -1,9 +1,8 @@
class nova(
$verbose = false,
$nodaemon = false,
$logdir = '/var/log/nova',
$sql_connection,
$network_manager,
# this is how to query all resources from our clutser
$nova_cluster_id='localcluster',
$sql_connection = false,
$network_manager='nova.network.manager.FlatManager',
$image_service,
# is flat_network_bridge valid if network_manager is not FlatManager?
$flat_network_bridge,
@@ -16,8 +15,6 @@ class nova(
$rabbit_userid,
$rabbit_virtual_host,
# Following may need to be broken out to different nova services
$state_path,
$lock_path,
$service_down_time,
$quota_instances,
$quota_cores,
@@ -27,32 +24,42 @@ class nova(
$quota_metadata_items,
$quota_max_injected_files,
$quota_max_injected_file_content_bytes,
$quota_max_injected_file_path_bytes
$quota_max_injected_file_path_bytes,
$logdir = '/var/log/nova',
$state_path = '/var/lib/nova',
$lock_path = '/var/lock/nova',
$verbose = false,
$nodaemon = false
) {
class { 'puppet': }
class {
[
'bzr',
'git',
'gcc',
'extrapackages',
# I may need to move python-mysqldb to elsewhere if it depends on mysql
'python',
]:
}
# TODO - why is this required?
package { "python-greenlet": ensure => present }
package { ["nova-common", "nova-doc"]:
class { 'nova::utilities': }
package { ["python-nova", "nova-common", "nova-doc"]:
ensure => present,
require => Package["python-greenlet"]
}
file { $logdir:
ensure => directory,
mode => '751',
owner => 'nova',
group => 'root',
require => Package['nova-common'],
}
# query out the config for our db connection
if $sql_connection {
nova_config { 'sql_connection': value => $sql_connection }
} else{
Nova_config<<| tag == $cluster_id and value == 'sql_connection' |>>
}
nova_config {
'verbose': value => $verbose;
'nodaemon': value => $nodaemon;
'logdir': value => $logdir;
'sql_connection': value => $sql_connection;
'network_manager': value => $network_manager;
'image_service': value => $image_service;
# is flat_network_bridge valid if network_manager is not FlatManager?

View File

@@ -0,0 +1,114 @@
#
# TODO - this is currently hardcoded to be a xenserver
#
# this will be specific to how rackspace composes
# the various backends for openstack
#
class nova::rackspace::all(
$logdir,
$verbose,
$sql_connection,
$network_manager,
$image_service,
$flat_network_bridge = 'xenbr0',
$glance_host,
$glance_port,
$allow_admin_api = 'true',
$rabbit_host,
$rabbit_password,
$rabbit_port,
$rabbit_userid,
$rabbit_virtual_host,
$state_path,
$lock_path,
$service_down_time,
$quota_instances,
$quota_cores,
$quota_volumes,
$quota_gigabytes,
$quota_floating_ips,
$quota_metadata_items,
$quota_max_injected_files,
$quota_max_injected_file_content_bytes,
$quota_max_injected_file_path_bytes,
$host,
$compute_type = 'xenserver',
# do kvm and libvirt have extra config options?
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image = 'false'
) {
# this is rackspace specific stuff for setting up the repos
# most of this code may go away after they are finished
# developing
stage { 'repo-setup':
before => Stage['main'],
}
class { 'apt':
disable_keys => true,
#always_apt_update => true,
stage => 'repo-setup',
}
class { 'nova::rackspace::repo':
stage => 'repo-setup',
}
class { 'mysql::server':
root_password => 'password'
}
class { 'nova::rackspace::dev':}
class { "nova":
logdir => $logdir,
verbose => $verbose,
sql_connection => $sql_connection,
network_manager => $network_manager,
image_service => $image_service,
flat_network_bridge => $flat_network_bridge,
glance_host => $glance_host,
glance_port => $glance_port,
allow_admin_api => $allow_admin_api,
rabbit_host => $rabbit_host,
rabbit_password => $rabbit_password,
rabbit_port => $rabbit_port,
rabbit_userid => $rabbit_userid,
rabbit_virtual_host => $rabbit_virtual_host,
state_path => $state_path,
lock_path => $lock_path,
service_down_time => $service_down_time,
quota_instances => $quota_instances,
quota_cores => $quota_cores,
quota_volumes => $quota_volumes,
quota_gigabytes => $quota_gigabytes,
quota_floating_ips => $quota_floating_ips,
quota_metadata_items => $quota_metadata_items,
quota_max_injected_files => $quota_max_injected_files,
quota_max_injected_file_content_bytes => $quota_max_injected_file_content_bytes,
quota_max_injected_file_path_bytes => $quota_max_injected_file_path_bytes,
}
class { "nova::api": enabled => false }
class { "nova::compute":
compute_type => $compute_type,
host => $host,
xenapi_connection_url => $xenapi_connection_url,
xenapi_connection_username => $xenapi_connection_username,
xenapi_connection_password => $xenapi_connection_password,
xenapi_inject_image => $xenapi_inject_image,
enabled => false
}
class { "nova::network": enabled => false }
class { "nova::objectstore": enabled => false }
class { "nova::scheduler": enabled => false }
class { 'nova::db':
# pass in db config as params
password => 'password',
name => 'nova',
user => 'nova',
host => 'localhost',
}
}

View File

@@ -0,0 +1,20 @@
# all of the openstack specific stuff is being moved to herej
class nova::rackspace::dev() {
class { 'puppet': }
class {
[
'bzr',
'git',
'gcc',
'gcc::swig',
# I may need to move python-mysqldb to elsewhere if it depends on mysql
# python-nova pulls in all of the deps mentioned here
'python',
]:
}
package { 'swig':
ensure => installed,
}
}

View File

@@ -1,4 +1,4 @@
class nova::repo {
class nova::rackspace::repo {
# this should not be hard-coded
# eventually this will be on a real debian repo
apt::source { 'openstack':

View File

@@ -0,0 +1,6 @@
# unzip swig screen parted curl euca2ools - extra packages
class nova::utilities {
package { ['unzip', 'screen', 'parted', 'curl', 'euca2ools']:
ensure => present
}
}

View File

@@ -1,4 +1,7 @@
Nova_config { target => '/tmp/nova.config' }
resources { 'nova_config':
purge => true,
}
stage { 'repo-setup':
before => Stage['main'],
@@ -47,4 +50,3 @@ class { 'nova::all':
xenapi_connection_password => 'password',
xenapi_inject_image => 'false',
}

View File

@@ -0,0 +1,54 @@
Nova_config { target => '/tmp/nova.config' }
resources { 'nova_config':
purge => true,
}
stage { 'repo-setup':
before => Stage['main'],
}
class { 'apt':
disable_keys => true,
#always_apt_update => true,
stage => 'repo-setup',
}
class { 'nova::repo':
stage => 'repo-setup',
}
class { 'mysql::server':
root_password => 'password'
}
class { 'nova::all':
#dhcpbridge_flagfile=/etc/nova/nova.conf
#dhcpbridge=/usr/bin/nova-dhcpbridge
#verbose => true,
#s3_host=192.168.25.30
#rabbit_host=192.168.25.30
#cc_host=192.168.25.30
#ec2_url=http://192.168.25.30:8773/services/Cloud
#fixed_range=10.0.0.0/32
#network_size=255
#FAKE_subdomain=ec2
#routing_source_ip=192.168.25.30
#verbose
#sql_connection=mysql://root:pass@192.168.25.30/nova
#network_manager=nova.network.manager.FlatManager
verbose => 'true',
logdir => '/var/log/nova',
sql_connection => 'mysql://nova:nova@127.0.0.1/nova',
network_manager => 'nova.network.manager.FlatManager',
image_service => 'nova.image.glance.GlanceImageService',
flat_network_bridge => 'xenbr0',
glance_host => 'glance_ip_address',
glance_port => '9292',
allow_admin_api => 'true',
rabbit_host => 'rabbit_ip_address',
rabbit_password => 'rabbitpassword',
rabbit_port => '5672',
rabbit_userid => 'rabbit_user',
rabbit_virtual_host => '/',
state_path => 'var/lib/nova',
lock_path => 'var/lock/nova',
service_down_time => '180000000',
host => $ipaddress,
}

View File

@@ -0,0 +1,38 @@
Nova_config { target => '/tmp/nova.config' }
resources { 'nova_config':
purge => true,
}
class { 'nova::rackspace::all':
verbose => 'true',
logdir => '/var/log/nova',
sql_connection => 'mysql://root:<password>@127.0.0.1/nova',
network_manager => 'nova.network.manager.FlatManager',
image_service => 'nova.image.glance.GlanceImageService',
flat_network_bridge => 'xenbr0',
glance_host => 'glance_ip_address',
glance_port => '9292',
allow_admin_api => 'true',
rabbit_host => 'rabbit_ip_address',
rabbit_password => 'rabbitpassword',
rabbit_port => '5672',
rabbit_userid => 'rabbit_user',
rabbit_virtual_host => '/',
state_path => 'var/lib/nova',
lock_path => 'var/lock/nova',
service_down_time => '180000000',
quota_instances => '1000000',
quota_cores => '1000000',
quota_volumes => '1000000',
quota_gigabytes => '1000000',
quota_floating_ips => '1000000',
quota_metadata_items => '1000000',
quota_max_injected_files => '1000000',
quota_max_injected_file_content_bytes => '1000000',
quota_max_injected_file_path_bytes => '1000000',
host => $ipaddress,
xenapi_connection_url => 'https://<XenServer_IP>',
xenapi_connection_username => 'root',
xenapi_connection_password => 'password',
xenapi_inject_image => 'false',
}

View File

@@ -31,7 +31,7 @@ class python {
]:
ensure => present,
}
package { ['pep8', 'xenapi', 'python-novaclient']:
package { ['pep8', 'xenapi']:
provider => 'pip',
ensure => present,
require => Package['python-pip'],