Browse Source

Merge "Use memcached for token caching in glance authtoken"

tags/11.2.0
Zuul 1 week ago
parent
commit
b12f051818

+ 2
- 0
manifests/profile/base/glance/api.pp View File

@@ -148,6 +148,8 @@ class tripleo::profile::base::glance::api (
148 148
     $sync_db = false
149 149
   }
150 150
 
151
+  include ::tripleo::profile::base::glance::authtoken
152
+
151 153
   if $step >= 4 or ($step >= 3 and $sync_db) {
152 154
     if $enable_internal_tls {
153 155
       if !$glance_network {

+ 44
- 0
manifests/profile/base/glance/authtoken.pp View File

@@ -0,0 +1,44 @@
1
+# Copyright 2019 Red Hat, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+#
15
+# == Class: tripleo::profile::base::glance::authtoken
16
+#
17
+# Glance authtoken profile for TripleO
18
+#
19
+# [*step*]
20
+#   (Optional) The current step in deployment. See tripleo-heat-templates
21
+#   for more details.
22
+#   Defaults to hiera('step')
23
+#
24
+# [*memcached_ips*]
25
+#   (Optional) Array of ipv4 or ipv6 addresses for memcache.
26
+#   Defaults to hiera('memcached_node_ips')
27
+#
28
+class tripleo::profile::base::glance::authtoken (
29
+  $step                = Integer(hiera('step')),
30
+  $memcached_ips       = hiera('memcached_node_ips'),
31
+) {
32
+
33
+  if $step >= 3 {
34
+    if is_ipv6_address($memcached_ips[0]) {
35
+      $memcache_servers = prefix(suffix(any2array(normalize_ip_for_uri($memcached_ips)), ':11211'), 'inet6:')
36
+    } else {
37
+      $memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_ips)), ':11211')
38
+    }
39
+
40
+    class { '::glance::api::authtoken':
41
+      memcached_servers => $memcache_servers
42
+    }
43
+  }
44
+}

+ 70
- 0
spec/classes/tripleo_profile_base_glance_authtoken_spec.rb View File

@@ -0,0 +1,70 @@
1
+#
2
+# Copyright (C) 2019 Red Hat, Inc.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#      http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+#
16
+
17
+require 'spec_helper'
18
+
19
+describe 'tripleo::profile::base::glance::authtoken' do
20
+  shared_examples_for 'tripleo::profile::base::glance::authtoken' do
21
+    context 'with step less than 3' do
22
+      let(:params) { {
23
+        :step => 1,
24
+      } }
25
+
26
+      it {
27
+        is_expected.to contain_class('tripleo::profile::base::glance::authtoken')
28
+        is_expected.to_not contain_class('glance::api::authtoken')
29
+      }
30
+    end
31
+
32
+    context 'with step 3' do
33
+      let(:params) { {
34
+        :step => 3,
35
+        :memcached_ips => '127.0.0.1',
36
+      } }
37
+
38
+      it {
39
+        is_expected.to contain_class('tripleo::profile::base::glance::authtoken')
40
+        is_expected.to contain_class('glance::api::authtoken').with(
41
+            :memcached_servers => ['127.0.0.1:11211'])
42
+      }
43
+    end
44
+
45
+    context 'with step 3 with ipv6' do
46
+      let(:params) { {
47
+        :step     => 3,
48
+        :memcached_ips => '::1',
49
+      } }
50
+
51
+      it {
52
+        is_expected.to contain_class('tripleo::profile::base::glance::authtoken')
53
+        is_expected.to contain_class('glance::api::authtoken').with(
54
+            :memcached_servers => ['[::1]:11211'])
55
+      }
56
+    end
57
+
58
+  end
59
+
60
+
61
+  on_supported_os.each do |os, facts|
62
+    context "on #{os}" do
63
+      let(:facts) do
64
+        facts.merge({ :hostname => 'node.example.com' })
65
+      end
66
+
67
+      it_behaves_like 'tripleo::profile::base::glance::authtoken'
68
+    end
69
+  end
70
+end

+ 2
- 0
spec/fixtures/hieradata/default.yaml View File

@@ -39,6 +39,8 @@ cinder_volume_short_node_names:
39 39
 cinder::backup::nfs::backup_share: '/mnt/backup'
40 40
 cinder::rabbit_password: 'password'
41 41
 cinder::keystone::authtoken::password: 'password'
42
+# glance related items
43
+glance::api::authtoken::password: 'password'
42 44
 # gnocchi related items
43 45
 gnocchi_api_short_bootstrap_node_name: node
44 46
 gnocchi::keystone::authtoken::password: 'password'

Loading…
Cancel
Save