Browse Source

checking Nova integration work 5/26/11

changes/27/26227/1
Dan Bode 10 years ago
parent
commit
e2eaf1313d
  1. 33
      nova/lib/puppet/provider/nova_config/parsed.rb
  2. 24
      nova/lib/puppet/type/nova_config.rb
  3. 8
      nova/manifests/all.pp
  4. 19
      nova/manifests/compute.pp
  5. 25
      nova/manifests/compute/xenserver.pp
  6. 18
      nova/manifests/db.pp
  7. 14
      nova/manifests/init.pp
  8. 0
      nova/manifests/messagebus.pp
  9. 0
      nova/manifests/project.pp
  10. 7
      nova/tests/compute.pp
  11. 9
      nova/tests/db.pp
  12. 9
      nova/tests/nova_config.pp
  13. 17
      nova/tests/openstack-all.pp

33
nova/lib/puppet/provider/nova_config/parsed.rb

@ -0,0 +1,33 @@
require 'puppet/provider/parsedfile'
novaconf = "/etc/nova/nova.conf"
Puppet::Type.type(:nova_config).provide(
:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => novaconf,
:filetype => :flat
) do
confine :exists => novaconf
text_line :comment, :match => /^\s*#/;
text_line :blank, :match => /^\s*$/;
record_line :parsed,
:fields => %w{line},
:match => /--(.*)/ ,
:post_parse => proc { |hash|
Puppet.debug("nova config line:#{hash[:line]} has been parsed")
if hash[:line] =~ /(\S+)\s*=\s*(\S+)/
hash[:name]=$1
hash[:value]=$2
else
raise Puppet::Error, "Invalid line: #{hash[:line]}"
end
}
def self.to_line(hash)
"--#{hash[:name]}=#{hash[:value]}"
end
end

24
nova/lib/puppet/type/nova_config.rb

@ -0,0 +1,24 @@
Puppet::Type.newtype(:nova_config) do
ensurable
newparam(:name, :namevar => true) do
newvalues(/\S+/)
end
newproperty(:value) do
newvalues(/\S+/)
end
newproperty(:target) do
desc "Path to our nova config file"
defaultto {
if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
@resource.class.defaultprovider.default_target
else
nil
end
}
end
end

8
nova/manifests/all.pp

@ -2,6 +2,7 @@ class nova::all(
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image = 'false',
$sql_connection,
$network_manager,
$image_service,
@ -9,7 +10,6 @@ class nova::all(
$nodaemon = 'undef',
$flat_network_bridge = 'xenbr0',
$connection_type = 'xenapi',
$xenapi_inject_image = 'false',
$rescue_timeout = '86400',
$allow_admin_api = 'true',
$xenapi_inject_image = 'false',
@ -43,4 +43,10 @@ class nova::all(
class { "nova::network": isServiceEnabled => false }
class { "nova::objectstore": isServiceEnabled => false }
class { "nova::scheduler": isServiceEnabled => false }
class { 'nova::db':
password => 'password',
name => 'nova',
user => 'nova',
host => 'localhost',
}
}

19
nova/manifests/compute.pp

@ -1,13 +1,24 @@
class nova::compute( $isServiceEnabled=false ) inherits nova {
class nova::compute(
$enabled = false,
$nova_config = '/etc/nova/nova.conf'
) {
Nova_config<| |>~>Service['nova_compute']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
package { "nova-compute":
ensure => present,
require => Package["python-greenlet"]
require => Class['nova']
}
service { "nova-compute":
ensure => $isServiceEnabled,
ensure => $service_ensure,
enable => $enabled,
require => Package["nova-compute"],
subscribe => File["/etc/nova/nova.conf"]
}
}

25
nova/manifests/compute/xenserver.pp

@ -0,0 +1,25 @@
class nova::compute::xenserver(
$enabled = false
$xenapi_connection_url,
$xenapi_connection_username,
$xenapi_connection_password,
$xenapi_inject_image=false,
) inherits nova {
class { 'nova::compute':
enabled => $enabled,
}
nova_config { 'xenapi_connection_url':
value => $xenapi_connection_url,
}
nova_config { 'xenapi_connection_username':
value => $xenapi_connection_username,
}
nova_config { 'xenapi_connection_password':
value => $xenapi_connection_password,
}
nova_config { 'xenapi_inject_image':
value => $xenapi_inject_image,
}
}

18
nova/manifests/db.pp

@ -1,15 +1,15 @@
class nova::db(
$db_pw,
$db_user = 'nova'
$db_name = 'nova',
$db_host => 'localhost'
$password,
$name = 'nova',
$user = 'nova',
$host = 'localhost'
) {
mysql::db { $db_name:
db_user => $db_user,
db_pw => $db_pw,
db_hostname => $db_hostname,
mysql::db { $name:
user => $user,
password => $password,
host => $host,
# I may want to inject some sql
# sql='',
require => Class['mysql::server']
require => Class['mysql::server'],
}
}

14
nova/manifests/init.pp

@ -1,4 +1,10 @@
class nova( $novaConfHash ) {
class nova(
$verbose = false,
$nodaemon = false,
sql_connection,
# just for network?
network_manager
) {
class { 'puppet': }
class {
@ -18,9 +24,5 @@ class nova( $novaConfHash ) {
require => Package["python-greenlet"]
}
file { "/etc/nova/nova.conf":
ensure => present,
content => template("nova/nova.conf.erb"),
require => Package["nova-common"]
}
Nova_config<| require +> Package["nova-common"] |>
}

0
nova/manifests/messagebus.pp

0
nova/manifests/project.pp

7
nova/tests/openstack-compute.pp → nova/tests/compute.pp

@ -23,3 +23,10 @@ class nova-compute-test {
class { "nova::compute": isServiceEnabled => false }
}
include nova-compute-test
class { 'nova::compute':
}
class { 'nova': }

9
nova/tests/db.pp

@ -0,0 +1,9 @@
class { 'mysql::server':
root_password => 'password'
}
class { 'nova::db':
password => 'password',
name => 'nova',
user => 'nova',
host => 'localhost',
}

9
nova/tests/nova_config.pp

@ -0,0 +1,9 @@
resources { 'nova_config':
purge => true
}
nova_config { ['verbose', 'nodaemomize']:
value => 'true',
}
nova_config { 'xenapi_connection_username':
value => 'rootty',
}

17
nova/tests/openstack-all.pp

@ -9,6 +9,9 @@ class { 'apt':
class { 'nova::repo':
stage => 'repo-setup',
}
class { 'mysql::server':
root_password => 'password'
}
class { 'nova::all':
verbose => 'undef',
nodaemon => 'undef',
@ -28,17 +31,3 @@ class { 'nova::all':
ipv6_backend => 'account_identifier',
}
# this will probably be on its own machine
class mysql::server {
mysql_root_pw => 'foo',
}
mysql::db {
db_user,
db_pw,
db_charset = 'utf8',
host = 'localhost',
grant='all',
sql=''
) {
}
Loading…
Cancel
Save