From 3d88a92666c8a1bb356d5510ca70652059ef4959 Mon Sep 17 00:00:00 2001 From: Martin Magr Date: Wed, 14 Aug 2013 15:13:06 +0200 Subject: [PATCH] Support for Ceilometer installation. - Added puppet-ceilometer and puppetlabs-mongodb modules - Added Ceilometer plugin Fixes: rhbz#967310 Change-Id: Ib1f42faf78a75af32232994f8e40acbdac318b4d --- .gitmodules | 6 + packstack/plugins/ceilometer_800.py | 103 ++++++++++++++++++ packstack/plugins/cinder_250.py | 6 +- packstack/plugins/glance_200.py | 2 + packstack/plugins/nova_300.py | 3 + packstack/plugins/prescript_000.py | 12 ++ packstack/plugins/puppet_950.py | 16 +-- packstack/puppet/modules/ceilometer | 1 + packstack/puppet/modules/mongodb | 1 + packstack/puppet/templates/ceilometer.pp | 44 ++++++++ .../puppet/templates/cinder_ceilometer.pp | 4 + .../puppet/templates/glance_ceilometer.pp | 4 + .../puppet/templates/keystone_ceilometer.pp | 7 ++ packstack/puppet/templates/nova_ceilometer.pp | 20 ++++ 14 files changed, 219 insertions(+), 10 deletions(-) create mode 100644 packstack/plugins/ceilometer_800.py create mode 160000 packstack/puppet/modules/ceilometer create mode 160000 packstack/puppet/modules/mongodb create mode 100644 packstack/puppet/templates/ceilometer.pp create mode 100644 packstack/puppet/templates/cinder_ceilometer.pp create mode 100644 packstack/puppet/templates/glance_ceilometer.pp create mode 100644 packstack/puppet/templates/keystone_ceilometer.pp create mode 100644 packstack/puppet/templates/nova_ceilometer.pp diff --git a/.gitmodules b/.gitmodules index 8feeff746..1537cb216 100644 --- a/.gitmodules +++ b/.gitmodules @@ -76,3 +76,9 @@ [submodule "packstack/puppet/modules/haproxy"] path = packstack/puppet/modules/haproxy url = https://github.com/puppetlabs/puppetlabs-haproxy.git +[submodule "packstack/puppet/modules/ceilometer"] + path = packstack/puppet/modules/ceilometer + url = https://github.com/packstack/puppet-ceilometer.git +[submodule "packstack/puppet/modules/mongodb"] + path = packstack/puppet/modules/mongodb + url = https://github.com/puppetlabs/puppetlabs-mongodb.git diff --git a/packstack/plugins/ceilometer_800.py b/packstack/plugins/ceilometer_800.py new file mode 100644 index 000000000..946852f3d --- /dev/null +++ b/packstack/plugins/ceilometer_800.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- + +""" +Installs and configures Ceilometer +""" + +import logging +import os +import uuid + +from packstack.installer import utils +from packstack.installer import validators +from packstack.modules.ospluginutils import (getManifestTemplate, + appendManifestFile) + +# Controller object will be initialized from main flow +controller = None + +# Plugin name +PLUGIN_NAME = "OS-Ceilometer" +PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') + +logging.debug("plugin %s loaded", __name__) + + +def initConfig(controllerObject): + global controller + controller = controllerObject + logging.debug("Adding OpenStack Ceilometer configuration") + paramsList = [ + {"CMD_OPTION" : "ceilometer-host", + "USAGE" : ("The IP address of the server on which " + "to install Ceilometer"), + "PROMPT" : ("Enter the IP address of the Ceilometer " + "server"), + "OPTION_LIST" : [], + "VALIDATORS" : [validators.validate_ssh], + "DEFAULT_VALUE" : utils.get_localhost_ip(), + "MASK_INPUT" : False, + "LOOSE_VALIDATION": True, + "CONF_NAME" : "CONFIG_CEILOMETER_HOST", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False}, + + {"CMD_OPTION" : "ceilometer-secret", + "USAGE" : "Secret key for signing metering messages.", + "PROMPT" : "Enter the Ceilometer secret key", + "OPTION_LIST" : [], + "VALIDATORS" : [validators.validate_not_empty], + "DEFAULT_VALUE" : uuid.uuid4().hex[:16], + "MASK_INPUT" : True, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "CONFIG_CEILOMETER_SECRET", + "USE_DEFAULT" : True, + "NEED_CONFIRM" : True, + "CONDITION" : False}, + + {"CMD_OPTION" : "ceilometer-ks-passwd", + "USAGE" : "The password to use for Ceilometer to authenticate with Keystone", + "PROMPT" : "Enter the password for the Ceilometer Keystone access", + "OPTION_LIST" : [], + "VALIDATORS" : [validators.validate_not_empty], + "DEFAULT_VALUE" : uuid.uuid4().hex[:16], + "MASK_INPUT" : True, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "CONFIG_CEILOMETER_KS_PW", + "USE_DEFAULT" : True, + "NEED_CONFIRM" : True, + "CONDITION" : False}, + ] + + groupDict = {"GROUP_NAME" : "CEILOMETER", + "DESCRIPTION" : "Ceilometer Config parameters", + "PRE_CONDITION" : "CONFIG_CEILOMETER_INSTALL", + "PRE_CONDITION_MATCH" : "y", + "POST_CONDITION" : False, + "POST_CONDITION_MATCH": True} + controller.addGroup(groupDict, paramsList) + + +def initSequences(controller): + if controller.CONF['CONFIG_CEILOMETER_INSTALL'] != 'y': + return + + steps = [{'title': 'Adding Ceilometer manifest entries', + 'functions': [create_manifest]}, + {'title': 'Adding Ceilometer Keystone manifest entries', + 'functions': [create_keystone_manifest]}] + controller.addSequence("Installing OpenStack Ceilometer",[], [], + steps) + + +def create_manifest(config): + manifestfile = "%s_ceilometer.pp" % config['CONFIG_CEILOMETER_HOST'] + manifestdata = getManifestTemplate("ceilometer.pp") + appendManifestFile(manifestfile, manifestdata) + + +def create_keystone_manifest(config): + manifestfile = "%s_keystone.pp" % config['CONFIG_KEYSTONE_HOST'] + manifestdata = getManifestTemplate("keystone_ceilometer.pp") + appendManifestFile(manifestfile, manifestdata) diff --git a/packstack/plugins/cinder_250.py b/packstack/plugins/cinder_250.py index d13e901f0..09819ab39 100644 --- a/packstack/plugins/cinder_250.py +++ b/packstack/plugins/cinder_250.py @@ -356,9 +356,11 @@ def create_manifest(config): manifestfile = "%s_cinder.pp" % controller.CONF['CONFIG_CINDER_HOST'] manifestdata = getManifestTemplate("cinder.pp") - if controller.CONF['CONFIG_CINDER_BACKEND'] == "gluster": + if config['CONFIG_CINDER_BACKEND'] == "gluster": manifestdata += getManifestTemplate("cinder_gluster.pp") - if controller.CONF['CONFIG_CINDER_BACKEND'] == "nfs": + if config['CONFIG_CINDER_BACKEND'] == "nfs": manifestdata += getManifestTemplate("cinder_nfs.pp") + if config['CONFIG_CEILOMETER_INSTALL'] == 'y': + manifestdata += getManifestTemplate('glance_ceilometer.pp') appendManifestFile(manifestfile, manifestdata) diff --git a/packstack/plugins/glance_200.py b/packstack/plugins/glance_200.py index 6c9ab0963..e57aaa513 100644 --- a/packstack/plugins/glance_200.py +++ b/packstack/plugins/glance_200.py @@ -95,4 +95,6 @@ def createkeystonemanifest(config): def createmanifest(config): manifestfile = "%s_glance.pp" % controller.CONF['CONFIG_GLANCE_HOST'] manifestdata = getManifestTemplate("glance.pp") + if config['CONFIG_CEILOMETER_INSTALL'] == 'y': + manifestdata += getManifestTemplate('glance_ceilometer.pp') appendManifestFile(manifestfile, manifestdata) diff --git a/packstack/plugins/nova_300.py b/packstack/plugins/nova_300.py index 92dbd1335..2c7f8b819 100644 --- a/packstack/plugins/nova_300.py +++ b/packstack/plugins/nova_300.py @@ -394,6 +394,9 @@ def createcomputemanifest(config): # just warn user to do it by himself controller.MESSAGES.append(str(ScriptRuntimeError)) + if controller.CONF['CONFIG_CEILOMETER_INSTALL'] == 'y': + manifestdata += getManifestTemplate("nova_ceilometer.pp") + appendManifestFile(manifestfile, manifestdata + "\n" + nova_config_options.getManifestEntry()) diff --git a/packstack/plugins/prescript_000.py b/packstack/plugins/prescript_000.py index cfb7d45ff..406a2a636 100644 --- a/packstack/plugins/prescript_000.py +++ b/packstack/plugins/prescript_000.py @@ -107,6 +107,18 @@ def initConfig(controllerObject): "USE_DEFAULT" : False, "NEED_CONFIRM" : False, "CONDITION" : False }, + {"CMD_OPTION" : "os-ceilometer-install", + "USAGE" : "Set to 'y' if you would like Packstack to install OpenStack Metering (Ceilometer)", + "PROMPT" : "Should Packstack install OpenStack Metering (Ceilometer)", + "OPTION_LIST" : ["y", "n"], + "VALIDATORS" : [validators.validate_options], + "DEFAULT_VALUE" : "y", + "MASK_INPUT" : False, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "CONFIG_CEILOMETER_INSTALL", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, {"CMD_OPTION" : "os-client-install", "USAGE" : "Set to 'y' if you would like Packstack to install the OpenStack Client packages. An admin \"rc\" file will also be installed", "PROMPT" : "Should Packstack install OpenStack client tools", diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index e11e7c51b..a7627c8ce 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -75,14 +75,14 @@ def installdeps(config): def copyPuppetModules(config): - os_modules = ' '.join(('apache', 'cinder', 'concat', - 'create_resources', 'firewall', - 'glance', 'horizon', 'inifile', - 'keystone', 'memcached', 'mysql', - 'nova', 'openstack', 'packstack', - 'qpid', 'neutron', 'rsync', 'ssh', 'stdlib', - 'swift', 'sysctl', 'tempest', 'vcsrepo', - 'vlan', 'vswitch', 'xinetd')) + os_modules = ' '.join(('apache', 'ceilometer', 'cinder', 'concat', + 'create_resources', 'firewall', 'glance', + 'horizon', 'inifile', 'keystone', + 'memcached', 'mongodb', 'mysql', 'neutron', + 'nova', 'openstack', 'packstack', 'qpid', + 'rsync', 'ssh', 'stdlib', 'swift', 'sysctl', + 'tempest', 'vcsrepo', 'vlan', 'vswitch', + 'xinetd')) # write puppet manifest to disk manifestfiles.writeManifests() diff --git a/packstack/puppet/modules/ceilometer b/packstack/puppet/modules/ceilometer new file mode 160000 index 000000000..6aea6ac83 --- /dev/null +++ b/packstack/puppet/modules/ceilometer @@ -0,0 +1 @@ +Subproject commit 6aea6ac832835361dd4520e6cd1b501dec682cd4 diff --git a/packstack/puppet/modules/mongodb b/packstack/puppet/modules/mongodb new file mode 160000 index 000000000..3a0574a4a --- /dev/null +++ b/packstack/puppet/modules/mongodb @@ -0,0 +1 @@ +Subproject commit 3a0574a4a664cfcff197829eb70976c4862db57a diff --git a/packstack/puppet/templates/ceilometer.pp b/packstack/puppet/templates/ceilometer.pp new file mode 100644 index 000000000..a0a2d2df1 --- /dev/null +++ b/packstack/puppet/templates/ceilometer.pp @@ -0,0 +1,44 @@ + +class { 'mongodb': + enable_10gen => false, + port => '27017', + before => Class['ceilometer::db'], + require => Firewall['001 mongodb incoming localhost'], +} + +firewall { '001 mongodb incoming localhost': + proto => 'tcp', + dport => ['27017'], + iniface => 'lo', + #source => 'localhost', + #destination => 'localhost', + action => 'accept', +} + +class { 'ceilometer': + metering_secret => '%(CONFIG_CEILOMETER_SECRET)s', + qpid_hostname => '%(CONFIG_QPID_HOST)s', + rpc_backend => 'ceilometer.openstack.common.rpc.impl_qpid', + verbose => true, + debug => true, +} + +class { 'ceilometer::db': + database_connection => 'mongodb://localhost:27017/ceilometer', + require => Class['mongodb'], +} + +class { 'ceilometer::collector': + require => Class['mongodb'], +} + +class { 'ceilometer::agent::central': + auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', + auth_password => '%(CONFIG_CEILOMETER_KS_PW)s', +} + +class { 'ceilometer::api': + keystone_host => '%(CONFIG_KEYSTONE_HOST)s', + keystone_password => '%(CONFIG_CEILOMETER_KS_PW)s', + require => Class['mongodb'], +} diff --git a/packstack/puppet/templates/cinder_ceilometer.pp b/packstack/puppet/templates/cinder_ceilometer.pp new file mode 100644 index 000000000..d1a7f3175 --- /dev/null +++ b/packstack/puppet/templates/cinder_ceilometer.pp @@ -0,0 +1,4 @@ + +cinder_config{ + 'DEFAULT/notification_driver': value => 'cinder.openstack.common.notifier.rpc_notifier' +} diff --git a/packstack/puppet/templates/glance_ceilometer.pp b/packstack/puppet/templates/glance_ceilometer.pp new file mode 100644 index 000000000..7e8355f3e --- /dev/null +++ b/packstack/puppet/templates/glance_ceilometer.pp @@ -0,0 +1,4 @@ + +glance_api_config { + 'DEFAULT/notifier_strategy': value => 'qpid' +} diff --git a/packstack/puppet/templates/keystone_ceilometer.pp b/packstack/puppet/templates/keystone_ceilometer.pp new file mode 100644 index 000000000..87baa828e --- /dev/null +++ b/packstack/puppet/templates/keystone_ceilometer.pp @@ -0,0 +1,7 @@ + +class { 'ceilometer::keystone::auth': + password => '%(CONFIG_CEILOMETER_KS_PW)s', + public_address => "%(CONFIG_CEILOMETER_HOST)s", + admin_address => "%(CONFIG_CEILOMETER_HOST)s", + internal_address => "%(CONFIG_CEILOMETER_HOST)s", +} diff --git a/packstack/puppet/templates/nova_ceilometer.pp b/packstack/puppet/templates/nova_ceilometer.pp new file mode 100644 index 000000000..5ee10b023 --- /dev/null +++ b/packstack/puppet/templates/nova_ceilometer.pp @@ -0,0 +1,20 @@ + +class { 'ceilometer': + metering_secret => '%(CONFIG_CEILOMETER_SECRET)s', + qpid_hostname => '%(CONFIG_QPID_HOST)s', + rpc_backend => 'ceilometer.openstack.common.rpc.impl_qpid', + verbose => true, + debug => true, +} + +class { 'ceilometer::agent::compute': + auth_url => 'http://%(CONFIG_KEYSTONE_HOST)s:35357/v2.0', + auth_password => '%(CONFIG_CEILOMETER_KS_PW)s', +} + +# if fqdn is not set correctly we have to tell compute agent which host it should query +if !$::fqdn or $::fqdn != $::hostname { + ceilometer_config { + 'DEFAULT/host': value => $::hostname + } +}