Browse Source

Merge pull request #74 from puppetlabs/master

back port latest folsom changes to folsom branch
tags/folsom-eol^0
Dan Bode 6 years ago
parent
commit
1a5b7504a5

+ 0
- 1
.fixtures.yml View File

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

+ 0
- 5
.gemfile View File

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

+ 25
- 10
.travis.yml View File

@@ -1,18 +1,33 @@
1 1
 language: ruby
2
+bundler_args: --without development
3
+before_script:
4
+  - echo $PUPPET_GEM_VERSION | grep '2.6' && git clone git://github.com/puppetlabs/puppetlabs-create_resources.git spec/fixtures/modules/create_resources || true
5
+script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
2 6
 rvm:
3 7
   - 1.8.7
4
-before_script:
5
-after_script:
6
-script: "rake spec"
8
+  - 1.9.3
9
+  - ruby-head
7 10
 branches:
8 11
   only:
9
-    - master
10
-    - folsom
11
-    - essex
12
+   - master
13
+   - folsom
14
+   - essex
12 15
 env:
13
-  - PUPPET_VERSION=2.7.13
14
-  - PUPPET_VERSION=2.7.6
15
-  - PUPPET_VERSION=2.6.9
16
+  - PUPPET_GEM_VERSION="~> 2.6"
17
+  - PUPPET_GEM_VERSION="~> 2.7"
18
+  - PUPPET_GEM_VERSION="~> 3.0"
19
+  - PUPPET_GEM_VERSION="~> 3.1"
20
+matrix:
21
+  allow_failures:
22
+    - rvm: ruby-head
23
+  exclude:
24
+    - rvm: 1.9.3
25
+      env: PUPPET_GEM_VERSION="~> 2.7"
26
+    - rvm: ruby-head
27
+      env: PUPPET_GEM_VERSION="~> 2.7"
28
+    - rvm: 1.9.3
29
+      env: PUPPET_GEM_VERSION="~> 2.6"
30
+    - rvm: ruby-head
31
+      env: PUPPET_GEM_VERSION="~> 2.6"
16 32
 notifications:
17 33
   email: false
18
-gemfile: .gemfile

+ 7
- 0
CHANGELOG View File

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

+ 13
- 0
Gemfile View File

@@ -0,0 +1,13 @@
1
+source :rubygems
2
+
3
+group :development, :test do
4
+  gem 'puppetlabs_spec_helper', :require => false
5
+end
6
+
7
+if puppetversion = ENV['PUPPET_GEM_VERSION']
8
+  gem 'puppet', puppetversion, :require => false
9
+else
10
+  gem 'puppet', :require => false
11
+end
12
+
13
+# vim:ft=ruby

+ 2
- 2
Modulefile View File

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

+ 0
- 80
README.markdown View File

@@ -1,80 +0,0 @@
1
-# PuppetLabs Glance module
2
-
3
-This module provides a set of manifests that can be used to install and
4
-configure glance.
5
-
6
-It is currently targettting the folsom release of OpenStack.
7
-
8
-Use the essex branch for essex support.
9
-
10
-## Platforms
11
-
12
-* Ubuntu 11.04 (Natty)
13
-* Ubuntu 11.10 (Oneiric)
14
-* Ubuntu 12.04 (Precise)
15
-
16
-## configurations
17
-
18
-Glance is configured with the following classes:
19
-
20
-
21
-  #configures glance::api service
22
-
23
-  class { 'glance::api':
24
-    verbose           => $verbose,
25
-    debug             => $verbose,
26
-    auth_type         => 'keystone',
27
-    auth_port         => '35357',
28
-    auth_host         => $keystone_host,
29
-    keystone_tenant   => 'services',
30
-    keystone_user     => 'glance',
31
-    keystone_password => $glance_user_password,
32
-    sql_connection    => $sql_connection,
33
-    enabled           => $enabled,
34
-  }
35
-
36
-  # configures the glance registry
37
-
38
-  class { 'glance::registry':
39
-    verbose           => $verbose,
40
-    debug             => $verbose,
41
-    auth_host         => $keystone_host,
42
-    auth_port         => '35357',
43
-    auth_type         => 'keystone',
44
-    keystone_tenant   => 'services',
45
-    keystone_user     => 'glance',
46
-    keystone_password => $glance_user_password,
47
-    sql_connection    => $sql_connection,
48
-    enabled           => $enabled,
49
-  }
50
-
51
-  # Configure file storage backend
52
-
53
-  class { 'glance::backend::file': }
54
-
55
-  # Create the Glance db, this should be configured on your mysql server
56
-  class { 'glance::db::mysql':
57
-    user          => $glance_db_user,
58
-    password      => $glance_db_password,
59
-    dbname        => $glance_db_dbname,
60
-    allowed_hosts => $allowed_hosts,
61
-  }
62
-
63
-  # configures glance endpoints in keystone
64
-  # should be run on your keystone server
65
-  class { 'glance::keystone::auth':
66
-    password         => $glance_user_password,
67
-    public_address   => $glance_public_real,
68
-    admin_address    => $glance_admin_real,
69
-    internal_address => $glance_internal_real,
70
-    region           => $region,
71
-  }
72
-
73
-for full examples, see the examples directory.
74
-
75
-in the module, puppetlabs-openstack, the following classes
76
-configure parts of glance:
77
-
78
-  - openstack::glance    # api, file backend, and registry
79
-  - openstack::keystone  # sets up endpoints
80
-  - openstack::db::mysql # sets up db config

+ 84
- 0
README.md View File

@@ -0,0 +1,84 @@
1
+# PuppetLabs Glance module
2
+
3
+This module provides a set of manifests that can be used to install and
4
+configure glance.
5
+
6
+It is currently targettting the folsom release of OpenStack.
7
+
8
+Use the essex branch for essex support.
9
+
10
+[![Unit Test Status](https://secure.travis-ci.org/puppetlabs/puppetlabs-glance.png?branch=master)](http://travis-ci.org/puppetlabs/puppetlabs-glance)
11
+
12
+## Platforms
13
+
14
+* Ubuntu 11.04 (Natty)
15
+* Ubuntu 11.10 (Oneiric)
16
+* Ubuntu 12.04 (Precise)
17
+
18
+## configurations
19
+
20
+Glance is configured with the following classes:
21
+
22
+
23
+### configures glance::api service
24
+
25
+    class { 'glance::api':
26
+      verbose           => $verbose,
27
+      debug             => $verbose,
28
+      auth_type         => 'keystone',
29
+      auth_port         => '35357',
30
+      auth_host         => $keystone_host,
31
+      keystone_tenant   => 'services',
32
+      keystone_user     => 'glance',
33
+      keystone_password => $glance_user_password,
34
+      sql_connection    => $sql_connection,
35
+      enabled           => $enabled,
36
+    }
37
+
38
+### configures the glance registry
39
+
40
+    class { 'glance::registry':
41
+      verbose           => $verbose,
42
+      debug             => $verbose,
43
+      auth_host         => $keystone_host,
44
+      auth_port         => '35357',
45
+      auth_type         => 'keystone',
46
+      keystone_tenant   => 'services',
47
+      keystone_user     => 'glance',
48
+      keystone_password => $glance_user_password,
49
+      sql_connection    => $sql_connection,
50
+      enabled           => $enabled,
51
+    }
52
+
53
+### Configure file storage backend
54
+
55
+    class { 'glance::backend::file': }
56
+
57
+### Create the Glance db, this should be configured on your mysql server
58
+
59
+    class { 'glance::db::mysql':
60
+      user          => $glance_db_user,
61
+      password      => $glance_db_password,
62
+      dbname        => $glance_db_dbname,
63
+      allowed_hosts => $allowed_hosts,
64
+    }
65
+
66
+### configures glance endpoints in keystone
67
+should be run on your keystone server
68
+
69
+    class { 'glance::keystone::auth':
70
+      password         => $glance_user_password,
71
+      public_address   => $glance_public_real,
72
+      admin_address    => $glance_admin_real,
73
+      internal_address => $glance_internal_real,
74
+      region           => $region,
75
+    }
76
+
77
+for full examples, see the examples directory.
78
+
79
+in the module, puppetlabs-openstack, the following classes
80
+configure parts of glance:
81
+
82
+  - openstack::glance    # api, file backend, and registry
83
+  - openstack::keystone  # sets up endpoints
84
+  - openstack::db::mysql # sets up db config

+ 1
- 0
examples/site.pp View File

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

+ 6
- 1
lib/puppet/provider/glance_api_config/ini_setting.rb View File

@@ -15,8 +15,13 @@ Puppet::Type.type(:glance_api_config).provide(
15 15
     '='
16 16
   end
17 17
 
18
-  def file_path
18
+  def self.file_path
19 19
     '/etc/glance/glance-api.conf'
20 20
   end
21 21
 
22
+  # this needs to be removed. This has been replaced with the class method
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
22 27
 end

+ 6
- 1
lib/puppet/provider/glance_api_paste_ini/ini_setting.rb View File

@@ -15,8 +15,13 @@ Puppet::Type.type(:glance_api_paste_ini).provide(
15 15
     '='
16 16
   end
17 17
 
18
-  def file_path
18
+  def self.file_path
19 19
     '/etc/glance/glance-api-paste.ini'
20 20
   end
21 21
 
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
22 27
 end

+ 6
- 1
lib/puppet/provider/glance_cache_config/ini_setting.rb View File

@@ -15,8 +15,13 @@ Puppet::Type.type(:glance_cache_config).provide(
15 15
     '='
16 16
   end
17 17
 
18
-  def file_path
18
+  def self.file_path
19 19
     '/etc/glance/glance-cache.conf'
20 20
   end
21 21
 
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
22 27
 end

+ 44
- 51
lib/puppet/provider/glance_image/glance.rb View File

@@ -13,23 +13,33 @@ Puppet::Type.type(:glance_image).provide(
13 13
 
14 14
   commands :glance => 'glance'
15 15
 
16
-  def self.prefetch(resource)
17
-    # rebuild the cache for every puppet run
18
-    @image_hash = nil
19
-  end
16
+  mk_resource_methods
20 17
 
21
-  def self.image_hash
22
-    @image_hash ||= build_image_hash
18
+  def self.instances
19
+    list_glance_images.collect do |image|
20
+      attrs = get_glance_image_attrs(image)
21
+      new(
22
+        :ensure           => :present,
23
+        :name             => attrs['name'],
24
+        :is_public        => attrs['public'],
25
+        :container_format => attrs['container format'],
26
+        :id               => attrs['id'],
27
+        :disk_format      => attrs['disk format']
28
+      )
29
+    end
23 30
   end
24 31
 
25
-  def image_hash
26
-    self.class.image_hash
32
+  def self.prefetch(resources)
33
+    images = instances
34
+    resources.keys.each do |name|
35
+      if provider = images.find{ |pkg| pkg.name == name }
36
+        resources[name].provider = provider
37
+      end
38
+    end
27 39
   end
28 40
 
29
-  def self.instances
30
-    image_hash.collect do |k, v|
31
-      new(:name => k)
32
-    end
41
+  def exists?
42
+    @property_hash[:ensure] == :present
33 43
   end
34 44
 
35 45
   def create
@@ -50,64 +60,47 @@ Puppet::Type.type(:glance_image).provide(
50 60
       raise(Puppet::Error, "Must specify either source or location")
51 61
     end
52 62
     if stdin
53
-      auth_glance_stdin('add', "name='#{resource[:name]}'", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
63
+      result = auth_glance_stdin('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
54 64
     else
55
-      auth_glance('add', "name='#{resource[:name]}'", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
65
+      results = auth_glance('add', "name=#{resource[:name]}", "is_public=#{resource[:is_public]}", "container_format=#{resource[:container_format]}", "disk_format=#{resource[:disk_format]}", location)
66
+    end
67
+    if results =~ /Added new image with ID: (\S+)/
68
+      @property_hash = {
69
+        :ensure           => :present,
70
+        :name             => resource[:name],
71
+        :is_public        => resource[:is_public],
72
+        :container_format => resource[:container_format],
73
+        :disk_format      => resource[:disk_format],
74
+        :id               => $1
75
+      }
76
+    else
77
+      fail("did not get expected message from image creation, got #{results}")
56 78
     end
57
-  end
58
-
59
-  def exists?
60
-    image_hash[resource[:name]]
61 79
   end
62 80
 
63 81
   def destroy
64
-    auth_glance('delete', '-f', image_hash[resource[:name]]['id'])
65
-  end
66
-
67
-  def location
68
-    image_hash[resource[:name]]['location']
82
+    auth_glance('delete', id)
83
+    @property_hash[:ensure] = :absent
69 84
   end
70 85
 
71 86
   def location=(value)
72
-    auth_glance('update', image_hash[resource[:name]]['id'], "location=#{value}")
73
-  end
74
-
75
-  def is_public
76
-    image_hash[resource[:name]]['public']
87
+    auth_glance('update', id, "location=#{value}")
77 88
   end
78 89
 
79 90
   def is_public=(value)
80
-    auth_glance('update', image_hash[resource[:name]]['id'], "is_public=#{value}")
81
-  end
82
-
83
-  def disk_format
84
-    image_hash[resource[:name]]['disk format']
91
+    auth_glance('update', id, "is_public=#{value}")
85 92
   end
86 93
 
87 94
   def disk_format=(value)
88
-    auth_glance('update', image_hash[resource[:name]]['id'], "disk_format=#{value}")
89
-  end
90
-
91
-  def container_format
92
-    image_hash[resource[:name]]['container format']
95
+    auth_glance('update', id, "disk_format=#{value}")
93 96
   end
94 97
 
95 98
   def container_format=(value)
96
-    auth_glance('update', image_hash[resource[:name]]['id'], "container_format=#{value}")
99
+    auth_glance('update', id, "container_format=#{value}")
97 100
   end
98 101
 
99
-  def id
100
-    image_hash[resource[:name]]['id']
102
+  def id=(id)
103
+    fail('id is read only')
101 104
   end
102 105
 
103
-  private 
104
-    def self.build_image_hash
105
-      hash = {}
106
-      list_glance_images.each do |image|
107
-        attrs = get_glance_image_attrs(image)
108
-        hash[attrs['name'].to_s] = attrs
109
-      end
110
-      hash
111
-    end
112 106
 end
113
-

+ 6
- 1
lib/puppet/provider/glance_registry_config/ini_setting.rb View File

@@ -15,8 +15,13 @@ Puppet::Type.type(:glance_registry_config).provide(
15 15
     '='
16 16
   end
17 17
 
18
-  def file_path
18
+  def self.file_path
19 19
     '/etc/glance/glance-registry.conf'
20 20
   end
21 21
 
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
22 27
 end

+ 6
- 1
lib/puppet/provider/glance_registry_paste_ini/ini_setting.rb View File

@@ -15,8 +15,13 @@ Puppet::Type.type(:glance_registry_paste_ini).provide(
15 15
     '='
16 16
   end
17 17
 
18
-  def file_path
18
+  def self.file_path
19 19
     '/etc/glance/glance-registry-paste.ini'
20 20
   end
21 21
 
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
22 27
 end

+ 3
- 3
manifests/keystone/auth.pp View File

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

+ 6
- 6
spec/classes/glance_keystone_auth_spec.rb View File

@@ -26,9 +26,9 @@ describe 'glance::keystone::auth' do
26 26
 
27 27
     it { should contain_keystone_endpoint('RegionOne/glance').with(
28 28
       :ensure       => 'present',
29
-      :public_url   => 'http://127.0.0.1:9292/v1',
30
-      :admin_url    => 'http://127.0.0.1:9292/v1',
31
-      :internal_url => 'http://127.0.0.1:9292/v1'
29
+      :public_url   => 'http://127.0.0.1:9292',
30
+      :admin_url    => 'http://127.0.0.1:9292',
31
+      :internal_url => 'http://127.0.0.1:9292'
32 32
     )}
33 33
 
34 34
   end
@@ -76,9 +76,9 @@ describe 'glance::keystone::auth' do
76 76
 
77 77
     it { should contain_keystone_endpoint('RegionTwo/glance').with(
78 78
       :ensure       => 'present',
79
-      :public_url   => 'http://10.0.0.1:9393/v1',
80
-      :admin_url    => 'http://10.0.0.2:9393/v1',
81
-      :internal_url => 'http://10.0.0.3:9393/v1'
79
+      :public_url   => 'http://10.0.0.1:9393',
80
+      :admin_url    => 'http://10.0.0.2:9393',
81
+      :internal_url => 'http://10.0.0.3:9393'
82 82
     )}
83 83
 
84 84
   end

Loading…
Cancel
Save