Split api.conf file into fragments

This commit splits the api.conf template into
fragments to better allow for logical separation
for configuration sections.

The main motivation for this change is to allow
differrent implementations of services in glance to
be split up into seperate configuration interfaces.

The primary examples of this are the notifier and
the storage backend. Each of these services have
multiple potential implementations. This allows
those implementations to be implemented as separate
class interfaces and saves us from having to have
all of the possible config parameters to be specified
as parameters of the api class.

It creates a define: glance::api::config that can
used to configure file fragments for
/etc/glance/glance-api.conf

It also creates configuration interfaces for
configuring the following config sections of api:
backend::swift, backend::file, notify::qpid,
notify::rabbitmq.
This commit is contained in:
Dan Bode
2012-03-31 16:01:42 -07:00
parent e9361dbaa6
commit 6c29550dcb
15 changed files with 332 additions and 0 deletions

20
manifests/api/config.pp Normal file
View File

@@ -0,0 +1,20 @@
#
# Can be used to specify configuration
# sections in glance-api.conf
#
# It will assume that the config
#
#
define glance::api::config(
$config = {},
$file_name = regsubst($name, ':', '_', 'G'),
$content = template("glance/api/${name}.erb"),
$order = undef
) {
concat::fragment { $name:
target => '/etc/glance/glance-api.conf',
content => $content,
order => $order,
}
}

15
manifests/backend.pp Normal file
View File

@@ -0,0 +1,15 @@
#
# used to model the line in the file
# that configures which storage backend
# to use
#
class glance::backend(
$default_store
) {
glance::api::config { 'backend':
config => {
'default_store' => $default_store
},
order => '02',
}
}

23
manifests/backend/file.pp Normal file
View File

@@ -0,0 +1,23 @@
#
# used to configure file backends for glance
#
# $filesystem_store_datadir - Location where dist images are stored when
# default_store == file.
# Optional. Default: /var/lib/glance/images/
class glance::backend::file(
$filesystem_store_datadir = '/var/lib/glance/images/'
) inherits glance::api {
# set file as default store
class { 'glance::backend':
default_store => 'file',
}
# configure directory where files should be stored
glance::api::config { 'file':
config => {
'filesystem_store_datadir' => $filesystem_store_datadir
},
order => '05',
}
}

View File

@@ -0,0 +1,40 @@
#
# configures the storage backend for glance
# as a swift instance
#
# $swift_store_auth_address - Optional. Default: '127.0.0.1:8080/v1.0/',
#
# $swift_store_user - Optional. Default:'jdoe',
#
# $swift_store_key - Optional. Default: 'a86850deb2742ec3cb41518e26aa2d89',
#
# $swift_store_container - 'glance',
#
# $swift_store_create_container_on_put - 'False'
class glance::backend::swift(
$swift_store_user,
$swift_store_key,
$swift_store_auth_address = '127.0.0.1:8080/v1.0/',
$swift_store_container = 'glance',
$swift_store_create_container_on_put = 'False',
) inherits glance::api {
# specify swift as backend
class { 'glance::backend':
default_store => 'swift',
}
glance::api::config { 'swift':
config => {
'swift_store_user' => $swift_store_user,
'swift_store_key' => $swift_store_key,
'swift_store_auth_address' => $swift_store_auth_address,
'swift_store_container' => $swift_store_container,
'swift_store_create_container_on_put' => $swift_store_create_container_on_put
},
order => '05',
# this just needs to configure a section
# in glance-api.conf
}
}

15
manifests/notify.pp Normal file
View File

@@ -0,0 +1,15 @@
#
# used to model the line in the file
# that configures which storage backend
# to use
#
class glance::notify(
$notifier_strategy
) {
glance::api::config { 'notify':
config => {
'notifier_strategy' => $notifier_strategy,
},
order => '06',
}
}

16
manifests/notify/qpid.pp Normal file
View File

@@ -0,0 +1,16 @@
#
# used to configure qpid notifications for glance
#
class glance::notify::qpid(
) inherits glance::api {
class { 'glance::notify':
notifier_strategy => 'qpid',
}
glance::api::config { 'qpid':
config => {
},
order => '07',
}
}

View File

@@ -0,0 +1,17 @@
#
# used to configure qpid notifications for glance
#
class glance::notify::rabbitmq(
# TODO be able to pass in rabbitmq params
) inherits glance::api {
class { 'glance::notify':
notifier_strategy => 'rabbit',
}
glance::api::config { 'rabbitmq':
config => {
},
order => '07',
}
}

View File

@@ -0,0 +1,5 @@
# Which backend store should Glance use by default is not specified
# in a request to add a new image to Glance? Default: 'file'
# Available choices are 'file', 'swift', and 's3'
# ================= Storage Backend ============================
default_store = <%= config['default_store'] %>

5
templates/api/file.erb Normal file
View File

@@ -0,0 +1,5 @@
# ============ Filesystem Store Options ========================
# Directory that the Filesystem backend store
# writes image data to
filesystem_store_datadir = <%= config['filesystem_store_datadir'] %>

21
templates/api/footer.erb Normal file
View File

@@ -0,0 +1,21 @@
# ============ Delayed Delete Options =============================
# Turn on/off delayed delete
delayed_delete = False
# Delayed delete time in seconds
scrub_time = 43200
# Directory that the scrubber will use to remind itself of what to delete
# Make sure this is also set in glance-scrubber.conf
scrubber_datadir = /var/lib/glance/scrubber
# =============== Image Cache Options =============================
# Base directory that the Image Cache uses
image_cache_dir = /var/lib/glance/image-cache/
<% if config['auth_type'] == 'keystone' -%>
[paste_deploy]
flavor = keystone
<% end -%>

82
templates/api/header.erb Normal file
View File

@@ -0,0 +1,82 @@
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = <%= config['log_verbose'] %>
# Show debugging output in logs (sets DEBUG log level output)
debug = <%= config['log_debug'] %>
# Address to bind the API server
bind_host = <%= config['bind_host'] %>
# Port the bind the API server to
bind_port = <%= config['bind_port'] %>
# Log to this file. Make sure you do not set the same log
# file for both the API and registry servers!
log_file = <%= config['log_file'] %>
# Backlog requests when creating socket
backlog = <%= config['backlog'] %>
# Backlog requests when creating socket
# Number of Glance API worker processes to start.
# On machines with more than one CPU increasing this value
# may improve performance (especially if using SSL with
# compression turned on). It is typically recommended to set
# this value to the number of CPUs present on your machine.
workers = <%= config['workers'] %>
# Role used to identify an authenticated user as administrator
#admin_role = admin
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
use_syslog = False
# Facility to use. If unset defaults to LOG_USER.
# syslog_log_facility = LOG_LOCAL0
# ================= SSL Options ===============================
# Certificate file to use when starting API server securely
# cert_file = /path/to/certfile
# Private key file to use when starting API server securely
# key_file = /path/to/keyfile
# ================= Security Options ==========================
# AES key for encrypting store 'location' metadata, including
# -- if used -- Swift or S3 credentials
# Should be set to a random string of length 16, 24 or 32 bytes
# metadata_encryption_key = <16, 24 or 32 char registry metadata key>
# ============ Registry Options ===============================
# Address to find the registry server
registry_host = <%= config['registry_host'] %>
# Port the registry server is listening on
registry_port = <%= config['registry_port'] %>
# What protocol to use when connecting to the registry server?
# Set to https for secure HTTP communication
registry_client_protocol = http
# The path to the key file to use in SSL connections to the
# registry server, if any. Alternately, you may set the
# GLANCE_CLIENT_KEY_FILE environ variable to a filepath of the key file
# registry_client_key_file = /path/to/key/file
# The path to the cert file to use in SSL connections to the
# registry server, if any. Alternately, you may set the
# GLANCE_CLIENT_CERT_FILE environ variable to a filepath of the cert file
# registry_client_cert_file = /path/to/cert/file
# The path to the certifying authority cert file to use in SSL connections
# to the registry server, if any. Alternately, you may set the
# GLANCE_CLIENT_CA_FILE environ variable to a filepath of the CA cert file
# registry_client_ca_file = /path/to/ca/file

7
templates/api/notify.erb Normal file
View File

@@ -0,0 +1,7 @@
# ============ Notification System Options =====================
# Notifications can be sent when images are create, updated or deleted.
# There are three methods of sending notifications, logging (via the
# log_file directive), rabbit (via a rabbitmq queue), qpid (via a Qpid
# message queue), or noop (no notifications sent, the default)
notifier_strategy = <%= config['notifier_strategy'] %>

18
templates/api/qpid.erb Normal file
View File

@@ -0,0 +1,18 @@
# Configuration options if sending notifications via Qpid (these are
# the defaults)
#qpid_notification_exchange = glance
#qpid_notification_topic = glance_notifications
#qpid_host = localhost
#qpid_port = 5672
#qpid_username =
#qpid_password =
#qpid_sasl_mechanisms =
#qpid_reconnect_timeout = 0
#qpid_reconnect_limit = 0
#qpid_reconnect_interval_min = 0
#qpid_reconnect_interval_max = 0
#qpid_reconnect_interval = 0
#qpid_heartbeat = 5
# Set to 'ssl' to enable SSL
#qpid_protocol = tcp
#qpid_tcp_nodelay = True

View File

@@ -0,0 +1,10 @@
# Configuration options if sending notifications via rabbitmq (these are
# the defaults)
#rabbit_host = localhost
#rabbit_port = 5672
#rabbit_use_ssl = false
#rabbit_userid = guest
#rabbit_password = guest
#rabbit_virtual_host = /
#rabbit_notification_exchange = glance
#rabbit_notification_topic = glance_notifications

38
templates/api/swift.erb Normal file
View File

@@ -0,0 +1,38 @@
# ============ Swift Store Options =============================
# Address where the Swift authentication service lives
swift_store_auth_address = <%= config['swift_store_auth_address'] %>
# User to authenticate against the Swift authentication service
swift_store_user = <%= config['swift_store_user'] %>
# Auth key for the user authenticating against the
# Swift authentication service
swift_store_key = <%= config['swift_store_key'] %>
# Container within the account that the account should use
# for storing images in Swift
swift_store_container = <%= config['swift_store_container'] %>
# Do we create the container if it does not exist?
swift_store_create_container_on_put = <%= config['swift_store_create_container_on_put'] %>
# What size, in MB, should Glance start chunking image files
# and do a large object manifest in Swift? By default, this is
# the maximum object size in Swift, which is 5GB
swift_store_large_object_size = 5120
# When doing a large object manifest, what size, in MB, should
# Glance write chunks to Swift? This amount of data is written
# to a temporary disk buffer during the process of chunking
# the image file, and the default is 200MB
swift_store_large_object_chunk_size = 200
# Whether to use ServiceNET to communicate with the Swift storage servers.
# (If you aren't RACKSPACE, leave this False!)
#
# To use ServiceNET for authentication, prefix hostname of
# `swift_store_auth_address` with 'snet-'.
# Ex. https://example.com/v1.0/ -> https://snet-example.com/v1.0/
swift_enable_snet = False