diff options
Diffstat (limited to 'meta-openstack/classes/openstackchef.bbclass')
| -rw-r--r-- | meta-openstack/classes/openstackchef.bbclass | 115 |
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 | # | ||
| 92 | inherit 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 | ||
| 97 | addtask deploychef_install before do_package after do_install | ||
| 98 | python 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. | ||
| 114 | ROOTFS_POSTPROCESS_COMMAND += "openstack_configure_hosts ; deploychef_rootfs_postprocess_commands ; " | ||
| 115 | |||
