summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-08-11 15:51:07 +0000
committerGerrit Code Review <review@openstack.org>2017-08-11 15:51:07 +0000
commitfe0ab45e81771dbcc1bfa82c027dd62405aa160c (patch)
tree7ad9af1a32bfe2d81817e9d82e902b5bb58a9e3b
parentca7788bfa0f46e0143e29600bc15e7083f1a475f (diff)
parent012902ad9212dc1fcd30baac2625407c9fc04694 (diff)
Merge "Added cellv2 support"
-rw-r--r--.rubocop_todo.yml14
-rw-r--r--Gemfile14
-rw-r--r--metadata.rb1
-rw-r--r--recipes/_nova_cell.rb72
-rw-r--r--recipes/api-metadata.rb2
-rw-r--r--recipes/api-os-compute.rb13
-rw-r--r--recipes/compute.rb4
-rw-r--r--recipes/libvirt.rb9
-rw-r--r--recipes/nova-common.rb10
-rw-r--r--spec/_nova_cell_spec.rb44
-rw-r--r--spec/api-os-compute-redhat_spec.rb8
-rw-r--r--spec/compute_spec.rb2
-rw-r--r--spec/libvirt-redhat_spec.rb2
-rw-r--r--spec/libvirt_spec.rb4
-rw-r--r--spec/nova-common_spec.rb19
-rw-r--r--spec/spec_helper.rb23
16 files changed, 189 insertions, 52 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index c16eaaf..45a8aa1 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,6 +1,6 @@
1# This configuration was generated by 1# This configuration was generated by
2# `rubocop --auto-gen-config` 2# `rubocop --auto-gen-config`
3# on 2017-03-06 14:33:48 +0000 using RuboCop version 0.39.0. 3# on 2017-08-02 01:11:06 -0400 using RuboCop version 0.47.1.
4# The point is for the user to remove these configuration records 4# The point is for the user to remove these configuration records
5# one by one as the offenses are removed from the code base. 5# one by one as the offenses are removed from the code base.
6# Note that changes in the inspected code, or installation of new 6# Note that changes in the inspected code, or installation of new
@@ -10,6 +10,11 @@
10Metrics/AbcSize: 10Metrics/AbcSize:
11 Max: 16 11 Max: 16
12 12
13# Offense count: 28
14# Configuration parameters: CountComments, ExcludedMethods.
15Metrics/BlockLength:
16 Max: 373
17
13# Offense count: 2 18# Offense count: 2
14# Configuration parameters: CountComments. 19# Configuration parameters: CountComments.
15Metrics/MethodLength: 20Metrics/MethodLength:
@@ -42,7 +47,7 @@ Style/Documentation:
42 - 'recipes/nova-setup.rb' 47 - 'recipes/nova-setup.rb'
43 - 'recipes/placement_api.rb' 48 - 'recipes/placement_api.rb'
44 49
45# Offense count: 1 50# Offense count: 3
46# Configuration parameters: MinBodyLength. 51# Configuration parameters: MinBodyLength.
47Style/GuardClause: 52Style/GuardClause:
48 Exclude: 53 Exclude:
@@ -61,4 +66,7 @@ Style/Next:
61# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. 66# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
62# SupportedStyles: single_quotes, double_quotes 67# SupportedStyles: single_quotes, double_quotes
63Style/StringLiterals: 68Style/StringLiterals:
64 Enabled: false 69 Exclude:
70 - 'spec/identity_registration_spec.rb'
71 - 'spec/placement_api_spec.rb'
72 - 'spec/spec_helper.rb'
diff --git a/Gemfile b/Gemfile
deleted file mode 100644
index 31c90b5..0000000
--- a/Gemfile
+++ /dev/null
@@ -1,14 +0,0 @@
1## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE
2## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE
3## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS
4
5source 'https://rubygems.org'
6
7gem 'chef', '~> 11.18.6'
8gem 'json', '<= 1.7.7' # chef 11 dependency
9gem 'berkshelf', '~> 3.2.1'
10gem 'hashie', '~> 2.0'
11gem 'chefspec', '~> 4.0.0'
12gem 'rspec', '~> 3.0.0'
13gem 'foodcritic', '~> 4.0'
14gem 'rubocop', '~> 0.29.1'
diff --git a/metadata.rb b/metadata.rb
index 6d0165d..a54c81a 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -7,6 +7,7 @@ license 'Apache 2.0'
7description 'The OpenStack Compute service Nova.' 7description 'The OpenStack Compute service Nova.'
8long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 8long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
9version '15.0.0' 9version '15.0.0'
10chef_version '>= 12.5' if respond_to?(:chef_version)
10 11
11%w(ubuntu redhat centos).each do |os| 12%w(ubuntu redhat centos).each do |os|
12 supports os 13 supports os
diff --git a/recipes/_nova_cell.rb b/recipes/_nova_cell.rb
new file mode 100644
index 0000000..2903632
--- /dev/null
+++ b/recipes/_nova_cell.rb
@@ -0,0 +1,72 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-compute
4# Recipe:: _nova_cell
5#
6# Copyright 2017, Workday, Inc.
7#
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
20
21# This recipe is automatically included in openstack-compute::api-os-compute
22# and not called directly. It creates a basic cellv2 setup, which is required
23# from Ocata forward.
24
25nova_user = node['openstack']['compute']['user']
26nova_group = node['openstack']['compute']['group']
27db_password = get_password('db', 'nova_cell0')
28bind_db = node['openstack']['bind_service']['db']
29listen_address = if bind_db['interface']
30 address_for bind_db['interface']
31 else
32 listen_address = bind_db['host']
33 end
34
35execute 'map cell0' do
36 user nova_user
37 group nova_group
38 command "nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://nova_cell0:#{db_password}@#{listen_address}/nova_cell0?charset=utf8"
39 not_if 'nova-manage cell_v2 list_cells | grep -q cell0'
40 action :run
41end
42
43execute 'create cell1' do
44 user nova_user
45 group nova_group
46 not_if 'nova-manage cell_v2 list_cells | grep -q cell1'
47 command 'nova-manage cell_v2 create_cell --verbose --name cell1'
48 action :run
49end
50
51execute 'api db sync' do
52 timeout node['openstack']['compute']['dbsync_timeout']
53 user nova_user
54 group nova_group
55 command 'nova-manage api_db sync'
56 action :run
57end
58
59execute 'db sync' do
60 timeout node['openstack']['compute']['dbsync_timeout']
61 user nova_user
62 group nova_group
63 command 'nova-manage db sync'
64 action :run
65end
66
67execute 'discover hosts' do
68 user nova_user
69 group nova_group
70 command 'nova-manage cell_v2 discover_hosts'
71 action :run
72end
diff --git a/recipes/api-metadata.rb b/recipes/api-metadata.rb
index 6d370ed..e9f89cb 100644
--- a/recipes/api-metadata.rb
+++ b/recipes/api-metadata.rb
@@ -40,7 +40,7 @@ template '/etc/nova/api-paste.ini' do
40 source 'api-paste.ini.erb' 40 source 'api-paste.ini.erb'
41 owner node['openstack']['compute']['user'] 41 owner node['openstack']['compute']['user']
42 group node['openstack']['compute']['group'] 42 group node['openstack']['compute']['group']
43 mode 00644 43 mode 0o0644
44end 44end
45 45
46service 'nova-api-metadata' do 46service 'nova-api-metadata' do
diff --git a/recipes/api-os-compute.rb b/recipes/api-os-compute.rb
index c7fa8ff..b11c682 100644
--- a/recipes/api-os-compute.rb
+++ b/recipes/api-os-compute.rb
@@ -33,15 +33,16 @@ platform_options['api_os_compute_packages'].each do |pkg|
33 end 33 end
34end 34end
35 35
36nova_user = node['openstack']['compute']['user']
37nova_group = node['openstack']['compute']['group']
38
36template '/etc/nova/api-paste.ini' do 39template '/etc/nova/api-paste.ini' do
37 source 'api-paste.ini.erb' 40 source 'api-paste.ini.erb'
38 owner node['openstack']['compute']['user'] 41 owner nova_user
39 group node['openstack']['compute']['group'] 42 group nova_group
40 mode 00644 43 mode 0o0644
41end 44end
42 45
43nova_user = node['openstack']['compute']['user']
44nova_group = node['openstack']['compute']['group']
45execute 'nova-manage api_db sync' do 46execute 'nova-manage api_db sync' do
46 timeout node['openstack']['compute']['dbsync_timeout'] 47 timeout node['openstack']['compute']['dbsync_timeout']
47 user nova_user 48 user nova_user
@@ -59,3 +60,5 @@ service 'nova-api-os-compute' do
59 'template[/etc/nova/api-paste.ini]' 60 'template[/etc/nova/api-paste.ini]'
60 ] 61 ]
61end 62end
63
64include_recipe 'openstack-compute::_nova_cell'
diff --git a/recipes/compute.rb b/recipes/compute.rb
index 6f8680f..9285475 100644
--- a/recipes/compute.rb
+++ b/recipes/compute.rb
@@ -53,14 +53,14 @@ end
53# TODO: (jklare) this has to be refactored!!! 53# TODO: (jklare) this has to be refactored!!!
54cookbook_file '/etc/nova/nova-compute.conf' do 54cookbook_file '/etc/nova/nova-compute.conf' do
55 source 'nova-compute.conf' 55 source 'nova-compute.conf'
56 mode 00644 56 mode 0o0644
57 action :create 57 action :create
58end 58end
59 59
60directory node['openstack']['compute']['conf']['DEFAULT']['instances_path'] do 60directory node['openstack']['compute']['conf']['DEFAULT']['instances_path'] do
61 owner node['openstack']['compute']['user'] 61 owner node['openstack']['compute']['user']
62 group node['openstack']['compute']['group'] 62 group node['openstack']['compute']['group']
63 mode 00755 63 mode 0o0755
64 recursive true 64 recursive true
65end 65end
66 66
diff --git a/recipes/libvirt.rb b/recipes/libvirt.rb
index 21c0f8f..f724e44 100644
--- a/recipes/libvirt.rb
+++ b/recipes/libvirt.rb
@@ -81,7 +81,8 @@ def update_boot_kernel_and_trigger_reboot(flavor = 'default')
81 update_grub2_default_kernel(flavor) 81 update_grub2_default_kernel(flavor)
82 else 82 else
83 ::Chef::Application.fatal!( 83 ::Chef::Application.fatal!(
84 'Unknown bootloader. Could not change boot kernel.') 84 'Unknown bootloader. Could not change boot kernel.'
85 )
85 end 86 end
86 87
87 # trigger reboot through reboot_handler, if kernel-$flavor is not yet 88 # trigger reboot through reboot_handler, if kernel-$flavor is not yet
@@ -127,7 +128,7 @@ template '/etc/libvirt/libvirtd.conf' do
127 source 'libvirtd.conf.erb' 128 source 'libvirtd.conf.erb'
128 owner 'root' 129 owner 'root'
129 group 'root' 130 group 'root'
130 mode 00644 131 mode 0o0644
131 variables( 132 variables(
132 auth_tcp: node['openstack']['compute']['libvirt']['auth_tcp'], 133 auth_tcp: node['openstack']['compute']['libvirt']['auth_tcp'],
133 libvirt_group: node['openstack']['compute']['libvirt']['group'] 134 libvirt_group: node['openstack']['compute']['libvirt']['group']
@@ -139,7 +140,7 @@ template '/etc/default/libvirt-bin' do
139 source 'libvirt-bin.erb' 140 source 'libvirt-bin.erb'
140 owner 'root' 141 owner 'root'
141 group 'root' 142 group 'root'
142 mode 00644 143 mode 0o0644
143 notifies :restart, 'service[libvirt-bin]', :immediately 144 notifies :restart, 'service[libvirt-bin]', :immediately
144 only_if { platform_family? 'debian' } 145 only_if { platform_family? 'debian' }
145end 146end
@@ -148,7 +149,7 @@ template '/etc/sysconfig/libvirtd' do
148 source 'libvirtd.erb' 149 source 'libvirtd.erb'
149 owner 'root' 150 owner 'root'
150 group 'root' 151 group 'root'
151 mode 00644 152 mode 0o0644
152 notifies :restart, 'service[libvirt-bin]', :immediately 153 notifies :restart, 'service[libvirt-bin]', :immediately
153 only_if { platform_family? %w(rhel) } 154 only_if { platform_family? %w(rhel) }
154end 155end
diff --git a/recipes/nova-common.rb b/recipes/nova-common.rb
index 7363cf7..b1c6c1a 100644
--- a/recipes/nova-common.rb
+++ b/recipes/nova-common.rb
@@ -56,21 +56,21 @@ end
56directory '/etc/nova' do 56directory '/etc/nova' do
57 owner node['openstack']['compute']['user'] 57 owner node['openstack']['compute']['user']
58 group node['openstack']['compute']['group'] 58 group node['openstack']['compute']['group']
59 mode 00750 59 mode 0o0750
60 action :create 60 action :create
61end 61end
62 62
63directory node['openstack']['compute']['conf']['DEFAULT']['state_path'] do 63directory node['openstack']['compute']['conf']['DEFAULT']['state_path'] do
64 owner node['openstack']['compute']['user'] 64 owner node['openstack']['compute']['user']
65 group node['openstack']['compute']['group'] 65 group node['openstack']['compute']['group']
66 mode 00755 66 mode 0o0755
67 recursive true 67 recursive true
68end 68end
69 69
70directory node['openstack']['compute']['conf']['oslo_concurrency']['lock_path'] do 70directory node['openstack']['compute']['conf']['oslo_concurrency']['lock_path'] do
71 owner node['openstack']['compute']['user'] 71 owner node['openstack']['compute']['user']
72 group node['openstack']['compute']['group'] 72 group node['openstack']['compute']['group']
73 mode 00755 73 mode 0o0755
74 recursive true 74 recursive true
75end 75end
76 76
@@ -214,7 +214,7 @@ template '/etc/nova/nova.conf' do
214 source 'nova.conf.erb' 214 source 'nova.conf.erb'
215 owner node['openstack']['compute']['user'] 215 owner node['openstack']['compute']['user']
216 group node['openstack']['compute']['group'] 216 group node['openstack']['compute']['group']
217 mode 00640 217 mode 0o0640
218 variables( 218 variables(
219 # TODO(jaypipes): No support here for >1 image API servers 219 # TODO(jaypipes): No support here for >1 image API servers
220 # with the glance_api_servers configuration option... 220 # with the glance_api_servers configuration option...
@@ -235,7 +235,7 @@ template '/etc/nova/rootwrap.conf' do
235 # Must be root! 235 # Must be root!
236 owner 'root' 236 owner 'root'
237 group 'root' 237 group 'root'
238 mode 00644 238 mode 0o0644
239end 239end
240 240
241execute 'enable nova login' do 241execute 'enable nova login' do
diff --git a/spec/_nova_cell_spec.rb b/spec/_nova_cell_spec.rb
new file mode 100644
index 0000000..6207bfc
--- /dev/null
+++ b/spec/_nova_cell_spec.rb
@@ -0,0 +1,44 @@
1# encoding: UTF-8
2
3require_relative 'spec_helper'
4
5describe 'openstack-compute::_nova_cell' do
6 describe 'ubuntu' do
7 let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
8 let(:node) { runner.node }
9 let(:chef_run) { runner.converge(described_recipe) }
10
11 include_context 'compute_stubs'
12 include_examples 'expect_runs_nova_cell_recipe'
13
14 it 'creates the cell0 mapping' do
15 expect(chef_run).to run_execute('map cell0')
16 .with(user: 'nova',
17 group: 'nova')
18 end
19
20 it 'creates a new cell' do
21 expect(chef_run).to run_execute('create cell1')
22 .with(user: 'nova',
23 group: 'nova')
24 end
25
26 it 'executes api_db sync' do
27 expect(chef_run).to run_execute('api db sync')
28 .with(user: 'nova',
29 group: 'nova')
30 end
31
32 it 'executes db sync' do
33 expect(chef_run).to run_execute('db sync')
34 .with(user: 'nova',
35 group: 'nova')
36 end
37
38 it 'discovers compute hosts' do
39 expect(chef_run).to run_execute('discover hosts')
40 .with(user: 'nova',
41 group: 'nova')
42 end
43 end
44end
diff --git a/spec/api-os-compute-redhat_spec.rb b/spec/api-os-compute-redhat_spec.rb
index 62ea929..bc8d298 100644
--- a/spec/api-os-compute-redhat_spec.rb
+++ b/spec/api-os-compute-redhat_spec.rb
@@ -13,6 +13,14 @@ describe 'openstack-compute::api-os-compute' do
13 include_examples 'expect_creates_nova_state_dir' 13 include_examples 'expect_creates_nova_state_dir'
14 include_examples 'expect_creates_nova_lock_dir' 14 include_examples 'expect_creates_nova_lock_dir'
15 15
16 it 'executes nova-manage api_db sync' do
17 expect(chef_run).to run_execute('nova-manage api_db sync')
18 .with(timeout: 3600,
19 user: 'nova',
20 group: 'nova',
21 command: 'nova-manage api_db sync')
22 end
23
16 it 'upgrades openstack api packages' do 24 it 'upgrades openstack api packages' do
17 expect(chef_run).to upgrade_package 'openstack-nova-api' 25 expect(chef_run).to upgrade_package 'openstack-nova-api'
18 end 26 end
diff --git a/spec/compute_spec.rb b/spec/compute_spec.rb
index 1dc3a85..5de0766 100644
--- a/spec/compute_spec.rb
+++ b/spec/compute_spec.rb
@@ -75,7 +75,7 @@ describe 'openstack-compute::compute' do
75 it 'creates the file' do 75 it 'creates the file' do
76 expect(chef_run).to create_cookbook_file(file.name).with( 76 expect(chef_run).to create_cookbook_file(file.name).with(
77 source: 'nova-compute.conf', 77 source: 'nova-compute.conf',
78 mode: 00644 78 mode: 0o0644
79 ) 79 )
80 end 80 end
81 end 81 end
diff --git a/spec/libvirt-redhat_spec.rb b/spec/libvirt-redhat_spec.rb
index 421826b..3a0a7db 100644
--- a/spec/libvirt-redhat_spec.rb
+++ b/spec/libvirt-redhat_spec.rb
@@ -43,7 +43,7 @@ describe 'openstack-compute::libvirt' do
43 expect(chef_run).to create_template(file.name).with( 43 expect(chef_run).to create_template(file.name).with(
44 owner: 'root', 44 owner: 'root',
45 group: 'root', 45 group: 'root',
46 mode: 0644 46 mode: 0o644
47 ) 47 )
48 end 48 end
49 49
diff --git a/spec/libvirt_spec.rb b/spec/libvirt_spec.rb
index ca555f0..3e0cfa6 100644
--- a/spec/libvirt_spec.rb
+++ b/spec/libvirt_spec.rb
@@ -62,7 +62,7 @@ describe 'openstack-compute::libvirt' do
62 expect(chef_run).to create_template(file.name).with( 62 expect(chef_run).to create_template(file.name).with(
63 owner: 'root', 63 owner: 'root',
64 group: 'root', 64 group: 'root',
65 mode: 0644 65 mode: 0o644
66 ) 66 )
67 end 67 end
68 68
@@ -88,7 +88,7 @@ describe 'openstack-compute::libvirt' do
88 expect(chef_run).to create_template(file.name).with( 88 expect(chef_run).to create_template(file.name).with(
89 owner: 'root', 89 owner: 'root',
90 group: 'root', 90 group: 'root',
91 mode: 0644 91 mode: 0o644
92 ) 92 )
93 end 93 end
94 94
diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb
index eda6077..3185420 100644
--- a/spec/nova-common_spec.rb
+++ b/spec/nova-common_spec.rb
@@ -35,7 +35,7 @@ describe 'openstack-compute::nova-common' do
35 expect(chef_run).to create_directory('/etc/nova').with( 35 expect(chef_run).to create_directory('/etc/nova').with(
36 owner: 'nova', 36 owner: 'nova',
37 group: 'nova', 37 group: 'nova',
38 mode: 0750 38 mode: 0o750
39 ) 39 )
40 end 40 end
41 41
@@ -66,7 +66,7 @@ describe 'openstack-compute::nova-common' do
66 expect(chef_run).to create_template(file.name).with( 66 expect(chef_run).to create_template(file.name).with(
67 owner: 'nova', 67 owner: 'nova',
68 group: 'nova', 68 group: 'nova',
69 mode: 0640 69 mode: 0o640
70 ) 70 )
71 end 71 end
72 72
@@ -155,7 +155,6 @@ describe 'openstack-compute::nova-common' do
155 155
156 it 'uses default values for attributes' do 156 it 'uses default values for attributes' do
157 [ 157 [
158
159 %r{^api_servers = http://127.0.0.1:9292$} 158 %r{^api_servers = http://127.0.0.1:9292$}
160 159
161 ].each do |line| 160 ].each do |line|
@@ -203,8 +202,7 @@ describe 'openstack-compute::nova-common' do
203 node.set['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = 'lo' 202 node.set['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = 'lo'
204 203
205 [/^vncserver_listen = 127.0.0.1$/, 204 [/^vncserver_listen = 127.0.0.1$/,
206 /^vncserver_proxyclient_address = 127.0.0.1$/ 205 /^vncserver_proxyclient_address = 127.0.0.1$/].each do |line|
207 ].each do |line|
208 expect(chef_run).to render_file(file.name).with_content(line) 206 expect(chef_run).to render_file(file.name).with_content(line)
209 end 207 end
210 end 208 end
@@ -265,7 +263,8 @@ describe 'openstack-compute::nova-common' do
265 263
266 it 'has no auto_assign_floating_ip' do 264 it 'has no auto_assign_floating_ip' do
267 expect(chef_run).not_to render_file(file.name).with_content( 265 expect(chef_run).not_to render_file(file.name).with_content(
268 'auto_assign_floating_ip=false') 266 'auto_assign_floating_ip=false'
267 )
269 end 268 end
270 269
271 context 'rbd backend' do 270 context 'rbd backend' do
@@ -385,7 +384,7 @@ describe 'openstack-compute::nova-common' do
385 expect(chef_run).to render_config_file(file.name) 384 expect(chef_run).to render_config_file(file.name)
386 .with_section_content( 385 .with_section_content(
387 'api_database', 386 'api_database',
388 %r{connection = mysql://nova_api:nova_api_db_pass@127.0.0.1:3306/nova_api\?charset=utf8$} 387 %(connection = mysql+pymysql://nova_api:nova_api_db_pass@127.0.0.1:3306/nova_api?charset=utf8)
389 ) 388 )
390 end 389 end
391 390
@@ -397,7 +396,7 @@ describe 'openstack-compute::nova-common' do
397 node.set['openstack']['db']['compute']['username'] = 'nova' 396 node.set['openstack']['db']['compute']['username'] = 'nova'
398 397
399 expect(chef_run).to render_config_file(file.name)\ 398 expect(chef_run).to render_config_file(file.name)\
400 .with_section_content('database', %r{slave_connection = mysql://nova:nova_db_pass@10.10.1.1:3326/nova\?charset=utf8$}) 399 .with_section_content('database', %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8))
401 end 400 end
402 401
403 it 'sets overide database enabled_slave attribute as false' do 402 it 'sets overide database enabled_slave attribute as false' do
@@ -407,7 +406,7 @@ describe 'openstack-compute::nova-common' do
407 node.set['openstack']['db']['compute']['username'] = 'nova' 406 node.set['openstack']['db']['compute']['username'] = 'nova'
408 407
409 expect(chef_run).to_not render_config_file(file.name)\ 408 expect(chef_run).to_not render_config_file(file.name)\
410 .with_section_content('database', %r{slave_connection = mysql://nova:nova_db_pass@10.10.1.1:3326/nova\?charset=utf8$}) 409 .with_section_content('database', %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8))
411 end 410 end
412 end 411 end
413 end 412 end
@@ -419,7 +418,7 @@ describe 'openstack-compute::nova-common' do
419 expect(chef_run).to create_template(file.name).with( 418 expect(chef_run).to create_template(file.name).with(
420 user: 'root', 419 user: 'root',
421 group: 'root', 420 group: 'root',
422 mode: 0644 421 mode: 0o644
423 ) 422 )
424 end 423 end
425 424
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4d059eb..fecb506 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -59,6 +59,9 @@ shared_context 'compute_stubs' do
59 .with('db', 'nova_api') 59 .with('db', 'nova_api')
60 .and_return('nova_api_db_pass') 60 .and_return('nova_api_db_pass')
61 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 61 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
62 .with('db', 'nova_cell0')
63 .and_return('nova_cell0_db_pass')
64 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
62 .with('user', 'guest') 65 .with('user', 'guest')
63 .and_return('mq-pass') 66 .and_return('mq-pass')
64 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 67 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
@@ -92,6 +95,12 @@ shared_context 'compute_stubs' do
92 stub_command('virsh secret-list | grep 00000000-0000-0000-0000-000000000000').and_return(false) 95 stub_command('virsh secret-list | grep 00000000-0000-0000-0000-000000000000').and_return(false)
93 stub_command('virsh secret-set-value --secret 00000000-0000-0000-0000-000000000000 --base64 $(ceph-authtool -p -n client.cinder /etc/ceph/ceph.client.cinder.keyring)').and_return(false) 96 stub_command('virsh secret-set-value --secret 00000000-0000-0000-0000-000000000000 --base64 $(ceph-authtool -p -n client.cinder /etc/ceph/ceph.client.cinder.keyring)').and_return(false)
94 stub_command('virsh secret-get-value 00000000-0000-0000-0000-000000000000 | grep $(ceph-authtool -p -n client.cinder /etc/ceph/ceph.client.cinder.keyring)').and_return(false) 97 stub_command('virsh secret-get-value 00000000-0000-0000-0000-000000000000 | grep $(ceph-authtool -p -n client.cinder /etc/ceph/ceph.client.cinder.keyring)').and_return(false)
98 stub_command('nova-manage api_db sync').and_return(true)
99 stub_command('nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://nova_cell0:mypass@127.0.0.1/nova_cell0?charset=utf8').and_return(true)
100 stub_command('nova-manage cell_v2 create_cell --verbose --name cell1').and_return(true)
101 stub_command('nova-manage cell_v2 list_cells | grep -q cell0').and_return(false)
102 stub_command('nova-manage cell_v2 list_cells | grep -q cell1').and_return(false)
103 stub_command('nova-manage cell_v2 discover_hosts').and_return(true)
95 end 104 end
96end 105end
97 106
@@ -109,12 +118,18 @@ shared_examples 'expect_runs_nova_common_recipe' do
109 end 118 end
110end 119end
111 120
121shared_examples 'expect_runs_nova_cell_recipe' do
122 it 'includes _nova_cell' do
123 expect(chef_run).to include_recipe 'openstack-compute::_nova_cell'
124 end
125end
126
112shared_examples 'expect_creates_nova_state_dir' do 127shared_examples 'expect_creates_nova_state_dir' do
113 it 'creates the /var/lib/nova/lock directory' do 128 it 'creates the /var/lib/nova/lock directory' do
114 expect(chef_run).to create_directory('/var/lib/nova').with( 129 expect(chef_run).to create_directory('/var/lib/nova').with(
115 user: 'nova', 130 user: 'nova',
116 group: 'nova', 131 group: 'nova',
117 mode: 0755 132 mode: 0o755
118 ) 133 )
119 end 134 end
120end 135end
@@ -124,7 +139,7 @@ shared_examples 'expect_creates_nova_lock_dir' do
124 expect(chef_run).to create_directory('/var/lib/nova/lock').with( 139 expect(chef_run).to create_directory('/var/lib/nova/lock').with(
125 user: 'nova', 140 user: 'nova',
126 group: 'nova', 141 group: 'nova',
127 mode: 0755 142 mode: 0o755
128 ) 143 )
129 end 144 end
130end 145end
@@ -134,7 +149,7 @@ shared_examples 'expect_creates_nova_instances_dir' do
134 expect(chef_run).to create_directory('/var/lib/nova/instances').with( 149 expect(chef_run).to create_directory('/var/lib/nova/instances').with(
135 user: 'nova', 150 user: 'nova',
136 group: 'nova', 151 group: 'nova',
137 mode: 0755 152 mode: 0o755
138 ) 153 )
139 end 154 end
140end 155end
@@ -145,7 +160,7 @@ shared_examples 'expect_creates_api_paste_template' do
145 expect(chef_run).to create_template('/etc/nova/api-paste.ini').with( 160 expect(chef_run).to create_template('/etc/nova/api-paste.ini').with(
146 user: 'nova', 161 user: 'nova',
147 group: 'nova', 162 group: 'nova',
148 mode: 0644 163 mode: 0o644
149 ) 164 )
150 end 165 end
151 166