Browse Source

Merge "Use memcached for token caching in cinder authtoken"

tags/11.2.0
Zuul 1 week ago
parent
commit
5d8a30825f

+ 1
- 0
manifests/profile/base/cinder/api.pp View File

@@ -76,6 +76,7 @@ class tripleo::profile::base::cinder::api (
76 76
   }
77 77
 
78 78
   include ::tripleo::profile::base::cinder
79
+  include ::tripleo::profile::base::cinder::authtoken
79 80
 
80 81
   if $enable_internal_tls {
81 82
     if !$cinder_api_network {

+ 44
- 0
manifests/profile/base/cinder/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::cinder::authtoken
16
+#
17
+# Cinder 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::cinder::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 { '::cinder::keystone::authtoken':
41
+      memcached_servers => $memcache_servers
42
+    }
43
+  }
44
+}

+ 70
- 0
spec/classes/tripleo_profile_base_cinder_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::cinder::authtoken' do
20
+  shared_examples_for 'tripleo::profile::base::cinder::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::cinder::authtoken')
28
+        is_expected.to_not contain_class('cinder::keystone::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::cinder::authtoken')
40
+        is_expected.to contain_class('cinder::keystone::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::cinder::authtoken')
53
+        is_expected.to contain_class('cinder::keystone::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::cinder::authtoken'
68
+    end
69
+  end
70
+end

Loading…
Cancel
Save