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
- updated readme
- added domain to image-upload
  edited resource / provider

Change-Id: If7b4d6e563081a0be9957353d73ef61a9688df56
Depends-On: I0f8955f05de9b33711c54b9a198f45018cceb8e1
This commit is contained in:
Christoph Albers 2016-08-31 15:55:27 +02:00
parent 8be768ab2e
commit 419e7bc05e
16 changed files with 178 additions and 189 deletions

View File

@ -6,3 +6,5 @@ cookbook "openstack-identity",
github: "openstack/cookbook-openstack-identity"
cookbook "openstack-common",
github: "openstack/cookbook-openstack-common"
cookbook "openstackclient",
github: "cloudbau/cookbook-openstackclient"

View File

@ -28,8 +28,9 @@ Cookbooks
The following cookbooks are dependencies:
- 'openstack-common', '>= 13.0.0'
- 'openstack-identity', '>= 13.0.0'
- 'openstack-common', '>= 14.0.0'
- 'openstack-identity', '>= 14.0.0'
- 'openstackclient', '>= 0.1.0'
Attributes
==========
@ -124,8 +125,7 @@ Action: `:upload`
- `:identity_tenant`: Name of the Keystone admin user's tenant.
- `:identity_uri`: URI of the Identity API endpoint.
For testing this provider with ChefSpec, a custom matcher was added to
`libraries/matchers.rb`.
For testing this provider with ChefSpec, a custom matcher was added to `libraries/matchers.rb`.
License and Author
==================

View File

@ -48,7 +48,7 @@ default['openstack']['image']['region'] = node['openstack']['region']
# The name of the Chef role that knows about the message queue server
# that Glance uses
default['openstack']['image']['rabbit_server_chef_role'] = 'os-ops-messaging'
default['openstack']['image']['service_tenant_name'] = 'service'
default['openstack']['image']['service_project'] = 'service'
default['openstack']['image']['service_user'] = 'glance'
default['openstack']['image']['service_role'] = 'admin'
@ -144,7 +144,7 @@ end
default['openstack']['endpoints'][ep_type][service]['host'] = '127.0.0.1'
default['openstack']['endpoints'][ep_type]['image_api']['path'] = ''
default['openstack']['endpoints'][ep_type]['image_api']['port'] = 9292
default['openstack']['endpoints'][ep_type]['image_registry']['path'] = '/v2'
default['openstack']['endpoints'][ep_type]['image_registry']['path'] = '/v3'
default['openstack']['endpoints'][ep_type]['image_registry']['port'] = 9191
end
end

View File

@ -14,9 +14,11 @@ default['openstack']['image_api']['conf'].tap do |conf|
conf['paste_deploy']['flavor'] = 'keystone'
# [keystone_authtoken] section
conf['keystone_authtoken']['auth_type'] = 'v2password'
conf['keystone_authtoken']['auth_type'] = 'v3password'
conf['keystone_authtoken']['region_name'] = node['openstack']['region']
conf['keystone_authtoken']['username'] = 'glance'
conf['keystone_authtoken']['tenant_name'] = 'service'
conf['keystone_authtoken']['project_name'] = 'admin'
conf['keystone_authtoken']['user_domain_name'] = 'Default'
conf['keystone_authtoken']['signing_dir'] = '/var/cache/glance/api'
conf['keystone_authtoken']['project_domain_name'] = 'Default'
end

View File

@ -11,9 +11,11 @@ default['openstack']['image_registry']['conf'].tap do |conf|
conf['paste_deploy']['flavor'] = 'keystone'
# [keystone_authtoken] section
conf['keystone_authtoken']['auth_type'] = 'v2password'
conf['keystone_authtoken']['auth_type'] = 'v3password'
conf['keystone_authtoken']['region_name'] = node['openstack']['region']
conf['keystone_authtoken']['username'] = 'glance'
conf['keystone_authtoken']['tenant_name'] = 'service'
conf['keystone_authtoken']['project_name'] = 'service'
conf['keystone_authtoken']['user_domain_name'] = 'Default'
conf['keystone_authtoken']['signing_dir'] = '/var/cache/glance/registry' # none in docs
conf['keystone_authtoken']['project_domain_name'] = 'Default'
end

View File

@ -12,5 +12,6 @@ version '14.0.0'
supports os
end
depends 'openstackclient'
depends 'openstack-common', '>= 14.0.0'
depends 'openstack-identity', '>= 14.0.0'

View File

@ -28,6 +28,8 @@ action :upload do
@pass = new_resource.identity_pass
@tenant = new_resource.identity_tenant
@ks_uri = new_resource.identity_uri
@domain = new_resource.identity_user_domain_name
@project_domain_name = new_resource.identity_project_domain_name
name = new_resource.image_name
url = new_resource.image_url
@ -68,7 +70,7 @@ def _upload_image(type, name, api, url, public)
end
def _upload_image_bare(name, api, url, public, type)
glance_cmd = "glance --insecure --os-username #{@user} --os-password #{@pass} --os-tenant-name #{@tenant} --os-image-url #{api} --os-auth-url #{@ks_uri}"
glance_cmd = "glance --insecure --os-username #{@user} --os-password #{@pass} --os-project-name #{@tenant} --os-image-url #{api} --os-auth-url #{@ks_uri} --os-user-domain-name #{@domain} --os-project-domain-name #{@project_domain_name}"
c_fmt = '--container-format bare'
d_fmt = "--disk-format #{type}"
@ -82,7 +84,7 @@ end
# TODO(chrislaco) This refactor is in the works via Craig Tracey
def _upload_ami(name, api, url, public)
glance_cmd = "glance --insecure --os-username #{@user} --os-password #{@pass} --os-tenant-name #{@tenant} --os-image-url #{api} --os-auth-url #{@ks_uri}"
glance_cmd = "glance --insecure --os-username #{@user} --os-password #{@pass} --os-project-name #{@tenant} --os-image-url #{api} --os-auth-url #{@ks_uri} --os-user-domain-name #{@domain} --os-project-domain-name #{@project_domain_name}"
aki_fmt = '--container-format aki --disk-format aki'
ari_fmt = '--container-format ari --disk-format ari'
ami_fmt = '--container-format ami --disk-format ami'

View File

@ -28,71 +28,79 @@ end
identity_admin_endpoint = admin_endpoint 'identity'
token = get_password 'token', 'openstack_identity_bootstrap_token'
auth_url = ::URI.decode identity_admin_endpoint.to_s
api_internal_endpoint = internal_endpoint 'image_api'
api_public_endpoint = public_endpoint 'image_api'
api_admin_endpoint = admin_endpoint 'image_api'
interfaces = {
public: { url: public_endpoint('image_api') },
internal: { url: internal_endpoint('image_api') },
admin: { url: admin_endpoint('image_api') }
}
admin_user = node['openstack']['identity']['admin_user']
admin_pass = get_password 'user', admin_user
admin_project = node['openstack']['identity']['admin_project']
admin_domain = node['openstack']['identity']['admin_domain_name']
service_pass = get_password 'service', 'openstack-image'
service_tenant_name =
node['openstack']['image_api']['conf']['keystone_authtoken']['tenant_name']
service_project =
node['openstack']['image_api']['conf']['keystone_authtoken']['project_name']
service_user =
node['openstack']['image_api']['conf']['keystone_authtoken']['username']
service_role = node['openstack']['image']['service_role']
service_domain_name = node['openstack']['image_api']['conf']['keystone_authtoken']['user_domain_name']
region = node['openstack']['region']
connection_params = {
openstack_auth_url: "#{auth_url}/auth/tokens",
openstack_username: admin_user,
openstack_api_key: admin_pass,
openstack_project_name: admin_project,
openstack_domain_name: admin_domain
}
# Register Image Service
openstack_identity_register 'Register Image Service' do
auth_uri auth_url
bootstrap_token token
service_name 'glance'
service_type 'image'
service_description 'Glance Image Service'
action :create_service
openstack_service 'glance' do
type 'image'
connection_params connection_params
end
# Register Image Endpoint
openstack_identity_register 'Register Image Endpoint' do
auth_uri auth_url
bootstrap_token token
service_type 'image'
endpoint_region region
endpoint_adminurl api_admin_endpoint.to_s
endpoint_internalurl api_internal_endpoint.to_s
endpoint_publicurl api_public_endpoint.to_s
action :create_endpoint
interfaces.each do |interface, res|
# Register Image Endpoints
openstack_endpoint 'image' do
service_name 'glance'
interface interface.to_s
url res[:url].to_s
region region
connection_params connection_params
end
end
# Register Service Tenant
openstack_identity_register 'Register Service Tenant' do
auth_uri auth_url
bootstrap_token token
tenant_name service_tenant_name
tenant_description 'Service Tenant'
tenant_enabled true # Not required as this is the default
action :create_tenant
openstack_project service_project do
connection_params connection_params
end
# Register Service User
openstack_identity_register "Register #{service_user} User" do
auth_uri auth_url
bootstrap_token token
tenant_name service_tenant_name
user_name service_user
user_pass service_pass
# String until https://review.openstack.org/#/c/29498/ merged
user_enabled true
action :create_user
openstack_user service_user do
project_name service_project
role_name service_role
password service_pass
connection_params connection_params
end
## Grant Service role to Service User for Service Tenant ##
openstack_identity_register "Grant '#{service_role}' Role to #{service_user} User for #{service_tenant_name} Tenant" do
auth_uri auth_url
bootstrap_token token
tenant_name service_tenant_name
user_name service_user
# Grant Service role to Service User for Service Tenant ##
openstack_user service_user do
role_name service_role
project_name service_project
connection_params connection_params
action :grant_role
end
# Grant default domain to user with role of Service Tenant ##
openstack_user service_user do
domain_name service_domain_name
role_name service_role
user_name service_user
connection_params connection_params
action :grant_domain
end

View File

@ -39,9 +39,13 @@ package 'curl' do
end
auth_uri = public_endpoint('identity').to_s
# admin_user = node['openstack']['image_api']['conf']['keystone_authtoken']['username']
# admin_pass = get_password admin_user, admin_pass
admin_user = node['openstack']['identity']['admin_user']
admin_pass = get_password 'user', admin_user
admin_tenant = node['openstack']['identity']['admin_tenant_name']
admin_project_name = node['openstack']['image_api']['conf']['keystone_authtoken']['project_name']
admin_project_domain_name = node['openstack']['image_api']['conf']['keystone_authtoken']['project_domain_name']
admin_domain = node['openstack']['image_api']['conf']['keystone_authtoken']['user_domain_name']
node['openstack']['image']['upload_images'].each do |img|
type = 'unknown'
@ -54,8 +58,10 @@ node['openstack']['image']['upload_images'].each do |img|
image_public true
identity_user admin_user
identity_pass admin_pass
identity_tenant admin_tenant
identity_tenant admin_project_name
identity_uri auth_uri
identity_user_domain_name admin_domain
identity_project_domain_name admin_project_domain_name
action :upload
end
end

View File

@ -31,7 +31,7 @@ end
identity_endpoint = public_endpoint 'identity'
swift_store_auth_address =
auth_uri_transform identity_endpoint.to_s, node['openstack']['api']['auth']['version']
tenant = node['openstack']['image_api']['conf']['keystone_authtoken']['tenant_name']
tenant = node['openstack']['image_api']['conf']['keystone_authtoken']['project']
user = node['openstack']['image_api']['conf']['keystone_authtoken']['user']
swift_store_user = "#{tenant}_#{user}"
swift_user_tenant = nil

View File

@ -37,3 +37,5 @@ attribute :identity_user, kind_of: String
attribute :identity_pass, kind_of: String
attribute :identity_tenant, kind_of: String
attribute :identity_uri, kind_of: String
attribute :identity_user_domain_name, kind_of: String
attribute :identity_project_domain_name, kind_of: String

View File

@ -97,13 +97,14 @@ describe 'openstack-image::api' do
it do
[
/^auth_type = v2password$/,
/^auth_type = v3password$/,
/^region_name = RegionOne$/,
/^username = glance$/,
/^tenant_name = service$/,
/^project_name = admin$/,
%r{^signing_dir = /var/cache/glance/api$},
%r{^auth_url = http://127.0.0.1:5000/v2.0$},
/^password = glance-pass$/
%r{^auth_url = http://127.0.0.1:5000/v3$},
/^password = glance-pass$/,
/^user_domain_name = Default$/
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('keystone_authtoken', line)

View File

@ -10,123 +10,85 @@ describe 'openstack-image::identity_registration' do
include_context 'image-stubs'
it 'registers image service' do
expect(chef_run).to create_service_openstack_identity_register('Register Image Service')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
service_description: 'Glance Image Service'
)
connection_params = {
openstack_auth_url: 'http://127.0.0.1:35357/v3/auth/tokens',
openstack_username: 'admin',
openstack_api_key: 'admin-pass',
openstack_project_name: 'admin',
openstack_domain_name: 'default'
}
service_name = 'glance'
service_type = 'image'
service_user = 'glance'
url = 'http://127.0.0.1:9292'
region = 'RegionOne'
project_name = 'admin'
role_name = 'admin'
password = 'glance-pass'
domain_name = 'Default'
it "registers #{project_name} Project" do
expect(chef_run).to create_openstack_project(
project_name
).with(
connection_params: connection_params
)
end
context 'registers compute endpoint' do
it 'with default values' do
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9292',
endpoint_internalurl: 'http://127.0.0.1:9292',
endpoint_publicurl: 'http://127.0.0.1:9292'
)
end
it 'with custom region override' do
node.set['openstack']['region'] = 'imageRegion'
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(endpoint_region: 'imageRegion')
end
it 'with different public url' do
public_url = 'https://public.host:123/public_path'
node.set['openstack']['endpoints']['public']['image_api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9292',
endpoint_internalurl: 'http://127.0.0.1:9292',
endpoint_publicurl: public_url
)
end
it 'with different admin url' do
admin_url = 'http://admin.host:456/admin_path'
node.set['openstack']['endpoints']['admin']['image_api']['uri'] = admin_url
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: 'http://127.0.0.1:9292',
endpoint_publicurl: 'http://127.0.0.1:9292'
)
end
it 'with different internal url' do
internal_url = 'http://internal.host:789/internal_path'
node.set['openstack']['endpoints']['internal']['image_api']['uri'] = internal_url
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9292',
endpoint_internalurl: internal_url,
endpoint_publicurl: 'http://127.0.0.1:9292'
)
end
it 'with different admin,internal,public urls' do
internal_url = 'http://internal.host:789/internal_path'
admin_url = 'http://admin.host:456/admin_path'
public_url = 'https://public.host:123/public_path'
node.set['openstack']['endpoints']['internal']['image_api']['uri'] = internal_url
node.set['openstack']['endpoints']['admin']['image_api']['uri'] = admin_url
node.set['openstack']['endpoints']['public']['image_api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register('Register Image Endpoint')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: public_url
)
end
it "registers #{service_name} service" do
expect(chef_run).to create_openstack_service(
service_name
).with(
connection_params: connection_params,
type: service_type
)
end
it 'registers service tenant' do
expect(chef_run).to create_tenant_openstack_identity_register('Register Service Tenant')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
tenant_description: 'Service Tenant',
tenant_enabled: true
)
context "registers #{service_name} endpoint" do
%w(admin internal public).each do |interface|
it "#{interface} endpoint with default values" do
expect(chef_run).to create_openstack_endpoint(
service_type
).with(
service_name: service_name,
# interface: interface,
url: url,
region: region,
connection_params: connection_params
)
end
end
end
it 'registers service user' do
expect(chef_run).to create_user_openstack_identity_register('Register glance User')
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'glance',
user_pass: 'glance-pass',
user_enabled: true
)
expect(chef_run).to create_openstack_user(
service_user
).with(
project_name: project_name,
role_name: role_name,
password: password,
connection_params: connection_params
)
end
it 'grants admin role to service user for service tenant' do
expect(chef_run).to grant_role_openstack_identity_register("Grant 'admin' Role to glance User for service Tenant")
.with(auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
role_name: 'admin',
user_name: 'glance'
)
it do
expect(chef_run).to grant_domain_openstack_user(
service_user
).with(
domain_name: domain_name,
role_name: role_name,
connection_params: connection_params
)
end
it do
expect(chef_run).to grant_role_openstack_user(
service_user
).with(
project_name: project_name,
role_name: role_name,
password: password,
connection_params: connection_params
)
end
end

View File

@ -12,12 +12,12 @@ describe 'openstack-image::image_upload' do
include_context 'image-stubs'
it do
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep cirros').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return(false)
expect(chef_run).to upgrade_package('curl')
end
it 'uploads the cirros image' do
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep cirros').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return(false)
expect(chef_run).to upload_openstack_image_image('Image setup for cirros').with(
image_url: 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img',
image_name: 'cirros',
@ -26,7 +26,7 @@ describe 'openstack-image::image_upload' do
identity_user: 'admin',
identity_pass: 'admin-pass',
identity_tenant: 'admin',
identity_uri: 'http://127.0.0.1:5000/v2.0'
identity_uri: 'http://127.0.0.1:5000/v3'
)
end
@ -39,7 +39,7 @@ describe 'openstack-image::image_upload' do
it 'uploads the tar image' do
node.set['openstack']['image']['upload_images'] = ['imageName']
node.set['openstack']['image']['upload_image']['imageName'] = 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz'
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep imageName').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep imageName').and_return(false)
expect(chef_run).to upload_openstack_image_image('Image setup for imageName').with(
image_url: 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz',
image_name: 'imageName',
@ -53,12 +53,12 @@ describe 'openstack-image::image_upload' do
it "uploads the #{image_type} image" do
node.set['openstack']['image']['upload_images'] = ["#{image_type}_imageName"]
node.set['openstack']['image']['upload_image']["#{image_type}_imageName"] = "image_file.#{image_type}"
node.set['openstack']['image']['upload_image_type']["#{image_type}_imageName"] = image_type
stub_command("glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep #{image_type}_imageName").and_return(false)
node.set['openstack']['image']['upload_image_type']["#{image_type}_imageName"] = image_type.to_s
stub_command("glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep #{image_type}_imageName").and_return(false)
expect(chef_run).to upload_openstack_image_image("Image setup for #{image_type}_imageName").with(
image_url: "image_file.#{image_type}",
image_name: "#{image_type}_imageName",
image_type: image_type,
image_type: image_type.to_s,
image_public: true
)
end
@ -70,8 +70,8 @@ describe 'openstack-image::image_upload' do
node.set['openstack']['image']['upload_image_type']['raw_imageName'] = 'raw'
node.set['openstack']['image']['upload_image']['vdi_imageName'] = 'image_file.vdi'
node.set['openstack']['image']['upload_image_type']['vdi_imageName'] = 'vdi'
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep raw_imageName').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-tenant-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep vdi_imageName').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep raw_imageName').and_return(false)
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep vdi_imageName').and_return(false)
expect(chef_run).to upload_openstack_image_image('Image setup for raw_imageName').with(
image_url: 'image_file.raw',
image_name: 'raw_imageName',

View File

@ -88,12 +88,13 @@ describe 'openstack-image::registry' do
it do
[
/^auth_type = v2password$/,
/^auth_type = v3password$/,
/^region_name = RegionOne$/,
/^username = glance$/,
/^tenant_name = service$/,
/^project_name = service/,
%r{^signing_dir = /var/cache/glance/registry},
%r{^auth_url = http://127.0.0.1:5000/v2.0},
%r{^auth_url = http://127.0.0.1:5000/v3},
/^user_domain_name = Default$/,
/^password = glance-pass$/
].each do |line|
expect(chef_run).to render_config_file(file.name)

View File

@ -62,7 +62,7 @@ shared_context 'image-stubs' do
.and_return('admin-pass')
allow(Chef::Application).to receive(:fatal!)
stub_command('glance --insecure --os-username glance --os-password glance-pass --os-tenant-name service --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v2.0 image-list | grep cirros').and_return('')
stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return('')
end
end
@ -169,7 +169,7 @@ end
shared_examples 'keystone attribute setter' do |version|
it 'sets the auth_uri value' do
expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$})
expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v3$})
end
it 'sets the identity_uri value' do
@ -177,13 +177,13 @@ shared_examples 'keystone attribute setter' do |version|
end
context 'auth version' do
it 'shows the version attribute if it is different from v2.0' do
it 'shows the version attribute if it is different from v3' do
node.set['openstack']['api']['auth']['version'] = 'v3.0'
expect(chef_run).to render_file(file.name).with_content(/^auth_version = v3.0$/)
end
end
%w(tenant_name user).each do |attr|
%w(project user).each do |attr|
it "sets the auth admin #{attr} attribute" do
node.set['openstack']["image-#{version}"]['conf']['keystone_authtoken']["admin_#{attr}"] = "service_#{attr}_value"
expect(chef_run).to render_file(file.name).with_content(/^admin_#{attr} = service_#{attr}_value$/)