initial basic setup

This first commit will install all the services and has full test
coverage. Everything is SUSE-specific for now, but the attributes were
setup so that other platforms can be easily added.

Change-Id: I33be4d259130f479a558d365d8abbbe78df17f44
This commit is contained in:
Ionuț Arțăriși 2014-06-16 18:49:28 +02:00
parent 9b1b9ed024
commit 37ec31e12d
24 changed files with 1441 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.bundle/
.cookbooks/
.kitchen
.vagrant
.coverage/
*.swp
Berksfile.lock
Vagrantfile

24
.rubocop.yml Normal file
View File

@ -0,0 +1,24 @@
AllCops:
Includes:
- metadata.rb
- Gemfile
- attributes/**
- libraries/**
- providers/**
- recipes/**
- resources/**
- spec/**
Encoding:
Exclude:
- metadata.rb
- Gemfile
NumericLiterals:
Enabled: false
LineLength:
Enabled: false
WordArray:
MinSize: 3

6
Berksfile Normal file
View File

@ -0,0 +1,6 @@
metadata
cookbook "openstack-common",
git: "git://github.com/stackforge/cookbook-openstack-common.git"
cookbook "openstack-identity",
git: "git://github.com/stackforge/cookbook-openstack-identity.git"

11
CHANGELOG.md Normal file
View File

@ -0,0 +1,11 @@
# CHANGELOG for cookbook-openstack-database
This file is used to list changes made in each version of the cookbook-openstack-database.
## 9.0.0
* Initial release of cookbook-openstack-database for Icehouse
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.

10
Gemfile Normal file
View File

@ -0,0 +1,10 @@
source 'https://rubygems.org'
gem 'chef', '~> 11.8'
gem 'json', '<= 1.7.7' # chef 11 dependency
gem 'berkshelf', '~> 2.0.10'
gem 'chefspec', '~> 3.4.0'
gem 'fauxhai', '>= 2.1.0'
gem 'foodcritic', '~> 4.0.0'
gem 'rubocop', '~> 0.18.1'
gem 'strainer'

236
Gemfile.lock Normal file
View File

@ -0,0 +1,236 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.16)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.3.5)
akami (1.2.0)
gyoku (>= 0.4.0)
nokogiri (>= 1.4.0)
ast (1.1.0)
berkshelf (2.0.10)
activesupport (~> 3.2.0)
addressable (~> 2.3.4)
buff-shell_out (~> 0.1)
chozo (>= 0.6.1)
faraday (>= 0.8.5)
hashie (>= 2.0.2)
minitar (~> 0.5.4)
rbzip2 (~> 0.2.0)
retryable (~> 1.3.3)
ridley (~> 1.5.0)
solve (>= 0.5.0)
thor (~> 0.18.0)
buff-config (0.4.0)
buff-extensions (~> 0.3)
varia_model (~> 0.1)
buff-extensions (0.5.0)
buff-ignore (1.1.1)
buff-platform (0.1.0)
buff-ruby_engine (0.1.0)
buff-shell_out (0.1.1)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2)
celluloid (0.14.1)
timers (>= 1.0.0)
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.8.2)
chef-zero (~> 1.6, >= 1.6.2)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
highline (~> 1.6, >= 1.6.9)
json (>= 1.4.4, <= 1.7.7)
mime-types (~> 1.16)
mixlib-authentication (~> 1.3)
mixlib-cli (~> 1.3)
mixlib-config (~> 2.0)
mixlib-log (~> 1.3)
mixlib-shellout (~> 1.2)
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1.0)
ohai (~> 6.0)
pry (~> 0.9)
puma (~> 1.6)
rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1)
chef-zero (1.7.2)
hashie (~> 2.0)
json
mixlib-log (~> 1.3)
moneta (< 0.7.0)
rack
chefspec (3.4.0)
chef (~> 11.0)
fauxhai (~> 2.0)
rspec (~> 2.14)
chozo (0.6.1)
activesupport (>= 3.2.0)
hashie (>= 2.0.2)
multi_json (>= 1.3.0)
coderay (1.1.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.8.8)
multipart-post (~> 1.2.0)
fauxhai (2.1.0)
net-ssh
ohai
ffi (1.9.3)
foodcritic (4.0.0)
erubis
gherkin (~> 2.11)
nokogiri (~> 1.5)
rake
rufus-lru (~> 1.0)
treetop (~> 1.4)
yajl-ruby (~> 1.1)
gherkin (2.12.2)
multi_json (~> 1.3)
gssapi (1.0.3)
ffi (>= 1.0.1)
gyoku (1.1.0)
builder (>= 2.1.2)
hashie (2.0.5)
highline (1.6.20)
httpclient (2.3.4.1)
httpi (0.9.7)
rack
i18n (0.6.9)
ipaddress (0.8.0)
json (1.7.7)
little-plugger (1.1.3)
logging (1.8.1)
little-plugger (>= 1.1.3)
multi_json (>= 1.3.6)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.4.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.3.0)
moneta (0.6.0)
multi_json (1.8.2)
multipart-post (1.2.0)
net-http-persistent (2.9)
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
nio4r (0.5.0)
nokogiri (1.5.10)
nori (1.1.5)
ohai (6.20.0)
ipaddress
mixlib-cli
mixlib-config
mixlib-log
mixlib-shellout
systemu (~> 2.5.2)
yajl-ruby
parser (2.1.7)
ast (~> 1.1)
slop (~> 3.4, >= 3.4.5)
polyglot (0.3.5)
powerpack (0.0.9)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puma (1.6.3)
rack (~> 1.2)
rack (1.5.2)
rainbow (2.0.0)
rake (10.3.2)
rbzip2 (0.2.0)
rest-client (1.6.7)
mime-types (>= 1.16)
retryable (1.3.3)
ridley (1.5.3)
addressable
buff-config (~> 0.2)
buff-extensions (~> 0.3)
buff-ignore (~> 1.1)
buff-shell_out (~> 0.1)
celluloid (~> 0.14.0)
celluloid-io (~> 0.14.0)
erubis
faraday (>= 0.8.4)
hashie (>= 2.0.2)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0)
net-http-persistent (>= 2.8)
net-ssh
nio4r (>= 0.5.0)
retryable
solve (>= 0.4.4)
varia_model (~> 0.1)
winrm (~> 1.1.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rubocop (0.18.1)
json (>= 1.7.7, < 2)
parser (~> 2.1.3)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
rubyntlm (0.1.1)
rufus-lru (1.0.5)
savon (0.9.5)
akami (~> 1.0)
builder (>= 2.1.2)
gyoku (>= 0.4.0)
httpi (~> 0.9)
nokogiri (>= 1.4.0)
nori (~> 1.0)
wasabi (~> 1.0)
slop (3.4.7)
solve (0.8.2)
strainer (3.3.0)
berkshelf (~> 2.0)
buff-platform (~> 0.1)
systemu (2.5.2)
thor (0.18.1)
timers (1.1.0)
treetop (1.5.3)
polyglot (~> 0.3)
uuidtools (2.1.4)
varia_model (0.2.0)
buff-extensions (~> 0.2)
hashie (>= 2.0.2)
wasabi (1.0.0)
nokogiri (>= 1.4.0)
winrm (1.1.3)
gssapi (~> 1.0.0)
httpclient (~> 2.2, >= 2.2.0.2)
logging (~> 1.6, >= 1.6.1)
nokogiri (~> 1.5)
rubyntlm (~> 0.1.1)
savon (= 0.9.5)
uuidtools (~> 2.1.2)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
berkshelf (~> 2.0.10)
chef (~> 11.8)
chefspec (~> 3.4.0)
fauxhai (>= 2.1.0)
foodcritic (~> 4.0.0)
json (<= 1.7.7)
rubocop (~> 0.18.1)
strainer

71
README.md Normal file
View File

@ -0,0 +1,71 @@
Description
===========
Installs the OpenStack Database service **Trove** as part of the
OpenStack reference deployment Chef for OpenStack. Trove is currently
installed from packages.
https://wiki.openstack.org/wiki/Trove
Requirements
============
Chef 11
Cookbooks
---------
The following cookbooks are dependencies:
* openstack-common
* openstack-identity
Usage
=====
api
----
- Installs the API service.
conductor
----
- Installs conductor service.
taskmanager
----
- Installs the taskmanager service.
identity_registration
----
- Registers the endpoints with Keystone.
Attributes
==========
Testing
=====
Please refer to the [TESTING.md](TESTING.md) for instructions for testing the cookbook.
License and Author
==================
| | |
|:---------------------|:---------------------------------------------------|
| **Author** | Ionut Artarisi (<iartarisi@suse.cz>) |
| | |
| **Copyright** | Copyright (c) 2013-2014, SUSE Linux GmbH |
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

5
Strainerfile Normal file
View File

@ -0,0 +1,5 @@
# Strainerfile
rubocop: rubocop $SANDBOX/$COOKBOOK
knife test: knife cookbook test $COOKBOOK
foodcritic: foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
chefspec: rspec $SANDBOX/$COOKBOOK/spec

42
TESTING.md Normal file
View File

@ -0,0 +1,42 @@
# Testing the Cookbook #
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
Tests are defined in [Strainerfile](Strainerfile), which in turn calls rubocop, knife, foodcritic and chefspec.
To run all of the tests with Strainer:
$ bundle exec strainer test -s Strainerfile
Or you may run the tests individually:
$ bundle install --path=.bundle # install gem dependencies
$ bundle exec berks install --path=.cookbooks # install cookbook dependencies
$ bundle exec strainer test -s Strainerfile # run tests
## Rubocop ##
[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.
### Attribute Rules ###
Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
[Gemfile and metadata.rb](.rubocop.yml)
[attributes/*.rb](attributes/.rubocop.yml)
[recipes/.rubocop.yml](recipes/.rubocop.yml)
[spec/.rubocop.yml](spec/.rubocop.yml)
## Knife ##
[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors.
## Foodcritic ##
[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules:
[FC003](http://acrmp.github.io/foodcritic/#FC003) these cookbooks are not intended for Chef Solo.
## Chefspec
[ChefSpec](http://code.sethvargo.com/chefspec/) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.

60
attributes/default.rb Normal file
View File

@ -0,0 +1,60 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-database
# Recipe:: default
#
# Copyright 2013-2014 SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set to some text value if you want templated config files
# to contain a custom banner at the top of the written file
default['openstack']['database']['custom_template_banner'] = '
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
'
default['openstack']['database']['verbose'] = false
default['openstack']['database']['debug'] = false
default['openstack']['database']['syslog']['use'] = false
default['openstack']['database']['user'] = 'trove'
default['openstack']['database']['group'] = 'trove'
case platform
when 'suse'
default['openstack']['database']['platform'] = {
'api_packages' => ['openstack-trove-api'],
'api_service' => 'openstack-trove-api',
'conductor_packages' => ['openstack-trove-conductor'],
'conductor_service' => 'openstack-trove-conductor',
'taskmanager_packages' => ['openstack-trove-taskmanager'],
'taskmanager_service' => 'openstack-trove-taskmanager'
}
end
default['openstack']['database']['service_user'] = 'trove'
default['openstack']['database']['service_role'] = 'admin'
default['openstack']['database']['service_tenant_name'] = 'service'
default['openstack']['database']['region'] = node['openstack']['region']
default['openstack']['database']['volume_support'] = true
# Keystone PKI signing directory
default['openstack']['database']['api']['auth']['cache_dir'] = '/var/cache/trove/api'
default['openstack']['database']['nova_proxy_user'] = 'admin'
default['openstack']['database']['nova_proxy_password'] = 'admin'
default['openstack']['database']['nova_proxy_tenant'] = 'admin'

17
metadata.rb Normal file
View File

@ -0,0 +1,17 @@
name 'openstack-database'
maintainer 'SUSE Linux GmbH'
maintainer_email 'crowbar@dell.com'
license 'Apache 2.0'
description 'Installs/Configures trove'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '9.0.0'
recipe 'openstack-database::identity_registration', 'Registers Trove endpoints and service with Keystone'
recipe 'openstack-database::api', 'Installs API service'
recipe 'openstack-database::conductor', 'Installs Conductor service'
recipe 'openstack-database::taskmanager', 'Installs TaskManager service'
recipe 'openstack-database::guestagent', 'Installs GuestAgent service'
depends 'openstack-common', '~> 9.0'
depends 'openstack-identity', '~> 9.0'
supports 'suse'

100
recipes/api.rb Normal file
View File

@ -0,0 +1,100 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-database
# Recipe:: api
#
# Copyright 2013-2014, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
if node['openstack']['database']['syslog']['use']
include_recipe 'openstack-common::logging'
end
platform_options = node['openstack']['database']['platform']
platform_options['api_packages'].each do |pkg|
package pkg
end
service 'trove-api' do
service_name platform_options['api_service']
supports status: true, restart: true
action [:enable]
end
db_user = node['openstack']['db']['database']['username']
db_pass = get_password 'db', 'openstack-database'
db_uri = db_uri('database', db_user, db_pass).to_s
api_endpoint = endpoint 'database-api'
identity_uri = endpoint('identity-api')
compute_uri = endpoint('compute-api').to_s.gsub(/%\(tenant_id\)s/, '')
block_storage_uri = endpoint('block-storage-api').to_s.gsub(/%\(tenant_id\)s/, '')
object_storage_uri = endpoint('object-storage-api')
rabbit = node['openstack']['mq']['database']['rabbit']
rabbit_pass = get_password('user', rabbit['userid'])
template '/etc/trove/trove.conf' do
source 'trove.conf.erb'
owner node['openstack']['database']['user']
group node['openstack']['database']['group']
mode 00640
variables(
database_connection: db_uri,
endpoint: api_endpoint,
rabbit: rabbit,
rabbit_pass: rabbit_pass,
identity_uri: identity_uri,
compute_uri: compute_uri,
block_storage_uri: block_storage_uri,
object_storage_uri: object_storage_uri
)
notifies :restart, 'service[trove-api]', :immediately
end
admin_token = secret 'secrets', 'openstack_identity_bootstrap_token'
identity_admin_uri = endpoint('identity-admin')
directory ::File.dirname(node['openstack']['database']['api']['auth']['cache_dir']) do
owner node['openstack']['database']['user']
group node['openstack']['database']['group']
mode 00700
end
template '/etc/trove/api-paste.ini' do
source 'api-paste.ini.erb'
owner node['openstack']['database']['user']
group node['openstack']['database']['group']
mode 00640
variables(
identity_admin_uri: identity_admin_uri,
identity_uri: identity_uri,
admin_token: admin_token
)
notifies :restart, 'service[trove-api]', :immediately
end
execute 'trove-manage db_sync' do
notifies :restart, 'service[trove-api]', :immediately
end

57
recipes/conductor.rb Normal file
View File

@ -0,0 +1,57 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-database
# Recipe:: conductor
#
# Copyright 2013-2014, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
platform_options = node['openstack']['database']['platform']
platform_options['conductor_packages'].each do |pkg|
package pkg
end
service 'trove-conductor' do
service_name platform_options['conductor_service']
supports status: true, restart: true
action [:enable]
end
db_user = node['openstack']['db']['database']['username']
db_pass = get_password 'db', 'openstack-database'
db_uri = db_uri('database', db_user, db_pass).to_s
rabbit_pass = get_password(
'user', node['openstack']['mq']['database']['rabbit']['userid'])
identity_uri = endpoint('identity-api')
template '/etc/trove/trove-conductor.conf' do
source 'trove-conductor.conf.erb'
owner node['openstack']['database']['user']
group node['openstack']['database']['group']
mode 00640
variables(
database_connection: db_uri,
identity_uri: identity_uri,
rabbit_pass: rabbit_pass
)
notifies :restart, 'service[trove-conductor]', :immediately
end

View File

@ -0,0 +1,91 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-database
# Recipe:: identity_registration
#
# Copyright 2013-2014, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'uri'
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
identity_admin_endpoint = endpoint 'identity-admin'
bootstrap_token = get_secret 'openstack_identity_bootstrap_token'
auth_uri = ::URI.decode identity_admin_endpoint.to_s
service_pass = get_password 'service', 'openstack-database'
service_user = node['openstack']['database']['service_user']
service_role = node['openstack']['database']['service_role']
service_tenant_name = node['openstack']['database']['service_tenant_name']
database_service_api_endpoint = endpoint 'database-api'
region = node['openstack']['database']['region']
# Register Service Tenant
openstack_identity_register 'Register Service Tenant' do
auth_uri auth_uri
bootstrap_token bootstrap_token
tenant_name service_tenant_name
tenant_description 'Service Tenant'
action :create_tenant
end
# Register Service User
openstack_identity_register 'Register Service User' do
auth_uri auth_uri
bootstrap_token bootstrap_token
tenant_name service_tenant_name
user_name service_user
user_pass service_pass
action :create_user
end
## Grant Admin role to Service User for Service Tenant ##
openstack_identity_register "Grant '#{service_role}' Role to Service User for Service Tenant" do
auth_uri auth_uri
bootstrap_token bootstrap_token
tenant_name service_tenant_name
user_name service_user
role_name service_role
action :grant_role
end
# Register Database Service Service
openstack_identity_register 'Register Database Service' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_name 'trove'
service_type 'database'
service_description 'Trove Service'
action :create_service
end
# Register Database Service Endpoint
openstack_identity_register 'Register Database Endpoint' do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_type 'database'
endpoint_region region
endpoint_adminurl ::URI.decode database_service_api_endpoint.to_s
endpoint_internalurl ::URI.decode database_service_api_endpoint.to_s
endpoint_publicurl ::URI.decode database_service_api_endpoint.to_s
action :create_endpoint
end

66
recipes/taskmanager.rb Normal file
View File

@ -0,0 +1,66 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-database
# Recipe:: taskmanager
#
# Copyright 2013-2014, SUSE Linux GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
platform_options = node['openstack']['database']['platform']
platform_options['taskmanager_packages'].each do |pkg|
package pkg
end
service 'trove-taskmanager' do
service_name platform_options['taskmanager_service']
supports status: true, restart: true
action [:enable]
end
db_user = node['openstack']['db']['database']['username']
db_pass = get_password 'db', 'openstack-database'
db_uri = db_uri('database', db_user, db_pass).to_s
identity_uri = endpoint('identity-api')
compute_uri = endpoint('compute-api').to_s.gsub(/%\(tenant_id\)s/, '')
block_storage_uri = endpoint('block-storage-api').to_s.gsub(/%\(tenant_id\)s/, '')
object_storage_uri = endpoint('object-storage-api')
rabbit = node['openstack']['mq']['database']['rabbit']
rabbit_pass = get_password('user', rabbit['userid'])
template '/etc/trove/trove-taskmanager.conf' do
source 'trove-taskmanager.conf.erb'
owner node['openstack']['database']['user']
group node['openstack']['database']['group']
mode 00640
variables(
database_connection: db_uri,
rabbit: rabbit,
rabbit_pass: rabbit_pass,
identity_uri: identity_uri,
compute_uri: compute_uri,
block_storage_uri: block_storage_uri,
object_storage_uri: object_storage_uri
)
notifies :restart, 'service[trove-taskmanager]', :immediately
end

107
spec/api-suse_spec.rb Normal file
View File

@ -0,0 +1,107 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-database::api' do
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'database-stubs'
it 'installs the api packages' do
expect(chef_run).to install_package('openstack-trove-api')
end
it 'starts the api service' do
expect(chef_run).to enable_service('openstack-trove-api')
end
it 'includes the logging recipe if syslog is enabled' do
chef_run = ChefSpec::Runner.new(::SUSE_OPTS) do |node|
node.set['openstack']['database']['syslog']['use'] = true
end.converge('openstack-database::api')
expect(chef_run).to include_recipe 'openstack-common::logging'
end
it 'creates the /var/cache/trove directory' do
expect(chef_run).to create_directory('/var/cache/trove').with(
user: 'trove',
group: 'trove',
mode: 0700
)
end
describe 'trove.conf' do
let(:filename) { '/etc/trove/trove.conf' }
it 'creates trove.conf file' do
expect(chef_run).to create_template(filename).with(
user: 'trove',
group: 'trove',
mode: 0640
)
end
it 'has the default values for configurable attributes' do
[/^debug = false$/,
/^verbose = false$/,
%r{^sql_connection = mysql://trove:db-pass@127.0.0.1:3306/trove\?charset=utf8$},
/^bind_host = 127.0.0.1$/,
/^bind_port = 8779$/,
/^rabbit_host = 127.0.0.1$/,
/^rabbit_virtual_host = \/$/,
/^rabbit_port = 5672$/,
/^rabbit_userid = guest$/,
/^rabbit_password = rabbit-pass$/,
/^rabbit_use_ssl = false$/,
%r{^trove_auth_url = http://127.0.0.1:5000/v2.0$},
%r{^nova_compute_url = http://127.0.0.1:8774/v2/$},
%r{^cinder_url = http://127.0.0.1:8776/v1/$},
%r{^swift_url = http://127.0.0.1:8080/v1/$},
%r{^dns_auth_url = http://127.0.0.1:5000/v2.0$},
%r{^log_dir = /var/log/trove$},
/^trove_volume_support = true$/
].each do |content|
expect(chef_run).to render_file(filename).with_content(content)
end
end
end
describe 'api-paste.ini' do
let(:filename) { '/etc/trove/api-paste.ini' }
it 'creates the file' do
expect(chef_run).to create_template(filename).with(
user: 'trove',
group: 'trove',
mode: 0640
)
end
it 'has the default values for configurable attributes' do
[%r{^auth_uri = http://127.0.0.1:5000/v2.0$},
/^auth_host = 127.0.0.1$/,
/^auth_port = 35357$/,
/^auth_protocol = http$/,
%r{^signing_dir = /var/cache/trove/api$}
].each do |content|
expect(chef_run).to render_file(filename).with_content(content)
end
end
end
describe 'database initialization' do
let(:manage_cmd) { 'trove-manage db_sync' }
it 'runs trove-manage' do
expect(chef_run).to run_execute(manage_cmd)
end
it 'restarts the trove-api service' do
res = chef_run.execute(manage_cmd)
expect(res).to notify('service[trove-api]').to(:restart)
end
end
end

View File

@ -0,0 +1,39 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-database::conductor' do
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'database-stubs'
it 'installs the converge packages' do
expect(chef_run).to install_package('openstack-trove-conductor')
end
it 'starts the conductor service' do
expect(chef_run).to enable_service('openstack-trove-conductor')
end
describe 'trove-conductor.conf' do
let(:filename) { '/etc/trove/trove-conductor.conf' }
it 'creates the trove-conductor.conf file' do
expect(chef_run).to create_template(filename).with(
user: 'trove',
group: 'trove',
mode: 0640
)
end
it 'has the default values for configurable attributes' do
[%r{^sql_connection = mysql://trove:db-pass@127.0.0.1:3306/trove\?charset=utf8$},
%r{^trove_auth_url = http://127.0.0.1:5000/v2.0$}
].each do |content|
expect(chef_run).to render_file(filename).with_content(content)
end
end
end
end

View File

@ -0,0 +1,76 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-database::identity_registration' do
describe 'suse' do
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'database-stubs'
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'
)
end
it 'registers service user' do
expect(chef_run).to create_user_openstack_identity_register(
'Register Service User'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'trove',
user_pass: 'service-pass'
)
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 Service User for Service Tenant"
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'trove',
role_name: 'admin'
)
end
it 'registers database service' do
expect(chef_run).to create_service_openstack_identity_register(
'Register Database Service'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'trove',
service_type: 'database',
service_description: 'Trove Service'
)
end
context 'registers database endpoint' do
it 'with default values' do
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Database Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'database',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:8779/v1.0',
endpoint_internalurl: 'http://127.0.0.1:8779/v1.0',
endpoint_publicurl: 'http://127.0.0.1:8779/v1.0'
)
end
end
end
end

37
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,37 @@
# encoding: UTF-8
require 'chefspec'
require 'chefspec/berkshelf'
require 'chef/application'
::LOG_LEVEL = :fatal
::SUSE_OPTS = {
platform: 'suse',
version: '11.03',
log_level: ::LOG_LEVEL
}
::REDHAT_OPTS = {
platform: 'redhat',
version: '6.5',
log_level: ::LOG_LEVEL
}
::UBUNTU_OPTS = {
platform: 'ubuntu',
version: '12.04',
log_level: ::LOG_LEVEL
}
shared_context 'database-stubs' do
before do
Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'openstack_identity_bootstrap_token').and_return('bootstrap-token')
Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'guest').and_return('rabbit-pass')
Chef::Recipe.any_instance.stub(:get_password)
.with('db', 'openstack-database').and_return('db-pass')
Chef::Recipe.any_instance.stub(:get_password)
.with('service', 'openstack-database').and_return('service-pass')
Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'openstack-database').and_return('user-pass')
end
end

View File

@ -0,0 +1,52 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-database::taskmanager' do
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'database-stubs'
it 'installs the taskmanager packages' do
expect(chef_run).to install_package('openstack-trove-taskmanager')
end
it 'starts the taskmanager service' do
expect(chef_run).to enable_service('openstack-trove-taskmanager')
end
describe 'trove-taskmanager.conf' do
let(:filename) { '/etc/trove/trove-taskmanager.conf' }
it 'creates trove-taskmanager.conf file' do
expect(chef_run).to create_template(filename).with(
user: 'trove',
group: 'trove',
mode: 0640
)
end
it 'has the default values for configurable attributes' do
[/^debug = false$/,
/^verbose = false$/,
%r{^sql_connection = mysql://trove:db-pass@127.0.0.1:3306/trove\?charset=utf8},
/^rabbit_host = 127.0.0.1$/,
/^rabbit_virtual_host = \/$/,
/^rabbit_port = 5672$/,
/^rabbit_userid = guest$/,
/^rabbit_password = rabbit-pass$/,
/^rabbit_use_ssl = false$/,
%r{^trove_auth_url = http://127.0.0.1:5000/v2.0$},
%r{^nova_compute_url = http://127.0.0.1:8774/v2/$},
%r{^cinder_url = http://127.0.0.1:8776/v1/$},
%r{^swift_url = http://127.0.0.1:8080/v1/$},
%r{^dns_auth_url = http://127.0.0.1:5000/v2.0$},
%r{^log_dir = /var/log/trove}
].each do |content|
expect(chef_run).to render_file(filename).with_content(content)
end
end
end
end

View File

@ -0,0 +1,47 @@
<%= node["openstack"]["database"]["custom_template_banner"] %>
[composite:trove]
use = call:trove.common.wsgi:versioned_urlmap
/: versions
/v1.0: troveapi
[app:versions]
paste.app_factory = trove.versions:app_factory
[pipeline:troveapi]
pipeline = faultwrapper tokenauth authorization contextwrapper ratelimit extensions troveapp
#pipeline = debug extensions troveapp
[filter:extensions]
paste.filter_factory = trove.common.extensions:factory
[filter:tokenauth]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
auth_uri = <%= @identity_uri.to_s %>
auth_host = <%= @identity_admin_uri.host %>
auth_port = <%= @identity_admin_uri.port %>
auth_protocol = <%= @identity_admin_uri.scheme %>
admin_token = <%= @admin_token %>
# signing_dir is configurable, but the default behavior of the authtoken
# middleware should be sufficient. It will create a temporary directory
# in the home directory for the user the trove process is running as.
signing_dir = <%= node["openstack"]["database"]["api"]["auth"]["cache_dir"] %>
[filter:authorization]
paste.filter_factory = trove.common.auth:AuthorizationMiddleware.factory
[filter:contextwrapper]
paste.filter_factory = trove.common.wsgi:ContextMiddleware.factory
[filter:faultwrapper]
paste.filter_factory = trove.common.wsgi:FaultWrapper.factory
[filter:ratelimit]
paste.filter_factory = trove.common.limits:RateLimitingMiddleware.factory
[app:troveapp]
paste.app_factory = trove.common.api:app_factory
#Add this filter to log request and response for debugging
[filter:debug]
paste.filter_factory = trove.common.wsgi:Debug

View File

@ -0,0 +1,10 @@
<%= node["openstack"]["database"]["custom_template_banner"] %>
[DEFAULT]
control_exchange = trove
trove_auth_url = <%= @identity_uri %>
nova_proxy_admin_user = <%= node['openstack']['database']['nova_proxy_user'] %>
nova_proxy_admin_pass = <%= node['openstack']['database']['nova_proxy_password'] %>
nova_proxy_admin_tenant_name = <%= node['openstack']['database']['nova_proxy_tenant'] %>
sql_connection = <%= @database_connection %>
rabbit_password = <%= @rabbit_pass %>

View File

@ -0,0 +1,131 @@
<%= node["openstack"]["database"]["custom_template_banner"] %>
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = <%= node["openstack"]["database"]["verbose"] %>
# Show debugging output in logs (sets DEBUG log level output)
debug = <%= node["openstack"]["database"]["debug"] %>
# Updates service and instance task statuses if instance failed become active
update_status_on_fail = False
# AMQP Connection info
rabbit_host = <%= @rabbit['host'] %>
rabbit_userid = <%= @rabbit['userid'] %>
rabbit_password = <%= @rabbit_pass %>
rabbit_virtual_host = <%= @rabbit['vhost'] %>
rabbit_port = <%= @rabbit['port'] %>
rabbit_use_ssl = <%= @rabbit['use_ssl'] %>
rabbit_notification_topic = <%= @rabbit['notification_topic'] %>
# SQLAlchemy connection string for the reference implementation
# registry server. Any valid SQLAlchemy connection string is fine.
# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
sql_connection = <%= @database_connection %>
# sql_connection = mysql://root:root@localhost/trove
# Period in seconds after which SQLAlchemy should reestablish its connection
# to the database.
#
# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
# notice this, you can lower this value to ensure that SQLAlchemy reconnects
# before MySQL can drop the connection.
sql_idle_timeout = 3600
#DB Api Implementation
db_api_implementation = trove.db.sqlalchemy.api
# Configuration options for talking to nova via the novaclient.
trove_auth_url = <%= @identity_uri %>
nova_compute_url = <%= @compute_uri %>
cinder_url = <%= @block_storage_uri %>
swift_url = <%= @object_storage_uri %>
# Config options for enabling volume service
trove_volume_support = True
block_device_mapping = vdb
device_path = /dev/vdb
mount_point = /var/lib/mysql
volume_time_out=30
server_delete_time_out=480
# Configuration options for talking to nova via the novaclient.
# These options are for an admin user in your keystone config.
# It proxy's the token received from the user to send to nova via this admin users creds,
# basically acting like the client via that proxy token.
nova_proxy_admin_user = <%= node['openstack']['database']['nova_proxy_user'] %>
nova_proxy_admin_pass = <%= node['openstack']['database']['nova_proxy_password'] %>
nova_proxy_admin_tenant_name = <%= node['openstack']['database']['nova_proxy_tenant'] %>
# Manager impl for the taskmanager
taskmanager_manager=trove.taskmanager.manager.Manager
# Manager sends Exists Notifications
exists_notification_transformer = trove.extensions.mgmt.instances.models.NovaNotificationTransformer
exists_notification_ticks = 30
notification_service_id = mysql:2f3ff068-2bfb-4f70-9a9d-a6bb65bc084b
# Trove DNS
trove_dns_support = False
dns_account_id = 123456
dns_auth_url = http://127.0.0.1:5000/v2.0
dns_username = user
dns_passkey = password
dns_ttl = 3600
dns_domain_name = 'trove.com.'
dns_domain_id = 11111111-1111-1111-1111-111111111111
dns_driver = trove.dns.designate.driver.DesignateDriver
dns_instance_entry_factory = trove.dns.designate.driver.DesignateInstanceEntryFactory
dns_endpoint_url = http://127.0.0.1/v1/
dns_service_type = dns
# Trove Security Groups for Instances
trove_security_groups_support = True
trove_security_groups_rules_support = False
trove_security_group_rule_protocol = tcp
trove_security_group_rule_port = 3306
trove_security_group_rule_cidr = 0.0.0.0/0
# Guest related conf
agent_heartbeat_time = 10
agent_call_low_timeout = 5
agent_call_high_timeout = 150
# Whether to use nova's contrib api for create server with volume
use_nova_server_volume = False
# Datastore templates
template_path = /etc/trove/templates/
# ============ notifer queue kombu connection options ========================
notifier_queue_transport = memory
# usage notifications
notification_driver=trove.openstack.common.notifier.rpc_notifier
control_exchange=trove
# ============ Logging information =============================
log_dir = /var/log/trove
#log_file = trove-taskmanager.log
# ============ PyDev remote dubugging =============================
# Enable or disable pydev remote debugging.
# There are three values allowed: 'disabled', 'enabled' and 'auto'
# If value is 'auto' tries to connect to remote debugger server,
# but in case of error continue running with disabled debugging
pydev_debug = disabled
# remote debug server host and port options
#pydev_debug_host = localhost
#pydev_debug_port = 5678
# path to pydevd library. It will be used if pydevd is absent in sys.path
#pydev_path = <path>
# ================= Guestagent related ========================
#guest_config = $pybasedir/etc/trove/trove-guestagent.conf.sample
#cloudinit_location = /etc/trove/cloudinit

View File

@ -0,0 +1,138 @@
<%= node["openstack"]["database"]["custom_template_banner"] %>
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = <%= node["openstack"]["database"]["verbose"] %>
# Show debugging output in logs (sets DEBUG log level output)
debug = <%= node["openstack"]["database"]["debug"] %>
# Address to bind the API server
bind_host = <%= @endpoint.host %>
# Port the bind the API server to
bind_port = <%= @endpoint.port %>
# Number of child processes to run
#trove_api_workers=5
# AMQP Connection info
rabbit_host = <%= @rabbit['host'] %>
rabbit_userid = <%= @rabbit['userid'] %>
rabbit_password = <%= @rabbit_pass %>
rabbit_virtual_host = <%= @rabbit['vhost'] %>
rabbit_port = <%= @rabbit['port'] %>
rabbit_use_ssl = <%= @rabbit['use_ssl'] %>
rabbit_notification_topic = <%= @rabbit['notification_topic'] %>
# SQLAlchemy connection string for the reference implementation
# registry server. Any valid SQLAlchemy connection string is fine.
# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
# sql_connection = sqlite:///trove_test.sqlite
sql_connection = <%= @database_connection %>
#sql_connection = postgresql://trove:trove@localhost/trove
# Period in seconds after which SQLAlchemy should reestablish its connection
# to the database.
#
# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
# notice this, you can lower this value to ensure that SQLAlchemy reconnects
# before MySQL can drop the connection.
sql_idle_timeout = 3600
#DB Api Implementation
db_api_implementation = "trove.db.sqlalchemy.api"
# Path to the extensions
api_extensions_path = trove/extensions/routes
# Configuration options for talking to nova via the novaclient.
trove_auth_url = <%= @identity_uri %>
nova_compute_url = <%= @compute_uri %>
cinder_url = <%= @block_storage_uri %>
swift_url = <%= @object_storage_uri %>
# Config option for showing the IP address that nova doles out
add_addresses = True
network_label_regex = ^private$
#ip_regex = ^(15.|123.)
# Config options for enabling volume service
trove_volume_support = <%= node['openstack']['database']['volume_support'] %>
block_device_mapping = vdb
device_path = /dev/vdb
mount_point = /var/lib/mysql
max_accepted_volume_size = 10
max_instances_per_user = 5
max_volumes_per_user = 100
max_backups_per_user = 5
volume_time_out=30
# Config options for rate limits
http_get_rate = 200
http_post_rate = 200
http_put_rate = 200
http_delete_rate = 200
# Trove DNS
trove_dns_support = False
dns_account_id = 123456
dns_auth_url = <%= @identity_uri %>
dns_username = user
dns_passkey = password
dns_ttl = 3600
dns_domain_name = 'trove.com.'
dns_domain_id = 11111111-1111-1111-1111-111111111111
dns_driver = trove.dns.designate.driver.DesignateDriver
dns_instance_entry_factory = trove.dns.designate.driver.DesignateInstanceEntryFactory
dns_endpoint_url = http://127.0.0.1/v1/
dns_service_type = dns
# Taskmanager queue name
taskmanager_queue = taskmanager
# Auth
admin_roles = admin
root_on_create = False
# Users to ignore for user create/list/delete operations
ignore_users = os_admin, root
ignore_dbs = lost+found, mysql, information_schema
# Guest related conf
agent_heartbeat_time = 10
agent_call_low_timeout = 5
agent_call_high_timeout = 150
# Reboot time out for instances
reboot_time_out = 60
# Trove api-paste file name
api_paste_config = api-paste.ini
# ============ notifer queue kombu connection options ========================
notifier_queue_transport = memory
control_exchange = trove
# ============ Logging information =============================
log_dir = /var/log/trove
#log_file = trove-api.log
# ============ SSL configuration (and enablement) =============================
# In order to enable SSL for the trove api server, uncomment
# the cert_file and key_file - and of course have those files
# accessible. The existance of those setting and files will
# enable SSL.
[ssl]
#cert_file = /path/to/server.crt
#key_file = /path/to/server.key
#optional:
#ca_file = /path/to/ca_file