Browse Source

Merge "Use memcached for token caching in neutron authtoken"

tags/11.2.0
Zuul 1 week ago
parent
commit
12b7e6f60b

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

+ 1
- 0
manifests/profile/base/neutron/server.pp View File

@@ -107,6 +107,7 @@ class tripleo::profile::base::neutron::server (
107 107
   }
108 108
 
109 109
   include ::tripleo::profile::base::neutron
110
+  include ::tripleo::profile::base::neutron::authtoken
110 111
 
111 112
   # Calculate neutron::server::l3_ha based on the number of API nodes
112 113
   # combined with if DVR is enabled.

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

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

@@ -86,6 +86,7 @@ horizon_node_names:
86 86
  - 'controller-1'
87 87
 #Neutron related
88 88
 neutron::rabbit_password: 'password'
89
+neutron::keystone::authtoken::password: 'password'
89 90
 # oslo.messaging related
90 91
 oslo_messaging_rpc_password: 'password'
91 92
 oslo_messaging_notify_password: 'password'

Loading…
Cancel
Save