Merge pull request #42 from Mirantis/bogdando/cinder_api_puppet

Bogdando/cinder api puppet
This commit is contained in:
Łukasz Oleś 2015-07-23 15:32:42 +02:00
commit a72ccb8019
6 changed files with 261 additions and 0 deletions

View File

@ -259,6 +259,15 @@ def deploy():
signals.connect(keystone_puppet, cinder_keystone_service_endpoint, {
'admin_port': 'keystone_admin_port', 'admin_token': 'admin_token'})
# CINDER API
cinder_api_puppet = vr.create('cinder_api_puppet', 'resources/cinder_api_puppet', {})[0]
signals.connect(node1, cinder_api_puppet)
signals.connect(cinder_puppet, cinder_api_puppet, {
'keystone_password', 'keystone_tenant', 'keystone_user'})
signals.connect(cinder_puppet, cinder_api_puppet, {
'keystone_host': 'keystone_auth_host',
'keystone_port': 'keystone_auth_port'})
# NOVA
# #nova_network_puppet = vr.create('nova_network_puppet', GitProvider(GIT_PUPPET_LIBS_URL, 'nova_network'), {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0]
# # TODO: fix rabbitmq user/password
@ -328,6 +337,7 @@ def deploy():
actions.resource_action(cinder_keystone_role, 'run')
actions.resource_action(cinder_puppet, 'run')
actions.resource_action(cinder_keystone_service_endpoint, 'run')
actions.resource_action(cinder_api_puppet, 'run')
# actions.resource_action(nova_keystone_user, 'run')
# actions.resource_action(nova_keystone_role, 'run')
@ -343,6 +353,7 @@ def undeploy():
db = get_db()
to_remove = [
'cinder_api_puppet',
'cinder_keystone_service_endpoint',
'cinder_puppet',
'cinder_keystone_role',

View File

@ -0,0 +1,98 @@
# Cinder API resource for puppet handler
Setup and configure the cinder API endpoint
## Parameters
source https://github.com/openstack/puppet-cinder/blob/5.1.0/manifests/api.pp
``keystone_password``
The password to use for authentication (keystone)
``keystone_enabled``
(optional) Use keystone for authentification
Defaults to true
``keystone_tenant``
(optional) The tenant of the auth user
Defaults to services
``keystone_user``
(optional) The name of the auth user
Defaults to cinder
``keystone_auth_host``
(optional) The keystone host
Defaults to localhost
``keystone_auth_port``
(optional) The keystone auth port
Defaults to 35357
``keystone_auth_protocol``
(optional) The protocol used to access the auth host
Defaults to http.
``os_region_name``
(optional) Some operations require cinder to make API requests
to Nova. This sets the keystone region to be used for these
requests. For example, boot-from-volume.
Defaults to undef.
``keystone_auth_admin_prefix``
(optional) The admin_prefix used to admin endpoint of the auth host
This allow admin auth URIs like http://auth_host:35357/keystone.
(where '/keystone' is the admin prefix)
Defaults to false for empty. If defined, should be a string with a
leading '/' and no trailing '/'.
``service_port``
(optional) The cinder api port
Defaults to 5000
``service_workers``
(optional) Number of cinder-api workers
Defaults to $::processorcount
``package_ensure``
(optional) The state of the package
Defaults to present
``bind_host``
(optional) The cinder api bind address
Defaults to 0.0.0.0
``ratelimits``
(optional) The state of the service
Defaults to undef. If undefined the default ratelimiting values are used.
``ratelimits_factory``
(optional) Factory to use for ratelimiting
Defaults to 'cinder.api.v1.limits:RateLimitingMiddleware.factory'
``default_volume_type``
(optional) default volume type to use.
This should contain the name of the default volume type to use.
If not configured, it produces an error when creating a volume
without specifying a type.
Defaults to 'false'.
``validate``
(optional) Whether to validate the service is working after any service refreshes
Defaults to false
``validation_options``
(optional) Service validation options
Should be a hash of options defined in openstacklib::service_validation
If empty, defaults values are taken from openstacklib function.
Default command list volumes.
Require validate set at True.
Example:
glance::api::validation_options:
glance-api:
command: check_cinder-api.py
path: /usr/bin:/bin:/usr/sbin:/sbin
provider: shell
tries: 5
try_sleep: 10
Defaults to {}

View File

@ -0,0 +1,12 @@
class {'cinder::api':
enabled => false,
package_ensure => 'absent',
keystone_password => 'not important as removed',
}
include cinder::params
package { 'cinder':
ensure => 'absent',
name => $::cinder::params::package_name,
}

View File

@ -0,0 +1,52 @@
$resource = hiera($::resource_name)
$keystone_password = $resource['input']['keystone_password']['value']
$keystone_enabled = $resource['input']['keystone_enabled']['value']
$keystone_tenant = $resource['input']['keystone_tenant']['value']
$keystone_user = $resource['input']['keystone_user']['value']
$keystone_auth_host = $resource['input']['keystone_auth_host']['value']
$keystone_auth_port = $resource['input']['keystone_auth_port']['value']
$keystone_auth_protocol = $resource['input']['keystone_auth_protocol']['value']
$keystone_auth_admin_prefix = $resource['input']['keystone_auth_admin_prefix']['value']
$keystone_auth_uri = $resource['input']['keystone_auth_uri']['value']
$os_region_name = $resource['input']['os_region_name']['value']
$service_port = $resource['input']['service_port']['value']
$service_workers = $resource['input']['service_workers']['value']
$package_ensure = $resource['input']['package_ensure']['value']
$bind_host = $resource['input']['bind_host']['value']
$ratelimits = $resource['input']['ratelimits']['value']
$default_volume_type = $resource['input']['default_volume_type']['value']
$ratelimits_factory = $resource['input']['ratelimits_factory']['value']
$validate = $resource['input']['validate']['value']
$validation_options = $resource['input']['validation_options']['value']
include cinder::params
package { 'cinder':
ensure => $package_ensure,
name => $::cinder::params::package_name,
} ->
class {'cinder::api':
keystone_password => $keystone_password,
keystone_enabled => $keystone_enabled,
keystone_tenant => $keystone_tenant,
keystone_user => $keystone_user,
keystone_auth_host => $keystone_auth_host,
keystone_auth_port => $keystone_auth_port,
keystone_auth_protocol => $keystone_auth_protocol,
keystone_auth_admin_prefix => $keystone_auth_admin_prefix,
keystone_auth_uri => $keystone_auth_uri,
os_region_name => $os_region_name,
service_port => $service_port,
service_workers => $service_workers,
package_ensure => $package_ensure,
bind_host => $bind_host,
enabled => true,
manage_service => true,
ratelimits => $ratelimits,
default_volume_type => $default_volume_type,
ratelimits_factory => $ratelimits_factory,
validate => $validate,
validation_options => $validation_options,
}

View File

@ -0,0 +1,78 @@
id: cinder_api_puppet
handler: puppet
puppet_module: cinder_api
version: 1.0.0
input:
keystone_password:
schema: str!
value: 'keystone'
keystone_enabled:
schema: bool
value: true
keystone_tenant:
schema: str
value: 'services'
keystone_user:
schema: str
value: 'cinder'
keystone_auth_host:
schema: str
value: 'localhost'
keystone_auth_port:
schema: int
value: 35357
keystone_auth_protocol:
schema: str
value: 'http'
keystone_auth_admin_prefix:
schema: bool
value: false
keystone_auth_uri:
schema: bool
value: false
os_region_name:
schema: str
value: ''
service_port:
schema: int
value: 5000
service_workers:
schema: int
value: 1
package_ensure:
schema: str
value: 'present'
bind_host:
schema: str
value: '0.0.0.0'
ratelimits:
schema: str
value: ''
default_volume_type:
schema: bool
value: false
ratelimits_factory:
schema: str
value: 'cinder.api.v1.limits:RateLimitingMiddleware.factory'
validate:
schema: bool
value: false
validation_options:
schema: {}
value: {}
git:
schema: {repository: str!, branch: str!}
value: {repository: 'https://github.com/openstack/puppet-cinder', branch: '5.1.0'}
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:
tags: [resource/cinder_api_service, resources/cinder_api, resources/cinder]

View File

@ -0,0 +1,10 @@
import requests
from solar.core.log import log
def test(resource):
log.debug('Testing cinder_api_puppet')
requests.get(
'http://%s:%s' % (resource.args['ip'].value, resource.args['port'].value)
)