summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Albers <c.albers@x-ion.de>2016-08-31 15:33:25 +0200
committerChristoph Albers <c.albers@x-ion.de>2016-09-30 10:58:23 +0200
commit49d23da16764c499abde28d670ab8f0a4d6025e8 (patch)
tree5395c49940a7f29fdfc59616f2053b0ce1d8453a
parentddad81bf9b1a46cc71bc35c6ecd9f580caa73ec5 (diff)
use_cookbook-openstackclient/identity_v3
- Now use cookbook-openstackclient to create endpoints role service and user - added domain creation and access granting - added values to work with identity_v3 - rewrote specs to work again - added needed keystone_authtoken attributes - updated README Change-Id: I2f339055883354c6a8a77daa7967ff279c4d18d9 Depends-On: I0f8955f05de9b33711c54b9a198f45018cceb8e1 Depends-On: If7b4d6e563081a0be9957353d73ef61a9688df56
Notes
Notes (review): Code-Review+2: Jan Klare <j.klare@cloudbau.de> Code-Review+2: Samuel Cassiba <s@cassiba.com> Workflow+1: Samuel Cassiba <s@cassiba.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 11 Oct 2016 16:09:33 +0000 Reviewed-on: https://review.openstack.org/363696 Project: openstack/cookbook-openstack-block-storage Branch: refs/heads/master
-rw-r--r--Berksfile3
-rw-r--r--README.md8
-rw-r--r--attributes/cinder_conf.rb8
-rw-r--r--attributes/default.rb2
-rw-r--r--metadata.rb1
-rw-r--r--recipes/identity_registration.rb160
-rw-r--r--spec/cinder_common_spec.rb6
-rw-r--r--spec/identity_registration_spec.rb198
-rw-r--r--spec/spec_helper.rb8
9 files changed, 189 insertions, 205 deletions
diff --git a/Berksfile b/Berksfile
index a4fb383..a603520 100644
--- a/Berksfile
+++ b/Berksfile
@@ -8,3 +8,6 @@ cookbook "openstack-identity",
8 github: "openstack/cookbook-openstack-identity" 8 github: "openstack/cookbook-openstack-identity"
9cookbook "openstack-common", 9cookbook "openstack-common",
10 github: "openstack/cookbook-openstack-common" 10 github: "openstack/cookbook-openstack-common"
11cookbook "openstackclient",
12 github: "cloudbau/cookbook-openstackclient"
13
diff --git a/README.md b/README.md
index aaf12fe..18415b6 100644
--- a/README.md
+++ b/README.md
@@ -29,9 +29,10 @@ Cookbooks
29The following cookbooks are dependencies: 29The following cookbooks are dependencies:
30 30
31- 'apt', '~> 4.0' 31- 'apt', '~> 4.0'
32- 'openstack-common', '>= 13.0.0' 32- 'openstack-common', '>= 14.0.0'
33- 'openstack-identity', '>= 13.0.0' 33- 'openstack-identity', '>= 14.0.0'
34- 'openstack-image', '>= 13.0.0' 34- 'openstack-image', '>= 14.0.0'
35- 'openstackclient', '>= 0.1.0'
35 36
36Attributes 37Attributes
37========== 38==========
@@ -96,6 +97,7 @@ License and Author
96| **Author** | Eric Zhou (<zyouzhou@cn.ibm.com>) | 97| **Author** | Eric Zhou (<zyouzhou@cn.ibm.com>) |
97| **Author** | Edwin Wang (<edwin.wang@cn.ibm.com>) | 98| **Author** | Edwin Wang (<edwin.wang@cn.ibm.com>) |
98| **Author** | Jan Klare (<j.klare@cloudbau.de>) | 99| **Author** | Jan Klare (<j.klare@cloudbau.de>) |
100| **Author** | Christoph Albers (<c.albers@x-ion.de>) |
99| | | 101| | |
100| **Copyright** | Copyright (c) 2012, Rackspace US, Inc. | 102| **Copyright** | Copyright (c) 2012, Rackspace US, Inc. |
101| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. | 103| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. |
diff --git a/attributes/cinder_conf.rb b/attributes/cinder_conf.rb
index 9e16ece..d09457b 100644
--- a/attributes/cinder_conf.rb
+++ b/attributes/cinder_conf.rb
@@ -9,10 +9,14 @@ default['openstack']['block-storage']['conf'].tap do |conf|
9 conf['DEFAULT']['control_exchange'] = 'cinder' 9 conf['DEFAULT']['control_exchange'] = 'cinder'
10 conf['DEFAULT']['volume_group'] = 'cinder-volumes' 10 conf['DEFAULT']['volume_group'] = 'cinder-volumes'
11 conf['DEFAULT']['state_path'] = '/var/lib/cinder' 11 conf['DEFAULT']['state_path'] = '/var/lib/cinder'
12 conf['keystone_authtoken']['auth_type'] = 'v2password' 12 conf['keystone_authtoken']['auth_type'] = 'v3password'
13 conf['keystone_authtoken']['region_name'] = node['openstack']['region'] 13 conf['keystone_authtoken']['region_name'] = node['openstack']['region']
14 conf['keystone_authtoken']['username'] = 'cinder' 14 conf['keystone_authtoken']['username'] = 'cinder'
15 conf['keystone_authtoken']['tenant_name'] = 'service' 15 conf['keystone_authtoken']['auth_version'] = node['openstack']['identity']['auth']['version']
16 conf['keystone_authtoken']['project_name'] = 'service'
17 conf['keystone_authtoken']['user_domain_name'] = 'Default'
16 conf['keystone_authtoken']['signing_dir'] = '/var/cache/cinder/api' 18 conf['keystone_authtoken']['signing_dir'] = '/var/cache/cinder/api'
19 conf['keystone_authtoken']['project_domain_name'] = 'Default'
20
17 conf['oslo_concurrency']['lock_path'] = '/var/lib/cinder/tmp' 21 conf['oslo_concurrency']['lock_path'] = '/var/lib/cinder/tmp'
18end 22end
diff --git a/attributes/default.rb b/attributes/default.rb
index 8fb12f0..b4139d0 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -49,7 +49,7 @@ default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messa
49default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone' 49default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone'
50 50
51default['openstack']['block-storage']['service_user'] = 'cinder' 51default['openstack']['block-storage']['service_user'] = 'cinder'
52default['openstack']['block-storage']['service_tenant_name'] = 'service' 52default['openstack']['block-storage']['project'] = 'service'
53default['openstack']['block-storage']['service_role'] = 'service' 53default['openstack']['block-storage']['service_role'] = 'service'
54default['openstack']['block-storage']['service_name'] = 'cinderv2' 54default['openstack']['block-storage']['service_name'] = 'cinderv2'
55default['openstack']['block-storage']['service_type'] = 'volumev2' 55default['openstack']['block-storage']['service_type'] = 'volumev2'
diff --git a/metadata.rb b/metadata.rb
index df1ecb3..18e321d 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -17,3 +17,4 @@ depends 'apt', '~> 4.0'
17depends 'openstack-common', '>= 14.0.0' 17depends 'openstack-common', '>= 14.0.0'
18depends 'openstack-identity', '>= 14.0.0' 18depends 'openstack-identity', '>= 14.0.0'
19depends 'openstack-image', '>= 14.0.0' 19depends 'openstack-image', '>= 14.0.0'
20depends 'openstackclient'
diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb
index 8133bba..08897cf 100644
--- a/recipes/identity_registration.rb
+++ b/recipes/identity_registration.rb
@@ -27,102 +27,112 @@ class ::Chef::Recipe
27end 27end
28 28
29identity_admin_endpoint = admin_endpoint 'identity' 29identity_admin_endpoint = admin_endpoint 'identity'
30bootstrap_token = get_password 'token', 'openstack_identity_bootstrap_token' 30auth_url = ::URI.decode identity_admin_endpoint.to_s
31auth_uri = ::URI.decode identity_admin_endpoint.to_s 31
32admin_cinder_api_endpoint = admin_endpoint 'block-storage' 32interfaces = {
33internal_cinder_api_endpoint = internal_endpoint 'block-storage' 33 public: { url: public_endpoint('block-storage') },
34public_cinder_api_endpoint = public_endpoint 'block-storage' 34 internal: { url: internal_endpoint('block-storage') },
35 admin: { url: admin_endpoint('block-storage') }
36}
35service_pass = get_password 'service', 'openstack-block-storage' 37service_pass = get_password 'service', 'openstack-block-storage'
36region = node['openstack']['block-storage']['region'] 38region = node['openstack']['block-storage']['region']
37service_tenant_name = node['openstack']['block-storage']['service_tenant_name'] 39service_project_name = node['openstack']['block-storage']['conf']['keystone_authtoken']['project_name']
38service_user = node['openstack']['block-storage']['service_user'] 40service_user = node['openstack']['block-storage']['service_user']
41admin_user = node['openstack']['identity']['admin_user']
42admin_pass = get_password 'user', node['openstack']['identity']['admin_user']
43admin_project = node['openstack']['identity']['admin_project']
44admin_domain = node['openstack']['identity']['admin_domain_name']
45service_domain_name = node['openstack']['block-storage']['conf']['keystone_authtoken']['user_domain_name']
39service_role = node['openstack']['block-storage']['service_role'] 46service_role = node['openstack']['block-storage']['service_role']
40service_name = node['openstack']['block-storage']['service_name'] 47service_name = node['openstack']['block-storage']['service_name']
41service_type = node['openstack']['block-storage']['service_type'] 48service_type = node['openstack']['block-storage']['service_type']
42 49
43openstack_identity_register 'Register Service Tenant' do 50connection_params = {
44 auth_uri auth_uri 51 openstack_auth_url: "#{auth_url}/auth/tokens",
45 bootstrap_token bootstrap_token 52 openstack_username: admin_user,
46 tenant_name service_tenant_name 53 openstack_api_key: admin_pass,
47 tenant_description 'Service Tenant' 54 openstack_project_name: admin_project,
48 action :create_tenant 55 openstack_domain_name: admin_domain
56}
57
58# Register VolumeV2 Service
59openstack_service service_name do
60 type service_type
61 connection_params connection_params
49end 62end
50 63
51openstack_identity_register 'Register Cinder V2 Volume Service' do 64interfaces.each do |interface, res|
52 auth_uri auth_uri 65 # Register VolumeV2 Endpoints
53 bootstrap_token bootstrap_token 66 openstack_endpoint service_type do
54 service_name service_name 67 service_name service_name
55 service_type service_type 68 interface interface.to_s
56 service_description 'Cinder Volume Service V2' 69 url res[:url].to_s
57 endpoint_region region 70 region region
58 endpoint_adminurl ::URI.decode admin_cinder_api_endpoint.to_s 71 connection_params connection_params
59 endpoint_internalurl ::URI.decode internal_cinder_api_endpoint.to_s 72 end
60 endpoint_publicurl ::URI.decode public_cinder_api_endpoint.to_s
61 action :create_service
62end 73end
63 74
64openstack_identity_register 'Register Cinder V2 Volume Endpoint' do 75# Register Service Project
65 auth_uri auth_uri 76openstack_project service_project_name do
66 bootstrap_token bootstrap_token 77 connection_params connection_params
67 service_name service_name 78end
68 service_type service_type 79
69 service_description 'Cinder Volume Service V2' 80# Register Service User
70 endpoint_region region 81openstack_user service_user do
71 endpoint_adminurl ::URI.decode admin_cinder_api_endpoint.to_s 82 project_name service_project_name
72 endpoint_internalurl ::URI.decode internal_cinder_api_endpoint.to_s 83 role_name service_role
73 endpoint_publicurl ::URI.decode public_cinder_api_endpoint.to_s 84 password service_pass
74 action :create_endpoint 85 connection_params connection_params
86end
87
88## Grant Service role to Service User for Service Tenant ##
89openstack_user service_user do
90 role_name service_role
91 project_name service_project_name
92 connection_params connection_params
93 action :grant_role
75end 94end
76 95
96openstack_user service_user do
97 domain_name service_domain_name
98 role_name service_role
99 connection_params connection_params
100 action :grant_domain
101end
77# --------------------- WORKAROUND --------------------------------------# 102# --------------------- WORKAROUND --------------------------------------#
78# Currently this bug is still open 103# Currently this bug is still open
79# (https://bugs.launchpad.net/horizon/+bug/1415712) and we need to register and 104# (https://bugs.launchpad.net/horizon/+bug/1415712) and we need to register and
80# enable the cinder v1 api to make it available via the dashboard. This should 105# enable the cinder v1 api to make it available via the dashboard. This should
81# be removed with the final mitaka release. 106# be removed with the final mitaka release.
82 107
83openstack_identity_register 'Register Cinder V1 Volume Service' do 108# openstack_identity_register 'Register Cinder V1 Volume Service' do
84 auth_uri auth_uri 109# auth_uri auth_uri
85 bootstrap_token bootstrap_token 110# bootstrap_token bootstrap_token
86 service_name (service_name.gsub(/v2/, '')) 111# service_name ((service_name).gsub(/v2/, ''))
87 service_type (service_type.gsub(/v2/, '')) 112# service_type ((service_type).gsub(/v2/, ''))
88 service_description 'Cinder Volume Service V1' 113# service_description 'Cinder Volume Service V1'
89 endpoint_region region 114# endpoint_region region
90 endpoint_adminurl (::URI.decode admin_cinder_api_endpoint.to_s.gsub(/v2/, 'v1')) 115# endpoint_adminurl ((::URI.decode admin_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
91 endpoint_internalurl (::URI.decode internal_cinder_api_endpoint.to_s.gsub(/v2/, 'v1')) 116# endpoint_internalurl ((::URI.decode internal_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
92 endpoint_publicurl (::URI.decode public_cinder_api_endpoint.to_s.gsub(/v2/, 'v1')) 117# endpoint_publicurl ((::URI.decode public_cinder_api_endpoint.to_s).gsub(/v2/, 'v1'))
93 action :create_service 118# action :create_service
94end 119# end
95 120
96openstack_identity_register 'Register Cinder V1 Volume Endpoint' do 121# Register Volume Service
97 auth_uri auth_uri 122openstack_service 'cinder' do
98 bootstrap_token bootstrap_token 123 type 'volume'
99 service_name (service_name.gsub(/v2/, '')) 124 connection_params connection_params
100 service_type (service_type.gsub(/v2/, ''))
101 service_description 'Cinder Volume Service V1'
102 endpoint_region region
103 endpoint_adminurl (::URI.decode admin_cinder_api_endpoint.to_s.gsub(/v2/, 'v1'))
104 endpoint_internalurl (::URI.decode internal_cinder_api_endpoint.to_s.gsub(/v2/, 'v1'))
105 endpoint_publicurl (::URI.decode public_cinder_api_endpoint.to_s.gsub(/v2/, 'v1'))
106 action :create_endpoint
107end 125end
108 126
109# --------------------- WORKAROUND --------------------------------------# 127interfaces.each do |interface, res|
110 128 # Register VolumeV1 Endpoints
111openstack_identity_register 'Register Cinder Service User' do 129 openstack_endpoint 'volume' do
112 auth_uri auth_uri 130 service_name 'cinder'
113 bootstrap_token bootstrap_token 131 interface interface.to_s
114 tenant_name service_tenant_name 132 url (::URI.decode res[:url].to_s).gsub(/v2/, 'v1')
115 user_name service_user 133 region region
116 user_pass service_pass 134 connection_params connection_params
117 user_enabled true # Not required as this is the default 135 end
118 action :create_user
119end 136end
120 137
121openstack_identity_register 'Grant service Role to Cinder Service User for Cinder Service Tenant' do 138# --------------------- WORKAROUND --------------------------------------#
122 auth_uri auth_uri
123 bootstrap_token bootstrap_token
124 tenant_name service_tenant_name
125 user_name service_user
126 role_name service_role
127 action :grant_role
128end
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index a224659..8e65abf 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -77,13 +77,11 @@ describe 'openstack-block-storage::cinder-common' do
77 77
78 context 'endpoint related' do 78 context 'endpoint related' do
79 it 'has auth_uri' do 79 it 'has auth_uri' do
80 expect(chef_run).to render_file(file.name).with_content(%r{^auth_url = http://127.0.0.1:5000/v2.0$}) 80 expect(chef_run).to render_file(file.name).with_content(%r{^auth_url = http://127.0.0.1:5000/v3$})
81 end 81 end
82 end 82 end
83 83
84 it 'has no auth_version when auth_version is v2.0' do 84 it do
85 node.set['openstack']['block-storage']['api']['auth']['version'] = 'v2.0'
86
87 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/) 85 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
88 end 86 end
89 87
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 35b79ea..6a8def2 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -12,153 +12,117 @@ describe 'openstack-block-storage::identity_registration' do
12 12
13 include_context 'block-storage-stubs' 13 include_context 'block-storage-stubs'
14 14
15 it 'registers service tenant' do 15 connection_params = {
16 expect(chef_run).to create_tenant_openstack_identity_register( 16 openstack_auth_url: 'http://127.0.0.1:35357/v3/auth/tokens',
17 'Register Service Tenant' 17 openstack_username: 'admin',
18 openstack_api_key: 'emc_test_pass',
19 openstack_project_name: 'admin',
20 openstack_domain_name: 'default'
21 }
22 service_name = 'cinderv2'
23 service_type = 'volumev2'
24 service_user = 'cinder'
25 url = 'http://127.0.0.1:8776/v2/%(tenant_id)s'
26 region = 'RegionOne'
27 project_name = 'service'
28 role_name = 'service'
29 password = 'cinder-pass'
30 domain_name = 'Default'
31
32 it "registers #{project_name} Project" do
33 expect(chef_run).to create_openstack_project(
34 project_name
18 ).with( 35 ).with(
19 auth_uri: 'http://127.0.0.1:35357/v2.0', 36 connection_params: connection_params
20 bootstrap_token: 'bootstrap-token',
21 tenant_name: 'service',
22 tenant_description: 'Service Tenant'
23 ) 37 )
24 end 38 end
25 39
26 it 'registers cinder v2 volume service' do 40 it "registers #{service_name} service" do
27 expect(chef_run).to create_service_openstack_identity_register( 41 expect(chef_run).to create_openstack_service(
28 'Register Cinder V2 Volume Service' 42 service_name
29 ).with( 43 ).with(
30 auth_uri: 'http://127.0.0.1:35357/v2.0', 44 connection_params: connection_params,
31 bootstrap_token: 'bootstrap-token', 45 type: service_type
32 service_name: 'cinderv2',
33 service_type: 'volumev2',
34 service_description: 'Cinder Volume Service V2',
35 endpoint_region: 'RegionOne',
36 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
37 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
38 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
39 ) 46 )
40 end 47 end
41 48
42 context 'registers v2 volume endpoint' do 49 context "registers #{service_name} endpoint" do
43 it 'with default values' do 50 %w(admin internal public).each do |interface|
44 expect(chef_run).to create_endpoint_openstack_identity_register( 51 it "#{interface} endpoint with default values" do
45 'Register Cinder V2 Volume Endpoint' 52 expect(chef_run).to create_openstack_endpoint(
46 ).with( 53 service_type
47 auth_uri: 'http://127.0.0.1:35357/v2.0', 54 ).with(
48 bootstrap_token: 'bootstrap-token', 55 service_name: service_name,
49 service_name: 'cinderv2', 56 # interface: interface,
50 service_type: 'volumev2', 57 url: url,
51 service_description: 'Cinder Volume Service V2', 58 region: region,
52 endpoint_region: 'RegionOne', 59 connection_params: connection_params
53 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s', 60 )
54 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s', 61 end
55 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
56 )
57 end
58
59 it 'with all different URLs' do
60 admin_url = 'https://admin.host:123/admin_path'
61 internal_url = 'http://internal.host:456/internal_path'
62 public_url = 'https://public.host:789/public_path'
63
64 node.set['openstack']['endpoints']['internal']['block-storage']['uri'] = internal_url
65 node.set['openstack']['endpoints']['admin']['block-storage']['uri'] = admin_url
66 node.set['openstack']['endpoints']['public']['block-storage']['uri'] = public_url
67
68 expect(chef_run).to create_endpoint_openstack_identity_register(
69 'Register Cinder V2 Volume Endpoint'
70 ).with(
71 auth_uri: 'http://127.0.0.1:35357/v2.0',
72 bootstrap_token: 'bootstrap-token',
73 service_name: 'cinderv2',
74 service_type: 'volumev2',
75 service_description: 'Cinder Volume Service V2',
76 endpoint_region: 'RegionOne',
77 endpoint_adminurl: admin_url,
78 endpoint_internalurl: internal_url,
79 endpoint_publicurl: public_url
80 )
81 end 62 end
63 %w(admin internal public).each do |interface|
64 it "#{interface} with different service type/name and registers v1 endpoint" do
65 node.set['openstack']['block-storage']['service_name'] = 'cinder'
66 node.set['openstack']['block-storage']['service_type'] = 'volume'
82 67
83 it 'with different service type/name' do 68 expect(chef_run).to create_openstack_endpoint(
84 node.set['openstack']['block-storage']['service_name'] = 'cinder' 69 'volume'
85 node.set['openstack']['block-storage']['service_type'] = 'volume' 70 ).with(
86 71 service_name: 'cinder',
87 expect(chef_run).to create_endpoint_openstack_identity_register( 72 # interface: interface,
88 'Register Cinder V2 Volume Endpoint' 73 url: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
89 ).with( 74 region: 'RegionOne',
90 auth_uri: 'http://127.0.0.1:35357/v2.0', 75 connection_params: connection_params
91 bootstrap_token: 'bootstrap-token', 76 )
92 service_name: 'cinder', 77 end
93 service_type: 'volume',
94 service_description: 'Cinder Volume Service V2',
95 endpoint_region: 'RegionOne',
96 endpoint_adminurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
97 endpoint_internalurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s',
98 endpoint_publicurl: 'http://127.0.0.1:8776/v2/%(tenant_id)s'
99 )
100 end 78 end
101 79
102 it 'with custom region override' do 80 it 'with custom region override' do
103 node.set['openstack']['block-storage']['region'] = 'volumeRegion' 81 node.set['openstack']['block-storage']['region'] = 'volumeRegion'
104 expect(chef_run).to create_endpoint_openstack_identity_register( 82 expect(chef_run).to create_openstack_endpoint(
105 'Register Cinder V2 Volume Endpoint' 83 service_type
106 ).with(endpoint_region: 'volumeRegion') 84 ).with(region: 'volumeRegion')
107 end 85 end
108 end 86 end
109 87
110 it 'registers service user' do 88 it 'registers service user' do
111 expect(chef_run).to create_user_openstack_identity_register( 89 expect(chef_run).to create_openstack_user(
112 'Register Cinder Service User' 90 service_user
113 ).with( 91 ).with(
114 auth_uri: 'http://127.0.0.1:35357/v2.0', 92 project_name: project_name,
115 bootstrap_token: 'bootstrap-token', 93 role_name: role_name,
116 tenant_name: 'service', 94 password: password,
117 user_name: 'cinder', 95 connection_params: connection_params
118 user_pass: 'cinder-pass',
119 user_enabled: true
120 ) 96 )
121 end 97 end
122 98
123 it 'grants service role to service user for service tenant' do 99 it do
124 expect(chef_run).to grant_role_openstack_identity_register( 100 expect(chef_run).to grant_domain_openstack_user(
125 'Grant service Role to Cinder Service User for Cinder Service Tenant' 101 service_user
126 ).with( 102 ).with(
127 auth_uri: 'http://127.0.0.1:35357/v2.0', 103 domain_name: domain_name,
128 bootstrap_token: 'bootstrap-token', 104 role_name: role_name,
129 tenant_name: 'service', 105 connection_params: connection_params
130 user_name: 'cinder',
131 role_name: 'service'
132 ) 106 )
133 end 107 end
108
134 it do 109 it do
135 expect(chef_run).to create_service_openstack_identity_register( 110 expect(chef_run).to grant_role_openstack_user(
136 'Register Cinder V1 Volume Service' 111 service_user
137 ).with( 112 ).with(
138 auth_uri: 'http://127.0.0.1:35357/v2.0', 113 project_name: project_name,
139 bootstrap_token: 'bootstrap-token', 114 role_name: role_name,
140 service_name: 'cinder', 115 password: password,
141 service_type: 'volume', 116 connection_params: connection_params
142 service_description: 'Cinder Volume Service V1',
143 endpoint_region: 'RegionOne',
144 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
145 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
146 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
147 ) 117 )
148 end 118 end
149 it do 119
150 expect(chef_run).to create_endpoint_openstack_identity_register( 120 it 'registers cinder v1 volume service' do
151 'Register Cinder V1 Volume Endpoint' 121 expect(chef_run).to create_openstack_service(
122 'cinder'
152 ).with( 123 ).with(
153 auth_uri: 'http://127.0.0.1:35357/v2.0', 124 connection_params: connection_params,
154 bootstrap_token: 'bootstrap-token', 125 type: 'volume'
155 service_name: 'cinder',
156 service_type: 'volume',
157 service_description: 'Cinder Volume Service V1',
158 endpoint_region: 'RegionOne',
159 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
160 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
161 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
162 ) 126 )
163 end 127 end
164 end 128 end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9b80925..0876859 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -108,12 +108,14 @@ shared_examples 'creates_cinder_conf' do |service, user, group, action = :restar
108 108
109 it do 109 it do
110 [ 110 [
111 /^auth_type = v2password$/, 111 /^auth_type = v3password$/,
112 /^region_name = RegionOne$/, 112 /^region_name = RegionOne$/,
113 /^username = cinder/, 113 /^username = cinder/,
114 /^tenant_name = service$/, 114 /^project_name = service$/,
115 /^user_domain_name = Default/,
116 /^project_domain_name = Default/,
115 %r{^signing_dir = /var/cache/cinder/api$}, 117 %r{^signing_dir = /var/cache/cinder/api$},
116 %r{^auth_url = http://127.0.0.1:5000/v2.0$}, 118 %r{^auth_url = http://127.0.0.1:5000/v3$},
117 /^password = cinder-pass$/ 119 /^password = cinder-pass$/
118 ].each do |line| 120 ].each do |line|
119 expect(chef_run).to render_config_file(file.name) 121 expect(chef_run).to render_config_file(file.name)