summaryrefslogtreecommitdiffstats
path: root/meta-openstack/classes/openstackchef.bbclass
diff options
context:
space:
mode:
authorMustapha Lansana <Mustapha.Lansana@windriver.com>2014-07-30 19:08:55 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-09-26 09:09:21 -0400
commitcaf76c8322f247d0829dc9a18009bee0b1195a06 (patch)
tree84751c17810440a9e560d486f57d9dc16074faf1 /meta-openstack/classes/openstackchef.bbclass
parentef4a3055abee950950c2aac127854eb9e83f2793 (diff)
downloadmeta-cloud-services-caf76c8322f247d0829dc9a18009bee0b1195a06.tar.gz
openstackchef: decentralized openstack-chef class implementation
This class provides a framework for recipes(packages) to register their configuration files with the deploychef package. This class works together with the deploychef package. This implementation makes it possible for the deploychef package, with the help of chef-solo, to recreate registered configuration files at run-time. Only services that inherit this class and register their configuration files are re-configurable at run-time; and by configurable, we mean to make chefsolo templates out of their configuration files and to be aware of the list of daemons that need to be killed/started at run-time. Therefore, openstackchef class requires the recipes/classes inheriting it to advertise their configuration files, list of start/stop daemons and finally a special callback function when necessary. In order to avoid duplication of common placeholders and substitution across the various recipes inheriting this class, we keep a dictionary of common placeholders and substitutions, but rely on the recipes to define the values these placeholders take at run-time. See the description at the top of the class files (openstackchef.bbclass and openstackchef_inc.bbclass ) for more details. This class makes chef-solo template files out of the configuration files exposed to it by the recipes. The resulting templates are stored at /opt/deploychef/cookbooks/openstack/templates/default. on the resulting rootfs. It also creates a file containing a set of chef-solo default template values known as attributes in chef-solo world. The default values are provided by the recipes and classes inheriting this class. The chefsolo attributes file is stored at /opt/deploychef/cookbooks/openstack/attributes/default.rb at the end of rootfs creation process. At run-time, the deploychef package whose package files are stored at '/opt/deploychef', makes a call to chef-solo. Chef-solo in turn uses the attributes and templates files to overwrite the configuration files for services like neutron, nova, swift, etc.. that registered configuration files with openstackchef class at build time. See accompanying documentation for further explanation. Signed-off-by: Mustapha Lansana <Mustapha.Lansana@windriver.com>
Diffstat (limited to 'meta-openstack/classes/openstackchef.bbclass')
-rw-r--r--meta-openstack/classes/openstackchef.bbclass115
1 files changed, 115 insertions, 0 deletions
diff --git a/meta-openstack/classes/openstackchef.bbclass b/meta-openstack/classes/openstackchef.bbclass
new file mode 100644
index 0000000..c2e4a40
--- /dev/null
+++ b/meta-openstack/classes/openstackchef.bbclass
@@ -0,0 +1,115 @@
1# openstackchef.bbclass
2# Copyright (c) 2014 Wind River Systems, Inc.
3#
4# Permission is hereby granted, free of charge, to any person obtaining a copy
5# of this software and associated documentation files (the "Software"), to
6# deal
7# in the Software without restriction, including without limitation the rights
8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9# copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20# FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23#
24#
25# This class provides a framework for openstack services like python-neutron
26# or python-nova to register their configuration files so that they can be
27# recreated at run-time by chef-solo. Inheriting
28# this class involves exposing configuration files from which this class
29# creates chef-solo templates. These template files are later used by chef-solo
30# to recreate the configuration files.
31#
32# For the templates files to be created, the recipes are expected
33# to define the following variables variables:
34#
35# SRCNAME:
36# This is the name of the package, neutron for example for the package
37# python-neutron. It's appended to the names of template files and also
38# used in the creation of package based temporary files. A default value
39# of ${BPN} is assigned to this variable when it's not defined by recipes
40# inheriting class.
41#
42# CHEF_SERVICES_CONF_FILES
43#
44# This variable provides the list of configuration files
45# exposed to this class by the recipes inheriting the class.
46# These files are expected to be in the image( ${D}) directory, though ${D}
47# directory is excluded from the file name. Definition of this variable
48# by recipe files is optional.
49# eg.
50# CHEF_SERVICES_CONF_FILES="\
51# ${sysconfdir}/chef/neutron/plugins/linuxbridge/linuxbridge_conf.ini.rb \
52# ${sysconfdir}/chef/neutron/neutron.conf
53# "
54#
55#INITSCRIPT_PACKAGES
56#This variable provides a mechanism for recipes inheriting this class
57#to provide a list of services to start/stop when their configuration files
58#are recreated on disk.
59#This variable is assumed to be provided by all recipes that register a set
60#of configuration files with this class. Failing to do so will lead to
61#service not reloading the newly created configuration file(s) at run-time.
62#
63#
64#INITSCRIPT_NAME_x or INITSCRIPT_NAME
65#This variable is also assumed to be set by recipes inheriting this class.
66#It specifies the names of the services to start/stop as specified above.
67#Like the variable immediately above, failure to provide this variable will
68#lead to mis-configuration of the service at run-time.
69#
70#
71#INITSCRIPT_PARAMS_x or INITSCRIPT_PARAMS
72#Like the last two variable above, this variable is also assumed to be set
73#by recipes inheriting this class. It is used to extract the run-level
74#priority of the INITSCRIPT_NAME variable(s). Unlike, the previous two
75#variables, a default run-level is assigned to the script when this variable
76#defaults to the string 'default'
77#
78#
79# CHEF_SERVICES_SPECIAL_FUNC
80# This variable is optional, and is the name of a shell callback function.
81# Unlike the placeholder/value substitution which this class does,
82# there are times when recipes need to do more than a simple placeholder/
83# value substitution. This is made possible with the use of the callback
84# function.
85# The callback function should be defined by the recipe(s) inheriting
86# this class. When this variable is defined, this class will call the
87# callback function and pass it the name of the file to manipulate
88# in the form of the variable CHEF_SERVICES_FILE_NAME. This variable
89# is then accessed in the callback function in the recipe file as
90# ${CHEF_SERVICES_FILE_NAME}
91#
92inherit hosts openstackchef_inc
93
94#Call this function after the do_install function have executed in
95#recipes inheriting this class, this ensures that we get configuration
96#files that have been moved to the images directory
97addtask deploychef_install before do_package after do_install
98python do_deploychef_install() {
99 if deploychef_not_rootfs_class(d) and \
100 deploychef_openstackchef_enabled(d):
101 #copy configuration files from packages inheriting class
102 template_files_tuple = deploychef_copy_conf_files(d)
103 #convert configuration files into templates for chefsolo
104 deploychef_make_templates( d, template_files_tuple)
105 #Generate a list of startup/shutdown services
106 deploychef_make_startup_shutdown_list(d)
107}
108
109#Use of ROOTFS_POSTPROCESS_COMMAND enables us to hook into the post
110#rootfs creation process and influence the work of openstack_configure_hosts.
111#However, to ensure that our function deploychef_rootfs_postprocess_commands
112#is called after openstack_configure_hosts and not before it,
113#we add it in front of our callback function here.
114ROOTFS_POSTPROCESS_COMMAND += "openstack_configure_hosts ; deploychef_rootfs_postprocess_commands ; "
115