ceilometer-agent-central has been replaced by ceilometer-polling
The ceilometer-agent-central and ceilometer-agent-compute services are now completely removed from the liberty release of ceilometer. The new implementation is to use ceilometer-polling and call the respective pollsters by namespace. Change-Id: I3af6fe9cc9c5b0fcf0406f89f402cbd1a31f66c4 Closes-Bug: 1606787
This commit is contained in:
parent
ec93c4eb56
commit
3816946e2f
@ -43,6 +43,7 @@ from charmhelpers.core.host import (
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
configure_installation_source,
|
||||
os_release,
|
||||
openstack_upgrade_available,
|
||||
pausable_restart_on_change as restart_on_change,
|
||||
is_unit_paused_set,
|
||||
@ -90,6 +91,10 @@ from charmhelpers.contrib.hardening.harden import harden
|
||||
hooks = Hooks()
|
||||
CONFIGS = register_configs()
|
||||
|
||||
LEGACY_RES_KEY = 'res_ceilometer_agent_central'
|
||||
LEGACY_OCF_FILE = "/usr/lib/ocf/resource.d/openstack/ceilometer-agent-central"
|
||||
NEW_RES_KEY = 'res_ceilometer_polling'
|
||||
|
||||
|
||||
@hooks.hook('install.real')
|
||||
@harden()
|
||||
@ -189,6 +194,15 @@ def config_changed():
|
||||
for rid in relation_ids('identity-service'):
|
||||
keystone_joined(relid=rid)
|
||||
|
||||
# Install OCF resource file locally
|
||||
install_ceilometer_ocf()
|
||||
|
||||
# Define the new ocf resource and use the key delete_resources to delete
|
||||
# legacy resource for >= Liberty since the ceilometer-agent-central moved
|
||||
# to ceilometer-polling in liberty (see LP: #1606787).
|
||||
for rid in relation_ids('ha'):
|
||||
ha_joined(rid)
|
||||
|
||||
|
||||
@hooks.hook('upgrade-charm')
|
||||
@harden()
|
||||
@ -199,13 +213,21 @@ def upgrade_charm():
|
||||
|
||||
|
||||
def install_ceilometer_ocf():
|
||||
dest_file = "/usr/lib/ocf/resource.d/openstack/ceilometer-agent-central"
|
||||
dest_file = LEGACY_OCF_FILE
|
||||
src_file = 'ocf/openstack/ceilometer-agent-central'
|
||||
|
||||
if os_release('ceilometer-common') >= 'liberty':
|
||||
dest_file = "/usr/lib/ocf/resource.d/openstack/ceilometer-polling"
|
||||
src_file = 'ocf/openstack/ceilometer-polling'
|
||||
# delete ocf file due to package no longer exists after upgrade
|
||||
if os.path.isfile(LEGACY_OCF_FILE):
|
||||
os.remove(LEGACY_OCF_FILE)
|
||||
|
||||
if not os.path.isdir(os.path.dirname(dest_file)):
|
||||
os.makedirs(os.path.dirname(dest_file))
|
||||
if not os.path.exists(dest_file):
|
||||
shutil.copy(src_file, dest_file)
|
||||
os.chmod(dest_file, 0o755)
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-joined')
|
||||
@ -236,16 +258,22 @@ def cluster_changed():
|
||||
@hooks.hook('ha-relation-joined')
|
||||
def ha_joined(relation_id=None):
|
||||
cluster_config = get_hacluster_config()
|
||||
delete_resources = []
|
||||
|
||||
RES_KEY = LEGACY_RES_KEY
|
||||
if os_release('ceilometer-common') >= 'liberty':
|
||||
RES_KEY = NEW_RES_KEY
|
||||
delete_resources.append(LEGACY_RES_KEY)
|
||||
|
||||
ocf_name = RES_KEY.replace('res_', '').replace('_', '-')
|
||||
resources = {
|
||||
'res_ceilometer_haproxy': 'lsb:haproxy',
|
||||
'res_ceilometer_agent_central': ('ocf:openstack:'
|
||||
'ceilometer-agent-central')
|
||||
RES_KEY: ('ocf:openstack:{}'.format(ocf_name))
|
||||
}
|
||||
|
||||
resource_params = {
|
||||
'res_ceilometer_haproxy': 'op monitor interval="5s"',
|
||||
'res_ceilometer_agent_central': 'op monitor interval="30s"'
|
||||
RES_KEY: 'op monitor interval="30s"'
|
||||
}
|
||||
|
||||
amqp_ssl_port = None
|
||||
@ -256,7 +284,7 @@ def ha_joined(relation_id=None):
|
||||
if amqp_ssl_port:
|
||||
params = ('params amqp_server_port="%s" op monitor interval="30s"' %
|
||||
(amqp_ssl_port))
|
||||
resource_params['res_ceilometer_agent_central'] = params
|
||||
resource_params[RES_KEY] = params
|
||||
|
||||
if config('dns-ha'):
|
||||
update_dns_ha_resource_params(relation_id=relation_id,
|
||||
@ -283,7 +311,9 @@ def ha_joined(relation_id=None):
|
||||
vip_group.append(vip_key)
|
||||
|
||||
if len(vip_group) >= 1:
|
||||
relation_set(groups={'grp_ceilometer_vips': ' '.join(vip_group)})
|
||||
relation_set(relation_id=relation_id,
|
||||
groups={'grp_ceilometer_vips':
|
||||
' '.join(vip_group)})
|
||||
|
||||
init_services = {
|
||||
'res_ceilometer_haproxy': 'haproxy'
|
||||
@ -297,6 +327,7 @@ def ha_joined(relation_id=None):
|
||||
corosync_mcastport=cluster_config['ha-mcastport'],
|
||||
resources=resources,
|
||||
resource_params=resource_params,
|
||||
delete_resources=delete_resources,
|
||||
clones=clones)
|
||||
|
||||
|
||||
|
@ -240,6 +240,8 @@ ceilometer_agent_central_monitor() {
|
||||
ceilometer_agent_central_start() {
|
||||
local rc
|
||||
|
||||
service ceilometer-agent-central stop >> /dev/null 2>&1
|
||||
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_SUCCESS ]; then
|
||||
|
348
ocf/openstack/ceilometer-polling
Normal file
348
ocf/openstack/ceilometer-polling
Normal file
@ -0,0 +1,348 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# OpenStack Ceilometer Polling Agent Service (ceilometer-polling)
|
||||
#
|
||||
# Description: Manages an OpenStack Ceilometer Polling Agent Service (ceilometer-polling) process as an HA resource
|
||||
#
|
||||
# Authors: Emilien Macchi
|
||||
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
|
||||
#
|
||||
# Support: openstack@lists.launchpad.net
|
||||
# License: Apache Software License (ASL) 2.0
|
||||
#
|
||||
#
|
||||
# See usage() function below for more details ...
|
||||
#
|
||||
# OCF instance parameters:
|
||||
# OCF_RESKEY_binary
|
||||
# OCF_RESKEY_config
|
||||
# OCF_RESKEY_user
|
||||
# OCF_RESKEY_pid
|
||||
# OCF_RESKEY_monitor_binary
|
||||
# OCF_RESKEY_amqp_server_port
|
||||
# OCF_RESKEY_additional_parameters
|
||||
#######################################################################
|
||||
# Initialization:
|
||||
|
||||
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
|
||||
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
|
||||
|
||||
#######################################################################
|
||||
|
||||
# Fill in some defaults if no values are specified
|
||||
|
||||
OCF_RESKEY_binary_default="ceilometer-polling"
|
||||
OCF_RESKEY_additional_parameters=" --polling-namespaces central"
|
||||
OCF_RESKEY_config_default="/etc/ceilometer/ceilometer.conf"
|
||||
OCF_RESKEY_user_default="ceilometer"
|
||||
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
|
||||
OCF_RESKEY_amqp_server_port_default="5672"
|
||||
|
||||
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
|
||||
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
|
||||
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
|
||||
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
|
||||
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
|
||||
|
||||
#######################################################################
|
||||
|
||||
usage() {
|
||||
cat <<UEND
|
||||
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
|
||||
|
||||
$0 manages an OpenStack Ceilometer Polling Agent Service (ceilometer-polling) process as an HA resource
|
||||
|
||||
The 'start' operation starts the scheduler service.
|
||||
The 'stop' operation stops the scheduler service.
|
||||
The 'validate-all' operation reports whether the parameters are valid
|
||||
The 'meta-data' operation reports this RA's meta-data information
|
||||
The 'status' operation reports whether the scheduler service is running
|
||||
The 'monitor' operation reports whether the scheduler service seems to be working
|
||||
|
||||
UEND
|
||||
}
|
||||
|
||||
meta_data() {
|
||||
cat <<END
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
|
||||
<resource-agent name="ceilometer-polling">
|
||||
<version>1.0</version>
|
||||
|
||||
<longdesc lang="en">
|
||||
Resource agent for the OpenStack Ceilometer Polling Agent Service (ceilometer-polling)
|
||||
May manage a ceilometer-polling instance or a clone set that
|
||||
creates a distributed ceilometer-polling cluster.
|
||||
</longdesc>
|
||||
<shortdesc lang="en">Manages the OpenStack Ceilometer Polling Agent Service (ceilometer-polling)</shortdesc>
|
||||
<parameters>
|
||||
|
||||
<parameter name="binary" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Location of the OpenStack Ceilometer Polling Agent server binary (ceilometer-polling)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Polling Agent server binary (ceilometer-polling)</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_binary_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="config" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Location of the OpenStack Ceilometer Polling Agent Service (ceilometer-polling) configuration file
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Polling Agent (ceilometer-polling registry) config file</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_config_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="user" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
User running OpenStack Ceilometer Polling Agent Service (ceilometer-polling)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Polling Agent Service (ceilometer-polling) user</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_user_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="pid" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
The pid file to use for this OpenStack Ceilometer Polling Agent Service (ceilometer-polling) instance
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Polling Agent Service (ceilometer-polling) pid file</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_pid_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="amqp_server_port" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
The listening port number of the AMQP server. Use for monitoring purposes
|
||||
</longdesc>
|
||||
<shortdesc lang="en">AMQP listening port</shortdesc>
|
||||
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
|
||||
</parameter>
|
||||
|
||||
|
||||
<parameter name="additional_parameters" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Additional parameters to pass on to the OpenStack Ceilometer Polling Agent Service (ceilometer-polling)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">Additional parameters for ceilometer-polling</shortdesc>
|
||||
<content type="string" />
|
||||
</parameter>
|
||||
|
||||
</parameters>
|
||||
|
||||
<actions>
|
||||
<action name="start" timeout="20" />
|
||||
<action name="stop" timeout="20" />
|
||||
<action name="status" timeout="20" />
|
||||
<action name="monitor" timeout="30" interval="20" />
|
||||
<action name="validate-all" timeout="5" />
|
||||
<action name="meta-data" timeout="5" />
|
||||
</actions>
|
||||
</resource-agent>
|
||||
END
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Functions invoked by resource manager actions
|
||||
|
||||
ceilometer_polling_check_port() {
|
||||
# This function has been taken from the squid RA and improved a bit
|
||||
# The length of the integer must be 4
|
||||
# Examples of valid port: "1080", "0080"
|
||||
# Examples of invalid port: "1080bad", "0", "0000", ""
|
||||
|
||||
local int
|
||||
local cnt
|
||||
|
||||
int="$1"
|
||||
cnt=${#int}
|
||||
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
|
||||
|
||||
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
|
||||
ocf_log err "Invalid port number: $1"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
}
|
||||
|
||||
ceilometer_polling_validate() {
|
||||
local rc
|
||||
|
||||
check_binary $OCF_RESKEY_binary
|
||||
check_binary netstat
|
||||
ceilometer_polling_check_port $OCF_RESKEY_amqp_server_port
|
||||
|
||||
# A config file on shared storage that is not available
|
||||
# during probes is OK.
|
||||
if [ ! -f $OCF_RESKEY_config ]; then
|
||||
if ! ocf_is_probe; then
|
||||
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
|
||||
return $OCF_ERR_INSTALLED
|
||||
fi
|
||||
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
|
||||
fi
|
||||
|
||||
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "User $OCF_RESKEY_user doesn't exist"
|
||||
return $OCF_ERR_INSTALLED
|
||||
fi
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
ceilometer_polling_status() {
|
||||
local pid
|
||||
local rc
|
||||
|
||||
if [ ! -f $OCF_RESKEY_pid ]; then
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) is not running"
|
||||
return $OCF_NOT_RUNNING
|
||||
else
|
||||
pid=`cat $OCF_RESKEY_pid`
|
||||
fi
|
||||
|
||||
ocf_run -warn kill -s 0 $pid
|
||||
rc=$?
|
||||
if [ $rc -eq 0 ]; then
|
||||
return $OCF_SUCCESS
|
||||
else
|
||||
ocf_log info "Old PID file found, but OpenStack Ceilometer Polling Agent (ceilometer-polling) is not running"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
}
|
||||
|
||||
ceilometer_polling_monitor() {
|
||||
local rc
|
||||
local pid
|
||||
local scheduler_amqp_check
|
||||
|
||||
ceilometer_polling_status
|
||||
rc=$?
|
||||
|
||||
# If status returned anything but success, return that immediately
|
||||
if [ $rc -ne $OCF_SUCCESS ]; then
|
||||
return $rc
|
||||
fi
|
||||
|
||||
# Check the connections according to the PID.
|
||||
# We are sure to hit the scheduler process and not other Cinder process with the same connection behavior (for example cinder-api)
|
||||
pid=`cat $OCF_RESKEY_pid`
|
||||
scheduler_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Central Agent is not connected to the AMQP server : $rc"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Ceilometer Polling Agent (ceilometer-polling) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
ceilometer_polling_start() {
|
||||
local rc
|
||||
|
||||
service ceilometer-agent-central stop >> /dev/null 2>&1
|
||||
|
||||
ceilometer_polling_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_SUCCESS ]; then
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) already running"
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
# run the actual ceilometer-polling daemon. Don't use ocf_run as we're sending the tool's output
|
||||
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
|
||||
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
|
||||
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
|
||||
|
||||
# Spin waiting for the server to come up.
|
||||
while true; do
|
||||
ceilometer_polling_monitor
|
||||
rc=$?
|
||||
[ $rc -eq $OCF_SUCCESS ] && break
|
||||
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||
ocf_log err "OpenStack Ceilometer Polling Agent (ceilometer-polling) start failed"
|
||||
exit $OCF_ERR_GENERIC
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) started"
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
ceilometer_polling_stop() {
|
||||
local rc
|
||||
local pid
|
||||
|
||||
ceilometer_polling_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) already stopped"
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
# Try SIGTERM
|
||||
pid=`cat $OCF_RESKEY_pid`
|
||||
ocf_run kill -s TERM $pid
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "OpenStack Ceilometer Polling Agent (ceilometer-polling) couldn't be stopped"
|
||||
exit $OCF_ERR_GENERIC
|
||||
fi
|
||||
|
||||
# stop waiting
|
||||
shutdown_timeout=15
|
||||
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
|
||||
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
|
||||
fi
|
||||
count=0
|
||||
while [ $count -lt $shutdown_timeout ]; do
|
||||
ceilometer_polling_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||
break
|
||||
fi
|
||||
count=`expr $count + 1`
|
||||
sleep 1
|
||||
ocf_log debug "OpenStack Ceilometer Polling Agent (ceilometer-polling) still hasn't stopped yet. Waiting ..."
|
||||
done
|
||||
|
||||
ceilometer_polling_status
|
||||
rc=$?
|
||||
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||
# SIGTERM didn't help either, try SIGKILL
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) failed to stop after ${shutdown_timeout}s \
|
||||
using SIGTERM. Trying SIGKILL ..."
|
||||
ocf_run kill -s KILL $pid
|
||||
fi
|
||||
|
||||
ocf_log info "OpenStack Ceilometer Polling Agent (ceilometer-polling) stopped"
|
||||
|
||||
rm -f $OCF_RESKEY_pid
|
||||
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
|
||||
case "$1" in
|
||||
meta-data) meta_data
|
||||
exit $OCF_SUCCESS;;
|
||||
usage|help) usage
|
||||
exit $OCF_SUCCESS;;
|
||||
esac
|
||||
|
||||
# Anything except meta-data and help must pass validation
|
||||
ceilometer_polling_validate || exit $?
|
||||
|
||||
# What kind of method was invoked?
|
||||
case "$1" in
|
||||
start) ceilometer_polling_start;;
|
||||
stop) ceilometer_polling_stop;;
|
||||
status) ceilometer_polling_status;;
|
||||
monitor) ceilometer_polling_monitor;;
|
||||
validate-all) ;;
|
||||
*) usage
|
||||
exit $OCF_ERR_UNIMPLEMENTED;;
|
||||
esac
|
@ -66,6 +66,7 @@ TO_PATCH = [
|
||||
'reload_systemd',
|
||||
'mkdir',
|
||||
'init_is_systemd',
|
||||
'os_release',
|
||||
]
|
||||
|
||||
|
||||
@ -148,7 +149,9 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch.object(hooks, 'ceilometer_joined')
|
||||
def test_config_changed_no_upgrade(self, joined, mock_config):
|
||||
@patch.object(hooks, 'install_ceilometer_ocf')
|
||||
def test_config_changed_no_upgrade(self, ocf,
|
||||
joined, mock_config):
|
||||
self.openstack_upgrade_available.return_value = False
|
||||
hooks.hooks.execute(['hooks/config-changed'])
|
||||
self.openstack_upgrade_available.\
|
||||
@ -157,10 +160,13 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
self.assertTrue(joined.called)
|
||||
self.assertTrue(self.reload_systemd.called)
|
||||
self.assertTrue(ocf.called)
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch.object(hooks, 'ceilometer_joined')
|
||||
def test_config_changed_upgrade(self, joined, mock_config):
|
||||
@patch.object(hooks, 'install_ceilometer_ocf')
|
||||
def test_config_changed_upgrade(self, ocf,
|
||||
joined, mock_config):
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
hooks.hooks.execute(['hooks/config-changed'])
|
||||
self.openstack_upgrade_available.\
|
||||
@ -169,14 +175,17 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
self.assertTrue(joined.called)
|
||||
self.assertTrue(self.reload_systemd.called)
|
||||
self.assertTrue(ocf.called)
|
||||
|
||||
def test_config_changed_with_openstack_upgrade_action(self):
|
||||
@patch.object(hooks, 'install_ceilometer_ocf')
|
||||
def test_config_changed_with_openstack_upgrade_action(self, ocf):
|
||||
self.openstack_upgrade_available.return_value = True
|
||||
self.test_config.set('action-managed-upgrade', True)
|
||||
|
||||
hooks.hooks.execute(['hooks/config-changed'])
|
||||
|
||||
self.assertFalse(self.do_openstack_upgrade.called)
|
||||
self.assertTrue(ocf.called)
|
||||
|
||||
@patch.object(hooks, 'canonical_url')
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@ -296,6 +305,7 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
@patch.object(hooks, 'get_netmask_for_address')
|
||||
def test_ha_joined(self, mock_netmask, mock_iface, mock_cluster_config,
|
||||
mock_config):
|
||||
self.os_release.return_value = 'kilo'
|
||||
mock_cluster_config.return_value = {'vip': '10.0.5.100',
|
||||
'ha-bindiface': 'bnd0',
|
||||
'ha-mcastport': 5802}
|
||||
@ -318,13 +328,15 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
'nic="eth0"')
|
||||
}
|
||||
exp_clones = {'cl_ceilometer_haproxy': 'res_ceilometer_haproxy'}
|
||||
call1 = call(groups={'grp_ceilometer_vips': 'res_ceilometer_eth0_vip'})
|
||||
call1 = call(relation_id=None,
|
||||
groups={'grp_ceilometer_vips': 'res_ceilometer_eth0_vip'})
|
||||
call2 = call(relation_id=None,
|
||||
init_services={'res_ceilometer_haproxy': 'haproxy'},
|
||||
corosync_bindiface='bnd0',
|
||||
corosync_mcastport=5802,
|
||||
resources=exp_resources,
|
||||
resource_params=exp_resource_params,
|
||||
delete_resources=[],
|
||||
clones=exp_clones)
|
||||
self.relation_set.assert_has_calls([call1, call2], any_order=False)
|
||||
|
||||
@ -338,6 +350,7 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
def test_ha_joined_ssl(self, mock_rel_get, mock_rel_units, mock_rel_ids,
|
||||
mock_iface, mock_cluster_config, mock_netmask,
|
||||
mock_config):
|
||||
self.os_release.return_value = 'kilo'
|
||||
mock_rel_ids.return_value = 'amqp:0'
|
||||
mock_rel_units.return_value = 'rabbitmq-server/0'
|
||||
mock_rel_get.return_value = '5671'
|
||||
@ -366,13 +379,15 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
'nic="eth0"')
|
||||
}
|
||||
exp_clones = {'cl_ceilometer_haproxy': 'res_ceilometer_haproxy'}
|
||||
call1 = call(groups={'grp_ceilometer_vips': 'res_ceilometer_eth0_vip'})
|
||||
call1 = call(relation_id=None,
|
||||
groups={'grp_ceilometer_vips': 'res_ceilometer_eth0_vip'})
|
||||
call2 = call(relation_id=None,
|
||||
init_services={'res_ceilometer_haproxy': 'haproxy'},
|
||||
corosync_bindiface='bnd0',
|
||||
corosync_mcastport=5802,
|
||||
resources=exp_resources,
|
||||
resource_params=exp_resource_params,
|
||||
delete_resources=[],
|
||||
clones=exp_clones)
|
||||
self.relation_set.assert_has_calls([call1, call2], any_order=False)
|
||||
|
||||
@ -386,6 +401,7 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
'ip_address="10.0.0.1"'})
|
||||
|
||||
self.test_config.set('dns-ha', True)
|
||||
self.os_release.return_value = 'kilo'
|
||||
mock_cluster_config.return_value = {
|
||||
'vip': None,
|
||||
'ha-bindiface': 'em0',
|
||||
@ -409,6 +425,7 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
'ip_address="10.0.0.1"',
|
||||
'res_ceilometer_haproxy': 'op monitor interval="5s"',
|
||||
'res_ceilometer_agent_central': 'op monitor interval="30s"'},
|
||||
'delete_resources': [],
|
||||
'clones': {'cl_ceilometer_haproxy': 'res_ceilometer_haproxy'}
|
||||
}
|
||||
self.update_dns_ha_resource_params.side_effect = _fake_update
|
||||
@ -417,6 +434,18 @@ class CeilometerHooksTest(CharmTestCase):
|
||||
self.assertTrue(self.update_dns_ha_resource_params.called)
|
||||
self.relation_set.assert_called_with(**args)
|
||||
|
||||
self.os_release.return_value = 'liberty'
|
||||
args.get('resources').pop('res_ceilometer_agent_central')
|
||||
args.get('resource_params').pop('res_ceilometer_agent_central')
|
||||
args.get('resources')['res_ceilometer_polling'] = \
|
||||
'ocf:openstack:ceilometer-polling'
|
||||
args.get('resource_params')['res_ceilometer_polling'] = \
|
||||
'op monitor interval="30s"'
|
||||
args['delete_resources'] = ['res_ceilometer_agent_central']
|
||||
self.update_dns_ha_resource_params.side_effect = _fake_update
|
||||
hooks.ha_joined()
|
||||
self.relation_set.assert_called_with(**args)
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch.object(hooks, 'keystone_joined')
|
||||
def test_ha_changed_not_clustered(self, mock_keystone_joined, mock_config):
|
||||
|
Loading…
Reference in New Issue
Block a user