Rebased on trunk

This commit is contained in:
Corey Bryant 2015-09-22 15:34:48 +00:00
commit c530e360f9
85 changed files with 509 additions and 350 deletions

View File

@ -1,2 +1,6 @@
pause:
description: Pause the Ceilometer unit. This action will stop Ceilometer services.
resume:
descrpition: Resume the Ceilometer unit. This action will start Ceilometer services.
openstack-upgrade:
description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True.

52
actions/actions.py Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/python
import os
import sys
from charmhelpers.core.host import service_pause, service_resume
from charmhelpers.core.hookenv import action_fail, status_set
from ceilometer_utils import CEILOMETER_SERVICES
def pause(args):
"""Pause the Ceilometer services.
@raises Exception should the service fail to stop.
"""
for service in CEILOMETER_SERVICES:
if not service_pause(service):
raise Exception("Failed to %s." % service)
status_set(
"maintenance", "Paused. Use 'resume' action to resume normal service.")
def resume(args):
"""Resume the Ceilometer services.
@raises Exception should the service fail to start."""
for service in CEILOMETER_SERVICES:
if not service_resume(service):
raise Exception("Failed to resume %s." % service)
status_set("active", "")
# A dictionary of all the defined actions to callables (which take
# parsed arguments).
ACTIONS = {"pause": pause, "resume": resume}
def main(args):
action_name = os.path.basename(args[0])
try:
action = ACTIONS[action_name]
except KeyError:
return "Action %s undefined" % action_name
else:
try:
action(args)
except Exception as e:
action_fail(str(e))
if __name__ == "__main__":
sys.exit(main(sys.argv))

View File

@ -0,0 +1 @@
../ceilometer_contexts.py

1
actions/ceilometer_utils.py Symbolic link
View File

@ -0,0 +1 @@
../ceilometer_utils.py

1
actions/charmhelpers Symbolic link
View File

@ -0,0 +1 @@
../charmhelpers

1
actions/pause Symbolic link
View File

@ -0,0 +1 @@
actions.py

1
actions/resume Symbolic link
View File

@ -0,0 +1 @@
actions.py

122
ceilometer_contexts.py Normal file
View File

@ -0,0 +1,122 @@
from charmhelpers.core.hookenv import (
relation_ids,
relation_get,
related_units,
config
)
from charmhelpers.contrib.openstack.utils import os_release
from charmhelpers.contrib.openstack.context import (
OSContextGenerator,
context_complete,
ApacheSSLContext as SSLContext,
)
from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
determine_api_port
)
CEILOMETER_DB = 'ceilometer'
class LoggingConfigContext(OSContextGenerator):
def __call__(self):
return {'debug': config('debug'), 'verbose': config('verbose')}
class MongoDBContext(OSContextGenerator):
interfaces = ['mongodb']
def __call__(self):
mongo_servers = []
replset = None
use_replset = os_release('ceilometer-api') >= 'icehouse'
for relid in relation_ids('shared-db'):
rel_units = related_units(relid)
use_replset = use_replset and (len(rel_units) > 1)
for unit in rel_units:
host = relation_get('hostname', unit, relid)
port = relation_get('port', unit, relid)
conf = {
"db_host": host,
"db_port": port,
"db_name": CEILOMETER_DB
}
if not context_complete(conf):
continue
if not use_replset:
return conf
if replset is None:
replset = relation_get('replset', unit, relid)
mongo_servers.append('{}:{}'.format(host, port))
if mongo_servers:
return {
'db_mongo_servers': ','.join(mongo_servers),
'db_name': CEILOMETER_DB,
'db_replset': replset
}
return {}
CEILOMETER_PORT = 8777
class CeilometerContext(OSContextGenerator):
def __call__(self):
# Lazy-import to avoid a circular dependency in the imports
from ceilometer_utils import get_shared_secret
ctxt = {
'api_workers': config('api-workers'),
'port': CEILOMETER_PORT,
'metering_secret': get_shared_secret()
}
return ctxt
class CeilometerServiceContext(OSContextGenerator):
interfaces = ['ceilometer-service']
def __call__(self):
for relid in relation_ids('ceilometer-service'):
for unit in related_units(relid):
conf = relation_get(unit=unit, rid=relid)
if context_complete(conf):
return conf
return {}
class HAProxyContext(OSContextGenerator):
interfaces = ['ceilometer-haproxy']
def __call__(self):
'''Extends the main charmhelpers HAProxyContext with a port mapping
specific to this charm.
'''
haproxy_port = CEILOMETER_PORT
api_port = determine_api_port(CEILOMETER_PORT, singlenode_mode=True)
apache_port = determine_apache_port(CEILOMETER_PORT,
singlenode_mode=True)
ctxt = {
'service_ports': {'ceilometer_api': [haproxy_port, apache_port]},
'port': api_port
}
return ctxt
class ApacheSSLContext(SSLContext):
external_ports = [CEILOMETER_PORT]
service_namespace = "ceilometer"

225
ceilometer_utils.py Normal file
View File

@ -0,0 +1,225 @@
import os
import uuid
from collections import OrderedDict
from charmhelpers.contrib.openstack import (
templating,
context,
)
from ceilometer_contexts import (
ApacheSSLContext,
LoggingConfigContext,
MongoDBContext,
CeilometerContext,
HAProxyContext
)
from charmhelpers.contrib.openstack.utils import (
get_os_codename_package,
get_os_codename_install_source,
configure_installation_source
)
from charmhelpers.core.hookenv import config, log
from charmhelpers.fetch import apt_update, apt_install, apt_upgrade
from copy import deepcopy
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
CEILOMETER_CONF_DIR = "/etc/ceilometer"
CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR
HTTPS_APACHE_CONF = "/etc/apache2/sites-available/openstack_https_frontend"
HTTPS_APACHE_24_CONF = "/etc/apache2/sites-available/" \
"openstack_https_frontend.conf"
CLUSTER_RES = 'grp_ceilometer_vips'
CEILOMETER_SERVICES = [
'ceilometer-agent-central',
'ceilometer-collector',
'ceilometer-api',
'ceilometer-alarm-evaluator',
'ceilometer-alarm-notifier',
'ceilometer-agent-notification',
]
CEILOMETER_DB = "ceilometer"
CEILOMETER_SERVICE = "ceilometer"
CEILOMETER_PACKAGES = [
'haproxy',
'apache2',
'ceilometer-agent-central',
'ceilometer-collector',
'ceilometer-api',
'python-pymongo',
]
ICEHOUSE_PACKAGES = [
'ceilometer-alarm-notifier',
'ceilometer-alarm-evaluator',
'ceilometer-agent-notification'
]
ICEHOUSE_SERVICES = [
'ceilometer-alarm-notifier',
'ceilometer-alarm-evaluator',
'ceilometer-agent-notification'
]
CEILOMETER_ROLE = "ResellerAdmin"
SVC = 'ceilometer'
CONFIG_FILES = OrderedDict([
(CEILOMETER_CONF, {
'hook_contexts': [context.IdentityServiceContext(service=SVC,
service_user=SVC),
context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR),
LoggingConfigContext(),
MongoDBContext(),
CeilometerContext(),
context.SyslogContext(),
HAProxyContext()],
'services': CEILOMETER_SERVICES
}),
(HAPROXY_CONF, {
'hook_contexts': [context.HAProxyContext(singlenode_mode=True),
HAProxyContext()],
'services': ['haproxy'],
}),
(HTTPS_APACHE_CONF, {
'hook_contexts': [ApacheSSLContext()],
'services': ['apache2'],
}),
(HTTPS_APACHE_24_CONF, {
'hook_contexts': [ApacheSSLContext()],
'services': ['apache2'],
})
])
TEMPLATES = 'templates'
SHARED_SECRET = "/etc/ceilometer/secret.txt"
def register_configs():
"""
Register config files with their respective contexts.
Regstration of some configs may not be required depending on
existing of certain relations.
"""
# if called without anything installed (eg during install hook)
# just default to earliest supported release. configs dont get touched
# till post-install, anyway.
release = get_os_codename_package('ceilometer-common', fatal=False) \
or 'grizzly'
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
if (get_os_codename_install_source(
config('openstack-origin')) >= 'icehouse'):
CONFIG_FILES[CEILOMETER_CONF]['services'] = \
CONFIG_FILES[CEILOMETER_CONF]['services'] + ICEHOUSE_SERVICES
for conf in CONFIG_FILES:
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
if os.path.exists('/etc/apache2/conf-available'):
configs.register(HTTPS_APACHE_24_CONF,
CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts'])
else:
configs.register(HTTPS_APACHE_CONF,
CONFIG_FILES[HTTPS_APACHE_CONF]['hook_contexts'])
return configs
def restart_map():
'''
Determine the correct resource map to be passed to
charmhelpers.core.restart_on_change() based on the services configured.
:returns: dict: A dictionary mapping config file to lists of services
that should be restarted when file changes.
'''
_map = {}
for f, ctxt in CONFIG_FILES.iteritems():
svcs = []
for svc in ctxt['services']:
svcs.append(svc)
if svcs:
_map[f] = svcs
return _map
def services():
''' Returns a list of services associate with this charm '''
_services = []
for v in restart_map().values():
_services = _services + v
return list(set(_services))
def get_ceilometer_context():
''' Retrieve a map of all current relation data for agent configuration '''
ctxt = {}
for hcontext in CONFIG_FILES[CEILOMETER_CONF]['hook_contexts']:
ctxt.update(hcontext())
return ctxt
def do_openstack_upgrade(configs):
"""
Perform an upgrade. Takes care of upgrading packages, rewriting
configs, database migrations and potentially any other post-upgrade
actions.
:param configs: The charms main OSConfigRenderer object.
"""
new_src = config('openstack-origin')
new_os_rel = get_os_codename_install_source(new_src)
log('Performing OpenStack upgrade to %s.' % (new_os_rel))
configure_installation_source(new_src)
dpkg_opts = [
'--option', 'Dpkg::Options::=--force-confnew',
'--option', 'Dpkg::Options::=--force-confdef',
]
apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
apt_install(packages=get_packages(),
options=dpkg_opts,
fatal=True)
# set CONFIGS to load templates from new release
configs.set_release(openstack_release=new_os_rel)
def get_packages():
packages = deepcopy(CEILOMETER_PACKAGES)
if (get_os_codename_install_source(
config('openstack-origin')) >= 'icehouse'):
packages = packages + ICEHOUSE_PACKAGES
return packages
def get_shared_secret():
"""
Returns the current shared secret for the ceilometer node. If the shared
secret does not exist, this method will generate one.
"""
secret = None
if not os.path.exists(SHARED_SECRET):
secret = str(uuid.uuid4())
set_shared_secret(secret)
else:
with open(SHARED_SECRET, 'r') as secret_file:
secret = secret_file.read().strip()
return secret
def set_shared_secret(secret):
"""
Sets the shared secret which is used to sign ceilometer messages.
:param secret: the secret to set
"""
with open(SHARED_SECRET, 'w') as secret_file:
secret_file.write(secret)

View File

@ -146,6 +146,11 @@ options:
description: |
Default multicast port number that will be used to communicate between
HA Cluster nodes.
api-workers:
type: int
default: 1
description: |
Number of workers for Ceilometer API server. (>= Kilo).
action-managed-upgrade:
type: boolean
default: False

View File

@ -1,121 +0,0 @@
from charmhelpers.core.hookenv import (
relation_ids,
relation_get,
related_units,
config
)
from charmhelpers.contrib.openstack.utils import os_release
from charmhelpers.contrib.openstack.context import (
OSContextGenerator,
context_complete,
ApacheSSLContext as SSLContext,
)
from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
determine_api_port
)
CEILOMETER_DB = 'ceilometer'
class LoggingConfigContext(OSContextGenerator):
def __call__(self):
return {'debug': config('debug'), 'verbose': config('verbose')}
class MongoDBContext(OSContextGenerator):
interfaces = ['mongodb']
def __call__(self):
mongo_servers = []
replset = None
use_replset = os_release('ceilometer-api') >= 'icehouse'
for relid in relation_ids('shared-db'):
rel_units = related_units(relid)
use_replset = use_replset and (len(rel_units) > 1)
for unit in rel_units:
host = relation_get('hostname', unit, relid)
port = relation_get('port', unit, relid)
conf = {
"db_host": host,
"db_port": port,
"db_name": CEILOMETER_DB
}
if not context_complete(conf):
continue
if not use_replset:
return conf
if replset is None:
replset = relation_get('replset', unit, relid)
mongo_servers.append('{}:{}'.format(host, port))
if mongo_servers:
return {
'db_mongo_servers': ','.join(mongo_servers),
'db_name': CEILOMETER_DB,
'db_replset': replset
}
return {}
CEILOMETER_PORT = 8777
class CeilometerContext(OSContextGenerator):
def __call__(self):
# Lazy-import to avoid a circular dependency in the imports
from ceilometer_utils import get_shared_secret
ctxt = {
'port': CEILOMETER_PORT,
'metering_secret': get_shared_secret()
}
return ctxt
class CeilometerServiceContext(OSContextGenerator):
interfaces = ['ceilometer-service']
def __call__(self):
for relid in relation_ids('ceilometer-service'):
for unit in related_units(relid):
conf = relation_get(unit=unit, rid=relid)
if context_complete(conf):
return conf
return {}
class HAProxyContext(OSContextGenerator):
interfaces = ['ceilometer-haproxy']
def __call__(self):
'''Extends the main charmhelpers HAProxyContext with a port mapping
specific to this charm.
'''
haproxy_port = CEILOMETER_PORT
api_port = determine_api_port(CEILOMETER_PORT, singlenode_mode=True)
apache_port = determine_apache_port(CEILOMETER_PORT,
singlenode_mode=True)
ctxt = {
'service_ports': {'ceilometer_api': [haproxy_port, apache_port]},
'port': api_port
}
return ctxt
class ApacheSSLContext(SSLContext):
external_ports = [CEILOMETER_PORT]
service_namespace = "ceilometer"

View File

@ -0,0 +1 @@
../ceilometer_contexts.py

View File

@ -66,8 +66,7 @@ CONFIGS = register_configs()
def install():
execd_preinstall()
origin = config('openstack-origin')
if (lsb_release()['DISTRIB_CODENAME'] == 'precise'
and origin == 'distro'):
if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and origin == 'distro'):
origin = 'cloud:precise-grizzly'
configure_installation_source(origin)
apt_update(fatal=True)

View File

@ -1,225 +0,0 @@
import os
import uuid
from collections import OrderedDict
from charmhelpers.contrib.openstack import (
templating,
context,
)
from ceilometer_contexts import (
ApacheSSLContext,
LoggingConfigContext,
MongoDBContext,
CeilometerContext,
HAProxyContext
)
from charmhelpers.contrib.openstack.utils import (
get_os_codename_package,
get_os_codename_install_source,
configure_installation_source
)
from charmhelpers.core.hookenv import config, log
from charmhelpers.fetch import apt_update, apt_install, apt_upgrade
from copy import deepcopy
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
CEILOMETER_CONF_DIR = "/etc/ceilometer"
CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR
HTTPS_APACHE_CONF = "/etc/apache2/sites-available/openstack_https_frontend"
HTTPS_APACHE_24_CONF = "/etc/apache2/sites-available/" \
"openstack_https_frontend.conf"
CLUSTER_RES = 'grp_ceilometer_vips'
CEILOMETER_SERVICES = [
'ceilometer-agent-central',
'ceilometer-collector',
'ceilometer-api',
'ceilometer-alarm-evaluator',
'ceilometer-alarm-notifier',
'ceilometer-agent-notification',
]
CEILOMETER_DB = "ceilometer"
CEILOMETER_SERVICE = "ceilometer"
CEILOMETER_PACKAGES = [
'haproxy',
'apache2',
'ceilometer-agent-central',
'ceilometer-collector',
'ceilometer-api',
'python-pymongo',
]
ICEHOUSE_PACKAGES = [
'ceilometer-alarm-notifier',
'ceilometer-alarm-evaluator',
'ceilometer-agent-notification'
]
ICEHOUSE_SERVICES = [
'ceilometer-alarm-notifier',
'ceilometer-alarm-evaluator',
'ceilometer-agent-notification'
]
CEILOMETER_ROLE = "ResellerAdmin"
SVC = 'ceilometer'
CONFIG_FILES = OrderedDict([
(CEILOMETER_CONF, {
'hook_contexts': [context.IdentityServiceContext(service=SVC,
service_user=SVC),
context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR),
LoggingConfigContext(),
MongoDBContext(),
CeilometerContext(),
context.SyslogContext(),
HAProxyContext()],
'services': CEILOMETER_SERVICES
}),
(HAPROXY_CONF, {
'hook_contexts': [context.HAProxyContext(singlenode_mode=True),
HAProxyContext()],
'services': ['haproxy'],
}),
(HTTPS_APACHE_CONF, {
'hook_contexts': [ApacheSSLContext()],
'services': ['apache2'],
}),
(HTTPS_APACHE_24_CONF, {
'hook_contexts': [ApacheSSLContext()],
'services': ['apache2'],
})
])
TEMPLATES = 'templates'
SHARED_SECRET = "/etc/ceilometer/secret.txt"
def register_configs():
"""
Register config files with their respective contexts.
Regstration of some configs may not be required depending on
existing of certain relations.
"""
# if called without anything installed (eg during install hook)
# just default to earliest supported release. configs dont get touched
# till post-install, anyway.
release = get_os_codename_package('ceilometer-common', fatal=False) \
or 'grizzly'
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release)
if (get_os_codename_install_source(config('openstack-origin'))
>= 'icehouse'):
CONFIG_FILES[CEILOMETER_CONF]['services'] = \
CONFIG_FILES[CEILOMETER_CONF]['services'] + ICEHOUSE_SERVICES
for conf in CONFIG_FILES:
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
if os.path.exists('/etc/apache2/conf-available'):
configs.register(HTTPS_APACHE_24_CONF,
CONFIG_FILES[HTTPS_APACHE_24_CONF]['hook_contexts'])
else:
configs.register(HTTPS_APACHE_CONF,
CONFIG_FILES[HTTPS_APACHE_CONF]['hook_contexts'])
return configs
def restart_map():
'''
Determine the correct resource map to be passed to
charmhelpers.core.restart_on_change() based on the services configured.
:returns: dict: A dictionary mapping config file to lists of services
that should be restarted when file changes.
'''
_map = {}
for f, ctxt in CONFIG_FILES.iteritems():
svcs = []
for svc in ctxt['services']:
svcs.append(svc)
if svcs:
_map[f] = svcs
return _map
def services():
''' Returns a list of services associate with this charm '''
_services = []
for v in restart_map().values():
_services = _services + v
return list(set(_services))
def get_ceilometer_context():
''' Retrieve a map of all current relation data for agent configuration '''
ctxt = {}
for hcontext in CONFIG_FILES[CEILOMETER_CONF]['hook_contexts']:
ctxt.update(hcontext())
return ctxt
def do_openstack_upgrade(configs):
"""
Perform an upgrade. Takes care of upgrading packages, rewriting
configs, database migrations and potentially any other post-upgrade
actions.
:param configs: The charms main OSConfigRenderer object.
"""
new_src = config('openstack-origin')
new_os_rel = get_os_codename_install_source(new_src)
log('Performing OpenStack upgrade to %s.' % (new_os_rel))
configure_installation_source(new_src)
dpkg_opts = [
'--option', 'Dpkg::Options::=--force-confnew',
'--option', 'Dpkg::Options::=--force-confdef',
]
apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
apt_install(packages=get_packages(),
options=dpkg_opts,
fatal=True)
# set CONFIGS to load templates from new release
configs.set_release(openstack_release=new_os_rel)
def get_packages():
packages = deepcopy(CEILOMETER_PACKAGES)
if (get_os_codename_install_source(config('openstack-origin'))
>= 'icehouse'):
packages = packages + ICEHOUSE_PACKAGES
return packages
def get_shared_secret():
"""
Returns the current shared secret for the ceilometer node. If the shared
secret does not exist, this method will generate one.
"""
secret = None
if not os.path.exists(SHARED_SECRET):
secret = str(uuid.uuid4())
set_shared_secret(secret)
else:
with open(SHARED_SECRET, 'r') as secret_file:
secret = secret_file.read().strip()
return secret
def set_shared_secret(secret):
"""
Sets the shared secret which is used to sign ceilometer messages.
:param secret: the secret to set
"""
with open(SHARED_SECRET, 'w') as secret_file:
secret_file.write(secret)

1
hooks/ceilometer_utils.py Symbolic link
View File

@ -0,0 +1 @@
../ceilometer_utils.py

1
hooks/charmhelpers Symbolic link
View File

@ -0,0 +1 @@
../charmhelpers

View File

@ -0,0 +1,43 @@
# kilo
###############################################################################
# [ WARNING ]
# ceilometer configuration file maintained by Juju
# local changes may be overwritten.
###############################################################################
[DEFAULT]
debug = {{ debug }}
verbose = {{ verbose }}
use_syslog = {{ use_syslog }}
api_workers = {{ api_workers }}
{% include "parts/rabbitmq" -%}
[api]
port = {{ port }}
[service_credentials]
os_auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
os_tenant_name = {{ admin_tenant_name }}
os_username = {{ admin_user }}
os_password = {{ admin_password }}
[database]
{% if db_replset: -%}
connection = mongodb://{{ db_mongo_servers }}/{{ db_name }}?readPreference=primaryPreferred&replicaSet={{ db_replset }}
mongodb_replica_set = {{ db_replset }}
{% else -%}
connection = mongodb://{{ db_host }}:{{ db_port }}/{{ db_name }}
{% endif %}
[publisher_rpc]
metering_secret = {{ metering_secret }}
[keystone_authtoken]
auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/
auth_host = {{ auth_host }}
auth_port = {{ auth_port }}
auth_protocol = {{ auth_protocol }}
admin_tenant_name = {{ admin_tenant_name }}
admin_user = {{ admin_user }}
admin_password = {{ admin_password }}
signing_dir = {{ signing_dir }}

View File

@ -1,9 +1,12 @@
#!/usr/bin/python
import subprocess
"""
Basic ceilometer functional tests.
"""
import amulet
import json
import time
from ceilometerclient.v2 import client as ceilclient
@ -107,6 +110,32 @@ class CeilometerBasicDeployment(OpenStackAmuletDeployment):
endpoint_type='publicURL')
self.ceil = ceilclient.Client(endpoint=ep, token=self._get_token)
def _run_action(self, unit_id, action, *args):
command = ["juju", "action", "do", "--format=json", unit_id, action]
command.extend(args)
print("Running command: %s\n" % " ".join(command))
output = subprocess.check_output(command)
output_json = output.decode(encoding="UTF-8")
data = json.loads(output_json)
action_id = data[u'Action queued with id']
return action_id
def _wait_on_action(self, action_id):
command = ["juju", "action", "fetch", "--format=json", action_id]
while True:
try:
output = subprocess.check_output(command)
except Exception as e:
print(e)
return False
output_json = output.decode(encoding="UTF-8")
data = json.loads(output_json)
if data[u"status"] == "completed":
return True
elif data[u"status"] == "failed":
return False
time.sleep(2)
def test_100_services(self):
"""Verify the expected services are running on the corresponding
service units."""
@ -569,3 +598,18 @@ class CeilometerBasicDeployment(OpenStackAmuletDeployment):
sleep_time = 0
self.d.configure(juju_service, set_default)
def test_1000_pause_and_resume(self):
"""The services can be paused and resumed. """
unit_name = "ceilometer/0"
unit = self.d.sentry.unit[unit_name]
assert u.status_get(unit)[0] == "unknown"
action_id = self._run_action(unit_name, "pause")
assert self._wait_on_action(action_id), "Pause action failed."
assert u.status_get(unit)[0] == "maintenance"
action_id = self._run_action(unit_name, "resume")
assert self._wait_on_action(action_id), "Resume action failed."
assert u.status_get(unit)[0] == "active"

View File

@ -111,8 +111,11 @@ class CeilometerContextsTest(CharmTestCase):
@patch.object(utils, 'get_shared_secret')
def test_ceilometer_context(self, secret):
secret.return_value = 'mysecret'
self.assertEquals(contexts.CeilometerContext()(),
{'port': 8777, 'metering_secret': 'mysecret'})
self.assertEquals(contexts.CeilometerContext()(), {
'port': 8777,
'metering_secret': 'mysecret',
'api_workers': 1,
})
def test_ceilometer_service_context(self):
self.relation_ids.return_value = ['ceilometer-service:0']