Merge pull request #74 from puppetlabs/master

back port latest folsom changes to folsom branch
This commit is contained in:
Dan Bode 2013-03-19 10:32:07 -07:00
commit 1a5b7504a5
17 changed files with 217 additions and 165 deletions

View File

@ -6,6 +6,5 @@ fixtures:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"rabbitmq": "git://github.com/puppetlabs/puppetlabs-rabbitmq.git" "rabbitmq": "git://github.com/puppetlabs/puppetlabs-rabbitmq.git"
'inifile': 'git://github.com/cprice-puppet/puppetlabs-inifile' 'inifile': 'git://github.com/cprice-puppet/puppetlabs-inifile'
"create_resources": 'git://github.com/puppetlabs/puppetlabs-create_resources'
symlinks: symlinks:
"glance": "#{source_dir}" "glance": "#{source_dir}"

View File

@ -1,5 +0,0 @@
source :rubygems
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'

View File

@ -1,18 +1,33 @@
language: ruby language: ruby
bundler_args: --without development
before_script:
- echo $PUPPET_GEM_VERSION | grep '2.6' && git clone git://github.com/puppetlabs/puppetlabs-create_resources.git spec/fixtures/modules/create_resources || true
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
rvm: rvm:
- 1.8.7 - 1.8.7
before_script: - 1.9.3
after_script: - ruby-head
script: "rake spec"
branches: branches:
only: only:
- master - master
- folsom - folsom
- essex - essex
env: env:
- PUPPET_VERSION=2.7.13 - PUPPET_GEM_VERSION="~> 2.6"
- PUPPET_VERSION=2.7.6 - PUPPET_GEM_VERSION="~> 2.7"
- PUPPET_VERSION=2.6.9 - PUPPET_GEM_VERSION="~> 3.0"
- PUPPET_GEM_VERSION="~> 3.1"
matrix:
allow_failures:
- rvm: ruby-head
exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 2.7"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.6"
- rvm: ruby-head
env: PUPPET_GEM_VERSION="~> 2.6"
notifications: notifications:
email: false email: false
gemfile: .gemfile

View File

@ -1,3 +1,10 @@
* 2013-03-19 1.1.0
- update travis matrix (add ruby 1.9, puppet 3.0)
- implement provider changes for purging
- refactor of glance_image native types
- remove /v1 from endpoints
- allow specifying https for public endpoint
- parse credentials out of apt-paste.conf
* 2012-11-02 1.0.0 * 2012-11-02 1.0.0
- Add travisci support to repo - Add travisci support to repo
- Remove essex support - Remove essex support

13
Gemfile Normal file
View File

@ -0,0 +1,13 @@
source :rubygems
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

View File

@ -1,5 +1,5 @@
name 'puppetlabs-glance' name 'puppetlabs-glance'
version '1.0.0' version '1.1.0'
source 'git://github.com/puppetlabs/puppetlabs-glance' source 'git://github.com/puppetlabs/puppetlabs-glance'
author 'Puppet Labs' author 'Puppet Labs'
license 'Apache' license 'Apache'
@ -8,6 +8,6 @@ description 'Openstack Glance module for folsom. Tested on Ubuntu Precise and RH
project_page 'http://github.com/puppetlabs/puppetlabs-glance' project_page 'http://github.com/puppetlabs/puppetlabs-glance'
dependency 'cprice404/inifile', '>= 0.9.0' dependency 'cprice404/inifile', '>= 0.9.0'
dependency 'puppetlabs/keystone', '>= 1.0.1' dependency 'puppetlabs/keystone', '>= 1.1.0'
dependency 'puppetlabs/mysql', '>= 0.5.0' dependency 'puppetlabs/mysql', '>= 0.5.0'
dependency 'puppetlabs/stdlib', '>= 2.4.0' dependency 'puppetlabs/stdlib', '>= 2.4.0'

View File

@ -1,80 +0,0 @@
# PuppetLabs Glance module
This module provides a set of manifests that can be used to install and
configure glance.
It is currently targettting the folsom release of OpenStack.
Use the essex branch for essex support.
## Platforms
* Ubuntu 11.04 (Natty)
* Ubuntu 11.10 (Oneiric)
* Ubuntu 12.04 (Precise)
## configurations
Glance is configured with the following classes:
#configures glance::api service
class { 'glance::api':
verbose => $verbose,
debug => $verbose,
auth_type => 'keystone',
auth_port => '35357',
auth_host => $keystone_host,
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => $sql_connection,
enabled => $enabled,
}
# configures the glance registry
class { 'glance::registry':
verbose => $verbose,
debug => $verbose,
auth_host => $keystone_host,
auth_port => '35357',
auth_type => 'keystone',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => $sql_connection,
enabled => $enabled,
}
# Configure file storage backend
class { 'glance::backend::file': }
# Create the Glance db, this should be configured on your mysql server
class { 'glance::db::mysql':
user => $glance_db_user,
password => $glance_db_password,
dbname => $glance_db_dbname,
allowed_hosts => $allowed_hosts,
}
# configures glance endpoints in keystone
# should be run on your keystone server
class { 'glance::keystone::auth':
password => $glance_user_password,
public_address => $glance_public_real,
admin_address => $glance_admin_real,
internal_address => $glance_internal_real,
region => $region,
}
for full examples, see the examples directory.
in the module, puppetlabs-openstack, the following classes
configure parts of glance:
- openstack::glance # api, file backend, and registry
- openstack::keystone # sets up endpoints
- openstack::db::mysql # sets up db config

84
README.md Normal file
View File

@ -0,0 +1,84 @@
# PuppetLabs Glance module
This module provides a set of manifests that can be used to install and
configure glance.
It is currently targettting the folsom release of OpenStack.
Use the essex branch for essex support.
[![Unit Test Status](https://secure.travis-ci.org/puppetlabs/puppetlabs-glance.png?branch=master)](http://travis-ci.org/puppetlabs/puppetlabs-glance)
## Platforms
* Ubuntu 11.04 (Natty)
* Ubuntu 11.10 (Oneiric)
* Ubuntu 12.04 (Precise)
## configurations
Glance is configured with the following classes:
### configures glance::api service
class { 'glance::api':
verbose => $verbose,
debug => $verbose,
auth_type => 'keystone',
auth_port => '35357',
auth_host => $keystone_host,
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => $sql_connection,
enabled => $enabled,
}
### configures the glance registry
class { 'glance::registry':
verbose => $verbose,
debug => $verbose,
auth_host => $keystone_host,
auth_port => '35357',
auth_type => 'keystone',
keystone_tenant => 'services',
keystone_user => 'glance',
keystone_password => $glance_user_password,
sql_connection => $sql_connection,
enabled => $enabled,
}
### Configure file storage backend
class { 'glance::backend::file': }
### Create the Glance db, this should be configured on your mysql server
class { 'glance::db::mysql':
user => $glance_db_user,
password => $glance_db_password,
dbname => $glance_db_dbname,
allowed_hosts => $allowed_hosts,
}
### configures glance endpoints in keystone
should be run on your keystone server
class { 'glance::keystone::auth':
password => $glance_user_password,
public_address => $glance_public_real,
admin_address => $glance_admin_real,
internal_address => $glance_internal_real,
region => $region,
}
for full examples, see the examples directory.
in the module, puppetlabs-openstack, the following classes
configure parts of glance:
- openstack::glance # api, file backend, and registry
- openstack::keystone # sets up endpoints
- openstack::db::mysql # sets up db config

View File

@ -37,6 +37,7 @@ class role_glance_mysql {
keystone_tenant => 'services', keystone_tenant => 'services',
keystone_user => 'glance', keystone_user => 'glance',
keystone_password => 'glance_password', keystone_password => 'glance_password',
sql_connection => 'mysql://glance:glance@127.0.0.1/glance',
} }
class { 'glance::backend::file': } class { 'glance::backend::file': }

View File

@ -15,8 +15,13 @@ Puppet::Type.type(:glance_api_config).provide(
'=' '='
end end
def file_path def self.file_path
'/etc/glance/glance-api.conf' '/etc/glance/glance-api.conf'
end end
# this needs to be removed. This has been replaced with the class method
def file_path
self.class.file_path
end
end end

View File

@ -15,8 +15,13 @@ Puppet::Type.type(:glance_api_paste_ini).provide(
'=' '='
end end
def file_path def self.file_path
'/etc/glance/glance-api-paste.ini' '/etc/glance/glance-api-paste.ini'
end end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end end

View File

@ -15,8 +15,13 @@ Puppet::Type.type(:glance_cache_config).provide(
'=' '='
end end
def file_path def self.file_path
'/etc/glance/glance-cache.conf' '/etc/glance/glance-cache.conf'
end end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end end

View File

@ -13,25 +13,35 @@ Puppet::Type.type(:glance_image).provide(
commands :glance => 'glance' commands :glance => 'glance'
def self.prefetch(resource) mk_resource_methods
# rebuild the cache for every puppet run
@image_hash = nil
end
def self.image_hash
@image_hash ||= build_image_hash
end
def image_hash
self.class.image_hash
end
def self.instances def self.instances
image_hash.collect do |k, v| list_glance_images.collect do |image|
new(:name => k) attrs = get_glance_image_attrs(image)
new(
:ensure => :present,
:name => attrs['name'],
:is_public => attrs['public'],
:container_format => attrs['container format'],
:id => attrs['id'],
:disk_format => attrs['disk format']
)
end end
end end
def self.prefetch(resources)
images = instances
resources.keys.each do |name|
if provider = images.find{ |pkg| pkg.name == name }
resources[name].provider = provider
end
end
end
def exists?
@property_hash[:ensure] == :present
end
def create def create
stdin = nil stdin = nil
if resource[:source] if resource[:source]
@ -50,64 +60,47 @@ Puppet::Type.type(:glance_image).provide(
raise(Puppet::Error, "Must specify either source or location") raise(Puppet::Error, "Must specify either source or location")
end end
if stdin if stdin
auth_glance_stdin('add', "name='#{resource[:name]}'", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location) result = auth_glance_stdin('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
else else
auth_glance('add', "name='#{resource[:name]}'", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location) results = auth_glance('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
end
if results =~ /Added new image with ID: (\S+)/
@property_hash = {
:ensure => :present,
:name => resource[:name],
:is_public => resource[:is_public],
:container_format => resource[:container_format],
:disk_format => resource[:disk_format],
:id => $1
}
else
fail("did not get expected message from image creation, got #{results}")
end end
end
def exists?
image_hash[resource[:name]]
end end
def destroy def destroy
auth_glance('delete', '-f', image_hash[resource[:name]]['id']) auth_glance('delete', id)
end @property_hash[:ensure] = :absent
def location
image_hash[resource[:name]]['location']
end end
def location=(value) def location=(value)
auth_glance('update', image_hash[resource[:name]]['id'], "location=#{value}") auth_glance('update', id, "location=#{value}")
end
def is_public
image_hash[resource[:name]]['public']
end end
def is_public=(value) def is_public=(value)
auth_glance('update', image_hash[resource[:name]]['id'], "is_public=#{value}") auth_glance('update', id, "is_public=#{value}")
end
def disk_format
image_hash[resource[:name]]['disk format']
end end
def disk_format=(value) def disk_format=(value)
auth_glance('update', image_hash[resource[:name]]['id'], "disk_format=#{value}") auth_glance('update', id, "disk_format=#{value}")
end
def container_format
image_hash[resource[:name]]['container format']
end end
def container_format=(value) def container_format=(value)
auth_glance('update', image_hash[resource[:name]]['id'], "container_format=#{value}") auth_glance('update', id, "container_format=#{value}")
end end
def id def id=(id)
image_hash[resource[:name]]['id'] fail('id is read only')
end end
private
def self.build_image_hash
hash = {}
list_glance_images.each do |image|
attrs = get_glance_image_attrs(image)
hash[attrs['name'].to_s] = attrs
end
hash
end
end end

View File

@ -15,8 +15,13 @@ Puppet::Type.type(:glance_registry_config).provide(
'=' '='
end end
def file_path def self.file_path
'/etc/glance/glance-registry.conf' '/etc/glance/glance-registry.conf'
end end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end end

View File

@ -15,8 +15,13 @@ Puppet::Type.type(:glance_registry_paste_ini).provide(
'=' '='
end end
def file_path def self.file_path
'/etc/glance/glance-registry-paste.ini' '/etc/glance/glance-registry-paste.ini'
end end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end end

View File

@ -50,9 +50,9 @@ class glance::keystone::auth(
if $configure_endpoint { if $configure_endpoint {
keystone_endpoint { "${region}/$auth_name": keystone_endpoint { "${region}/$auth_name":
ensure => present, ensure => present,
public_url => "${public_protocol}://${public_address}:${port}/v1", public_url => "${public_protocol}://${public_address}:${port}",
admin_url => "http://${admin_address}:${port}/v1", admin_url => "http://${admin_address}:${port}",
internal_url => "http://${internal_address}:${port}/v1", internal_url => "http://${internal_address}:${port}",
} }
} }
} }

View File

@ -26,9 +26,9 @@ describe 'glance::keystone::auth' do
it { should contain_keystone_endpoint('RegionOne/glance').with( it { should contain_keystone_endpoint('RegionOne/glance').with(
:ensure => 'present', :ensure => 'present',
:public_url => 'http://127.0.0.1:9292/v1', :public_url => 'http://127.0.0.1:9292',
:admin_url => 'http://127.0.0.1:9292/v1', :admin_url => 'http://127.0.0.1:9292',
:internal_url => 'http://127.0.0.1:9292/v1' :internal_url => 'http://127.0.0.1:9292'
)} )}
end end
@ -76,9 +76,9 @@ describe 'glance::keystone::auth' do
it { should contain_keystone_endpoint('RegionTwo/glance').with( it { should contain_keystone_endpoint('RegionTwo/glance').with(
:ensure => 'present', :ensure => 'present',
:public_url => 'http://10.0.0.1:9393/v1', :public_url => 'http://10.0.0.1:9393',
:admin_url => 'http://10.0.0.2:9393/v1', :admin_url => 'http://10.0.0.2:9393',
:internal_url => 'http://10.0.0.3:9393/v1' :internal_url => 'http://10.0.0.3:9393'
)} )}
end end