From b23d78ca58c54251138a9edabeaab3982e4eebc8 Mon Sep 17 00:00:00 2001 From: Mustapha Lansana Date: Wed, 30 Jul 2014 21:36:33 -0400 Subject: cinder/glance/neutron: support for openstackchef class Openstackchef enables us to recreate configuration files for services in an openstack installation. It does this by creating template file(s) out of openstack services' configuration file(s) exposed to it. The following services are inheriting the openstack class and then exposing a set of configuration files to the class. The configuration files are assumed to have been installed in the image in the service's WORKDIR and are exposed to openstackchef by assigning them to the variable CHEF_SERVICES_CONF_FILES. For legacy reasons, the string OPENSTACKCHEF_ENABLED is defined in openstackchef class, but it can be overwritten to an empty string in a .bb, .class, .bbapend or local.conf file when openstackchef support is not desired. This enables all of these services to be built without openstackchef support. In addition, it prevents the recipes for these sevices from substituting the placeholders in their configuration files when inheriting openstackchef. However, since services like python-glance and python-cinder install some of their configuration files to the image directory during the substitution, it means that these files at not installed when the substitutions are not required. Therefore, we have taken the liberty to install those missing configuration files before the check for whether or not substitutions should be made, without having any side effect on when the substitutions are required. At build-time, openstackchef makes chef-solo templates out of the registered files. And at run-time, the deploychef package makes a call to chef-solo, which in-turn use the template files to recreate the registered configuration files. In making template files out of configuration files, openstackchef makes a simple placeholder/value substitution in the configuration files. However, it provides a mechanism for services inheriting the class to define a special shell callback function which can do more than a simple placeholder/value substitution. This special callback function is exposed to openstackchef by assigning it to the variable CHEF_SERVICES_SPECIAL_FUNC. And the name of the file passed back to the shell callback function as an argument is set to the variable CHEF_SERVICES_FILE_NAME by openstackchef. In this patch set, only python-neutron and python-glance recipe files makes special substitutions. Signed-off-by: Mustapha Lansana --- .../recipes-devtools/python/python-neutron_git.bb | 67 ++++++++++++++-------- 1 file changed, 43 insertions(+), 24 deletions(-) (limited to 'meta-openstack/recipes-devtools/python/python-neutron_git.bb') diff --git a/meta-openstack/recipes-devtools/python/python-neutron_git.bb b/meta-openstack/recipes-devtools/python/python-neutron_git.bb index 295db97..f961487 100644 --- a/meta-openstack/recipes-devtools/python/python-neutron_git.bb +++ b/meta-openstack/recipes-devtools/python/python-neutron_git.bb @@ -25,7 +25,7 @@ PV="2014.2.b3+git${SRCPV}" S = "${WORKDIR}/git" -inherit setuptools update-rc.d identity hosts default_configs +inherit setuptools update-rc.d identity hosts default_configs openstackchef SERVICECREATE_PACKAGES = "${SRCNAME}-setup" KEYSTONE_HOST="${CONTROLLER_IP}" @@ -60,11 +60,11 @@ do_install_append() { install -m 600 ${S}/etc/api-paste.ini ${NEUTRON_CONF_DIR}/ install -m 600 ${S}/etc/policy.json ${NEUTRON_CONF_DIR}/ - sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \ - -i ${NEUTRON_CONF_DIR}/neutron.conf - sed -e "s:%SERVICE_USER%:${SRCNAME}:g" -i ${NEUTRON_CONF_DIR}/neutron.conf - sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \ - -i ${NEUTRON_CONF_DIR}/neutron.conf + #sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \ + # -i ${NEUTRON_CONF_DIR}/neutron.conf + #sed -e "s:%SERVICE_USER%:${SRCNAME}:g" -i ${NEUTRON_CONF_DIR}/neutron.conf + #sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \ + # -i ${NEUTRON_CONF_DIR}/neutron.conf sed -e "s:^# core_plugin.*:core_plugin = neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2:g" \ -i ${NEUTRON_CONF_DIR}/neutron.conf @@ -74,15 +74,7 @@ do_install_append() { sed -e "s:^# notify_nova_on_port_data_changes.*:notify_nova_on_port_data_changes = False:g" \ -i ${NEUTRON_CONF_DIR}/neutron.conf - sed -e "s:^# rabbit_host =.*:rabbit_host = ${CONTROLLER_IP}:" -i ${NEUTRON_CONF_DIR}/neutron.conf - - for file in plugins/openvswitch/ovs_neutron_plugin.ini plugins/linuxbridge/linuxbridge_conf.ini - do - sed -e "s:%DB_USER%:${DB_USER}:g" -i ${NEUTRON_CONF_DIR}/${file} - sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${NEUTRON_CONF_DIR}/${file} - sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${NEUTRON_CONF_DIR}/${file} - sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${NEUTRON_CONF_DIR}/${file} - done + sed -e "s:^# rabbit_host =.*:rabbit_host = %CONTROLLER_IP%:" -i ${NEUTRON_CONF_DIR}/neutron.conf PLUGIN=openvswitch ARGS="--config-file=${sysconfdir}/${SRCNAME}/neutron.conf --config-file=${sysconfdir}/${SRCNAME}/plugins/openvswitch/ovs_neutron_plugin.ini" @@ -121,15 +113,23 @@ do_install_append() { install -m 0755 ${WORKDIR}/neutron-$AGENT.init.sh ${D}${sysconfdir}/init.d/neutron-$AGENT-agent install -m 600 ${WORKDIR}/${AGENT}_agent.ini ${NEUTRON_CONF_DIR}/ fi - sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \ - -i ${NEUTRON_CONF_DIR}/metadata_agent.ini - sed -e "s:%SERVICE_USER%:${SRCNAME}:g" \ - -i ${NEUTRON_CONF_DIR}/metadata_agent.ini - sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \ - -i ${NEUTRON_CONF_DIR}/metadata_agent.ini - sed -e "s:%METADATA_SHARED_SECRET%:${METADATA_SHARED_SECRET}:g" \ - -i ${NEUTRON_CONF_DIR}/metadata_agent.ini - + if [ -z "${OPENSTACKCHEF_ENABLED}" ]; then + for file in plugins/openvswitch/ovs_neutron_plugin.ini \ + plugins/linuxbridge/linuxbridge_conf.ini neutron.conf metadata_agent.ini; do + sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \ + -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%SERVICE_USER%:${SRCNAME}:g" \ + -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \ + -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%METADATA_SHARED_SECRET%:${METADATA_SHARED_SECRET}:g" \ + -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%DB_USER%:${DB_USER}:g" -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${NEUTRON_CONF_DIR}/$file + sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${NEUTRON_CONF_DIR}/$file + done + fi sed -e "s:^auth_host.*:#auth_host:g" -i ${NEUTRON_CONF_DIR}/neutron.conf sed -e "s:^auth_port.*:#auth_port:g" -i ${NEUTRON_CONF_DIR}/neutron.conf sed -e "s:^auth_protocol.*:#auth_protocol:g" -i ${NEUTRON_CONF_DIR}/neutron.conf @@ -157,6 +157,25 @@ pkg_postinst_${SRCNAME}-setup () { --config-file /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini upgrade head } +CHEF_SERVICES_CONF_FILES := " \ + ${sysconfdir}/${SRCNAME}/neutron.conf \ + ${sysconfdir}/${SRCNAME}/metadata_agent.ini \ + ${sysconfdir}/${SRCNAME}/plugins/openvswitch/ovs_neutron_plugin.ini \ + ${sysconfdir}/${SRCNAME}/plugins/linuxbridge/linuxbridge_conf.ini \ + " +deploychef_services_special_func(){ + #This function is a callback function for the deploychef .bbclass + #We define this special callback funtion because we are doing + #more than a placeholder substitution. The variable CHEF_SERVICES_FILE_NAME + #is defined in deploychef_framework.bbclass + if [ -n "${CHEF_SERVICES_FILE_NAME}" ]; then + sed "s:^# rabbit_host =.*:rabbit_host = %CONTROLLER_IP%:" -i \ + ${CHEF_SERVICES_FILE_NAME} + fi +} + +CHEF_SERVICES_SPECIAL_FUNC := "deploychef_services_special_func" + pkg_postinst_${SRCNAME}-plugin-openvswitch-setup () { if [ "x$D" != "x" ]; then exit 1 -- cgit v1.2.3-54-g00ecf