From 4832b747a10480ad2b84e353172f461882aaec6d Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Sun, 16 Nov 2014 16:46:11 +0000 Subject: [PATCH] redis-based group membership coordination for ceilometer If CONFIG_CEILOMETER_COORDINATION_BACKEND is set to 'redis' then a redis manifest is created to install redis on the appropriate host and configure the ceilometer-central-agent and ceilometer-alarm-evaluator to use it for group membership coordination. The other valid option is 'none', in which case no coordination will be done. 'redis' is the default. Change-Id: I07261f5fd433c13a57a614c15b13f0cad6c79d6a --- docs/packstack.rst | 9 ++++ packstack/plugins/ceilometer_800.py | 69 +++++++++++++++++++++++- packstack/plugins/puppet_950.py | 6 +-- packstack/puppet/templates/ceilometer.pp | 19 +++++-- packstack/puppet/templates/redis.pp | 9 ++++ 5 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 packstack/puppet/templates/redis.pp diff --git a/docs/packstack.rst b/docs/packstack.rst index 2123df45d..1a1dd3a5c 100644 --- a/docs/packstack.rst +++ b/docs/packstack.rst @@ -422,6 +422,15 @@ Ceilometer Config Parameters **CONFIG_CEILOMETER_KS_PW** The password to use for Ceilometer to authenticate with Keystone. +**CONFIG_CEILOMETER_COORDINATION_BACKEND** + Specify an optional backend for group membership coordination in the alarm evaluator and central agent. Currently the only valid option are 'redis' or 'none'. The default is 'redis'. + +**CONFIG_REDIS_HOST** + The IP address of the server on which to install Redis, if Redis is being used for coordination. + +**CONFIG_REDIS_PORT** + The port on which the Redis server will listen, if Redis is being used for coordination. + Heat Config Parameters ---------------------- diff --git a/packstack/plugins/ceilometer_800.py b/packstack/plugins/ceilometer_800.py index 7d6d9ca99..1fd777ff4 100644 --- a/packstack/plugins/ceilometer_800.py +++ b/packstack/plugins/ceilometer_800.py @@ -51,6 +51,18 @@ def initConfig(controller): "USE_DEFAULT": False, "NEED_CONFIRM": True, "CONDITION": False}, + + {"CONF_NAME": "CONFIG_CEILOMETER_COORDINATION_BACKEND", + "CMD_OPTION": "ceilometer-coordination-backend", + "USAGE": "Backend driver for group membership coordination", + "PROMPT": "Enter the coordination driver", + "OPTION_LIST": ['redis', 'none'], + "VALIDATORS": [validators.validate_options], + "DEFAULT_VALUE": 'redis', + "MASK_INPUT": False, + "USE_DEFAULT": True, + "NEED_CONFIRM": False, + "CONDITION": False}, ], "MONGODB": [ @@ -68,6 +80,33 @@ def initConfig(controller): "NEED_CONFIRM": False, "CONDITION": False}, ], + "REDIS": [ + {"CMD_OPTION": "redis-host", + "USAGE": ("The IP address of the server on which to install " + "redis"), + "PROMPT": "Enter the IP address of the redis server", + "OPTION_LIST": [], + "VALIDATORS": [validators.validate_ssh], + "DEFAULT_VALUE": utils.get_localhost_ip(), + "MASK_INPUT": False, + "LOOSE_VALIDATION": True, + "CONF_NAME": "CONFIG_REDIS_HOST", + "USE_DEFAULT": False, + "NEED_CONFIRM": False, + "CONDITION": False}, + {"CMD_OPTION": "redis-port", + "USAGE": "The port on which the redis server listens", + "PROMPT": "Enter the port of the redis server", + "OPTION_LIST": [], + "VALIDATORS": [validators.validate_port], + "DEFAULT_VALUE": 6379, + "MASK_INPUT": False, + "LOOSE_VALIDATION": True, + "CONF_NAME": "CONFIG_REDIS_PORT", + "USE_DEFAULT": False, + "NEED_CONFIRM": False, + "CONDITION": False}, + ], } ceilometer_groups = [ @@ -84,6 +123,13 @@ def initConfig(controller): "PRE_CONDITION_MATCH": "y", "POST_CONDITION": False, "POST_CONDITION_MATCH": True}, + + {"GROUP_NAME": "REDIS", + "DESCRIPTION": "Redis Config parameters", + "PRE_CONDITION": "CONFIG_CEILOMETER_COORDINATION_BACKEND", + "PRE_CONDITION_MATCH": "redis", + "POST_CONDITION": False, + "POST_CONDITION_MATCH": True}, ] for group in ceilometer_groups: paramList = ceilometer_params[group["GROUP_NAME"]] @@ -96,6 +142,8 @@ def initSequences(controller): steps = [{'title': 'Adding MongoDB manifest entries', 'functions': [create_mongodb_manifest]}, + {'title': 'Adding Redis manifest entries', + 'functions': [create_redis_manifest]}, {'title': 'Adding Ceilometer manifest entries', 'functions': [create_manifest]}, {'title': 'Adding Ceilometer Keystone manifest entries', @@ -126,7 +174,7 @@ def create_manifest(config, messages): # class needs it if config['CONFIG_NOVA_INSTALL'] == 'n': manifestdata += getManifestTemplate("ceilometer_nova_disabled.pp") - appendManifestFile(manifestfile, manifestdata) + appendManifestFile(manifestfile, manifestdata, 'ceilometer') def create_mongodb_manifest(config, messages): @@ -147,6 +195,25 @@ def create_mongodb_manifest(config, messages): appendManifestFile(manifestfile, manifestdata, 'pre') +def create_redis_manifest(config, messages): + if config['CONFIG_CEILOMETER_COORDINATION_BACKEND'] == 'redis': + manifestfile = "%s_redis.pp" % config['CONFIG_REDIS_HOST'] + manifestdata = getManifestTemplate("redis.pp") + + fw_details = dict() + key = "redis_server" + fw_details.setdefault(key, {}) + fw_details[key]['host'] = "%s" % config['CONFIG_CONTROLLER_HOST'] + fw_details[key]['service_name'] = "redis-server" + fw_details[key]['chain'] = "INPUT" + fw_details[key]['ports'] = config['CONFIG_REDIS_PORT'] + fw_details[key]['proto'] = "tcp" + config['FIREWALL_REDIS_RULES'] = fw_details + + manifestdata += createFirewallResources('FIREWALL_REDIS_RULES') + appendManifestFile(manifestfile, manifestdata, 'pre') + + def create_keystone_manifest(config, messages): manifestfile = "%s_keystone.pp" % config['CONFIG_CONTROLLER_HOST'] manifestdata = getManifestTemplate("keystone_ceilometer.pp") diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index f64fa8abe..ae8bb0594 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -175,9 +175,9 @@ def copy_puppet_modules(config, messages): 'concat', 'firewall', 'glance', 'heat', 'horizon', 'inifile', 'keystone', 'memcached', 'mongodb', 'mysql', 'neutron', 'nova', 'nssdb', 'openstack', - 'packstack', 'qpid', 'rabbitmq', 'remote', 'rsync', - 'ssh', 'stdlib', 'swift', 'sysctl', 'tempest', - 'vcsrepo', 'vlan', 'vswitch', 'xinetd', + 'packstack', 'qpid', 'rabbitmq', 'redis', 'remote', + 'rsync', 'ssh', 'stdlib', 'swift', 'sysctl', + 'tempest', 'vcsrepo', 'vlan', 'vswitch', 'xinetd', 'openstacklib')) # write puppet manifest to disk diff --git a/packstack/puppet/templates/ceilometer.pp b/packstack/puppet/templates/ceilometer.pp index 7955c3709..28c9002e7 100644 --- a/packstack/puppet/templates/ceilometer.pp +++ b/packstack/puppet/templates/ceilometer.pp @@ -1,5 +1,15 @@ $config_mongodb_host = hiera('CONFIG_MONGODB_HOST') +$config_ceilometer_coordination_backend = hiera('CONFIG_CEILOMETER_COORDINATION_BACKEND') + +if $config_ceilometer_coordination_backend == 'redis' { + $redis_host = hiera('CONFIG_REDIS_HOST') + $redis_port = hiera('CONFIG_REDIS_PORT') + $coordination_url = "redis://${redis_host}:${redis_port}" +} else { + $coordination_url = '' +} + class { 'ceilometer::db': database_connection => "mongodb://${config_mongodb_host}:27017/ceilometer", } @@ -15,14 +25,17 @@ class { 'ceilometer::agent::auth': auth_password => hiera('CONFIG_CEILOMETER_KS_PW'), } -class { 'ceilometer::agent::central': } +class { 'ceilometer::agent::central': + coordination_url => $coordination_url, +} class { 'ceilometer::alarm::notifier':} -class { 'ceilometer::alarm::evaluator':} +class { 'ceilometer::alarm::evaluator': + coordination_url => $coordination_url, +} class { 'ceilometer::api': keystone_host => hiera('CONFIG_CONTROLLER_HOST'), keystone_password => hiera('CONFIG_CEILOMETER_KS_PW'), } - diff --git a/packstack/puppet/templates/redis.pp b/packstack/puppet/templates/redis.pp new file mode 100644 index 000000000..ab4aaba88 --- /dev/null +++ b/packstack/puppet/templates/redis.pp @@ -0,0 +1,9 @@ +$redis_host = hiera('CONFIG_REDIS_HOST') +$redis_port = hiera('CONFIG_REDIS_PORT') + +class { 'redis': + bind => $redis_host, + port => $redis_port, + appendonly => true, + daemonize => false, +}