Add support for configurable hugepages
This commit is contained in:
parent
60e336fa26
commit
182f9602ee
@ -1,4 +1,4 @@
|
||||
branch: lp:charm-helpers
|
||||
branch: lp:~james-page/charm-helpers/vpp-rebase
|
||||
destination: hooks/charmhelpers
|
||||
include:
|
||||
- core
|
||||
|
@ -250,3 +250,10 @@ options:
|
||||
stipulated by nova-cloud-controller. The option is only available for
|
||||
backward compatibility for deployments which do not use the neutron-api
|
||||
charm. Please do not enable this on new deployments.
|
||||
# Huge page configuration - off by default
|
||||
hugepages:
|
||||
type: string
|
||||
default:
|
||||
description: |
|
||||
The pecentage of system memory to use for hugepages eg '10%' or the total
|
||||
number of 2M hugepages - eg "1024".
|
||||
|
@ -152,15 +152,11 @@ class CommandLine(object):
|
||||
arguments = self.argument_parser.parse_args()
|
||||
argspec = inspect.getargspec(arguments.func)
|
||||
vargs = []
|
||||
kwargs = {}
|
||||
for arg in argspec.args:
|
||||
vargs.append(getattr(arguments, arg))
|
||||
if argspec.varargs:
|
||||
vargs.extend(getattr(arguments, argspec.varargs))
|
||||
if argspec.keywords:
|
||||
for kwarg in argspec.keywords.items():
|
||||
kwargs[kwarg] = getattr(arguments, kwarg)
|
||||
output = arguments.func(*vargs, **kwargs)
|
||||
output = arguments.func(*vargs)
|
||||
if getattr(arguments.func, '_cli_test_command', False):
|
||||
self.exit_code = 0 if output else 1
|
||||
output = ''
|
||||
|
@ -26,7 +26,7 @@ from . import CommandLine # noqa
|
||||
"""
|
||||
Import the sub-modules which have decorated subcommands to register with chlp.
|
||||
"""
|
||||
import host # noqa
|
||||
import benchmark # noqa
|
||||
import unitdata # noqa
|
||||
from charmhelpers.core import hookenv # noqa
|
||||
from . import host # noqa
|
||||
from . import benchmark # noqa
|
||||
from . import unitdata # noqa
|
||||
from . import hookenv # noqa
|
||||
|
23
hooks/charmhelpers/cli/hookenv.py
Normal file
23
hooks/charmhelpers/cli/hookenv.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2014-2015 Canonical Limited.
|
||||
#
|
||||
# This file is part of charm-helpers.
|
||||
#
|
||||
# charm-helpers is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# charm-helpers is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import cmdline
|
||||
from charmhelpers.core import hookenv
|
||||
|
||||
|
||||
cmdline.subcommand('relation-id')(hookenv.relation_id._wrapped)
|
||||
cmdline.subcommand('service-name')(hookenv.service_name)
|
||||
cmdline.subcommand('remote-service-name')(hookenv.remote_service_name._wrapped)
|
@ -44,7 +44,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
Determine if the local branch being tested is derived from its
|
||||
stable or next (dev) branch, and based on this, use the corresonding
|
||||
stable or next branches for the other_services."""
|
||||
base_charms = ['mysql', 'mongodb']
|
||||
base_charms = ['mysql', 'mongodb', 'nrpe']
|
||||
|
||||
if self.series in ['precise', 'trusty']:
|
||||
base_series = self.series
|
||||
@ -53,11 +53,15 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
|
||||
if self.stable:
|
||||
for svc in other_services:
|
||||
if svc.get('location'):
|
||||
continue
|
||||
temp = 'lp:charms/{}/{}'
|
||||
svc['location'] = temp.format(base_series,
|
||||
svc['name'])
|
||||
else:
|
||||
for svc in other_services:
|
||||
if svc.get('location'):
|
||||
continue
|
||||
if svc['name'] in base_charms:
|
||||
temp = 'lp:charms/{}/{}'
|
||||
svc['location'] = temp.format(base_series,
|
||||
@ -81,7 +85,8 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
'ceph-osd', 'ceph-radosgw']
|
||||
# Most OpenStack subordinate charms do not expose an origin option
|
||||
# as that is controlled by the principle.
|
||||
ignore = ['cinder-ceph', 'hacluster', 'neutron-openvswitch']
|
||||
ignore = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
|
||||
'cisco-vpp', 'odl-controller']
|
||||
|
||||
if self.openstack:
|
||||
for svc in services:
|
||||
|
@ -37,6 +37,31 @@ class OSConfigException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def os_template_dirs(templates_dir, os_release):
|
||||
tmpl_dirs = [(rel, os.path.join(templates_dir, rel))
|
||||
for rel in six.itervalues(OPENSTACK_CODENAMES)]
|
||||
|
||||
if not os.path.isdir(templates_dir):
|
||||
log('Templates directory not found @ %s.' % templates_dir,
|
||||
level=ERROR)
|
||||
raise OSConfigException
|
||||
dirs = [templates_dir]
|
||||
helper_templates = os.path.join(os.path.dirname(__file__), 'templates')
|
||||
if os.path.isdir(helper_templates):
|
||||
dirs.append(helper_templates)
|
||||
|
||||
for rel, tmpl_dir in tmpl_dirs:
|
||||
if os.path.isdir(tmpl_dir):
|
||||
dirs.insert(0, tmpl_dir)
|
||||
if rel == os_release:
|
||||
break
|
||||
ch_templates = os.path.dirname(__file__) + '/charmhelpers/contrib/openstack/templates'
|
||||
dirs.append(ch_templates)
|
||||
log('Template search path: %s' %
|
||||
' '.join(dirs), level=INFO)
|
||||
return dirs
|
||||
|
||||
|
||||
def get_loader(templates_dir, os_release):
|
||||
"""
|
||||
Create a jinja2.ChoiceLoader containing template dirs up to
|
||||
|
@ -24,6 +24,8 @@ import subprocess
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
import re
|
||||
|
||||
import six
|
||||
import yaml
|
||||
@ -40,7 +42,8 @@ from charmhelpers.core.hookenv import (
|
||||
charm_dir,
|
||||
INFO,
|
||||
relation_ids,
|
||||
relation_set
|
||||
related_units,
|
||||
relation_set,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.storage.linux.lvm import (
|
||||
@ -69,7 +72,6 @@ CLOUD_ARCHIVE_KEY_ID = '5EDB1B62EC4926EA'
|
||||
DISTRO_PROPOSED = ('deb http://archive.ubuntu.com/ubuntu/ %s-proposed '
|
||||
'restricted main multiverse universe')
|
||||
|
||||
|
||||
UBUNTU_OPENSTACK_RELEASE = OrderedDict([
|
||||
('oneiric', 'diablo'),
|
||||
('precise', 'essex'),
|
||||
@ -118,6 +120,34 @@ SWIFT_CODENAMES = OrderedDict([
|
||||
('2.3.0', 'liberty'),
|
||||
])
|
||||
|
||||
# >= Liberty version->codename mapping
|
||||
PACKAGE_CODENAMES = {
|
||||
'nova-common': OrderedDict([
|
||||
('12.0.0', 'liberty'),
|
||||
]),
|
||||
'neutron-common': OrderedDict([
|
||||
('7.0.0', 'liberty'),
|
||||
]),
|
||||
'cinder-common': OrderedDict([
|
||||
('7.0.0', 'liberty'),
|
||||
]),
|
||||
'keystone': OrderedDict([
|
||||
('8.0.0', 'liberty'),
|
||||
]),
|
||||
'horizon-common': OrderedDict([
|
||||
('8.0.0', 'liberty'),
|
||||
]),
|
||||
'ceilometer-common': OrderedDict([
|
||||
('5.0.0', 'liberty'),
|
||||
]),
|
||||
'heat-common': OrderedDict([
|
||||
('5.0.0', 'liberty'),
|
||||
]),
|
||||
'glance-common': OrderedDict([
|
||||
('11.0.0', 'liberty'),
|
||||
]),
|
||||
}
|
||||
|
||||
DEFAULT_LOOPBACK_SIZE = '5G'
|
||||
|
||||
|
||||
@ -201,20 +231,29 @@ def get_os_codename_package(package, fatal=True):
|
||||
error_out(e)
|
||||
|
||||
vers = apt.upstream_version(pkg.current_ver.ver_str)
|
||||
match = re.match('^(\d)\.(\d)\.(\d)', vers)
|
||||
if match:
|
||||
vers = match.group(0)
|
||||
|
||||
try:
|
||||
if 'swift' in pkg.name:
|
||||
swift_vers = vers[:5]
|
||||
if swift_vers not in SWIFT_CODENAMES:
|
||||
# Deal with 1.10.0 upward
|
||||
swift_vers = vers[:6]
|
||||
return SWIFT_CODENAMES[swift_vers]
|
||||
else:
|
||||
vers = vers[:6]
|
||||
return OPENSTACK_CODENAMES[vers]
|
||||
except KeyError:
|
||||
e = 'Could not determine OpenStack codename for version %s' % vers
|
||||
error_out(e)
|
||||
# >= Liberty independent project versions
|
||||
if (package in PACKAGE_CODENAMES and
|
||||
vers in PACKAGE_CODENAMES[package]):
|
||||
return PACKAGE_CODENAMES[package][vers]
|
||||
else:
|
||||
# < Liberty co-ordinated project versions
|
||||
try:
|
||||
if 'swift' in pkg.name:
|
||||
swift_vers = vers[:5]
|
||||
if swift_vers not in SWIFT_CODENAMES:
|
||||
# Deal with 1.10.0 upward
|
||||
swift_vers = vers[:6]
|
||||
return SWIFT_CODENAMES[swift_vers]
|
||||
else:
|
||||
vers = vers[:6]
|
||||
return OPENSTACK_CODENAMES[vers]
|
||||
except KeyError:
|
||||
e = 'Could not determine OpenStack codename for version %s' % vers
|
||||
error_out(e)
|
||||
|
||||
|
||||
def get_os_version_package(pkg, fatal=True):
|
||||
@ -704,3 +743,19 @@ def git_yaml_value(projects_yaml, key):
|
||||
return projects[key]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def remote_restart(rel_name, remote_service=None):
|
||||
trigger = {
|
||||
'restart-trigger': str(uuid.uuid4()),
|
||||
}
|
||||
if remote_service:
|
||||
trigger['remote-service'] = remote_service
|
||||
for rid in relation_ids(rel_name):
|
||||
# This subordinate can be related to two seperate services using
|
||||
# different subordinate relations so only issue the restart if
|
||||
# thr principle is conencted down the relation we think it is
|
||||
if related_units(relid=rid):
|
||||
relation_set(relation_id=rid,
|
||||
relation_settings=trigger,
|
||||
)
|
||||
|
@ -43,9 +43,10 @@ def zap_disk(block_device):
|
||||
|
||||
:param block_device: str: Full path of block device to clean.
|
||||
'''
|
||||
# https://github.com/ceph/ceph/commit/fdd7f8d83afa25c4e09aaedd90ab93f3b64a677b
|
||||
# sometimes sgdisk exits non-zero; this is OK, dd will clean up
|
||||
call(['sgdisk', '--zap-all', '--mbrtogpt',
|
||||
'--clear', block_device])
|
||||
call(['sgdisk', '--zap-all', '--', block_device])
|
||||
call(['sgdisk', '--clear', '--mbrtogpt', '--', block_device])
|
||||
dev_end = check_output(['blockdev', '--getsz',
|
||||
block_device]).decode('UTF-8')
|
||||
gpt_end = int(dev_end.split()[0]) - 100
|
||||
|
@ -34,23 +34,6 @@ import errno
|
||||
import tempfile
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
try:
|
||||
from charmhelpers.cli import cmdline
|
||||
except ImportError as e:
|
||||
# due to the anti-pattern of partially synching charmhelpers directly
|
||||
# into charms, it's possible that charmhelpers.cli is not available;
|
||||
# if that's the case, they don't really care about using the cli anyway,
|
||||
# so mock it out
|
||||
if str(e) == 'No module named cli':
|
||||
class cmdline(object):
|
||||
@classmethod
|
||||
def subcommand(cls, *args, **kwargs):
|
||||
def _wrap(func):
|
||||
return func
|
||||
return _wrap
|
||||
else:
|
||||
raise
|
||||
|
||||
import six
|
||||
if not six.PY3:
|
||||
from UserDict import UserDict
|
||||
@ -91,6 +74,7 @@ def cached(func):
|
||||
res = func(*args, **kwargs)
|
||||
cache[key] = res
|
||||
return res
|
||||
wrapper._wrapped = func
|
||||
return wrapper
|
||||
|
||||
|
||||
@ -190,7 +174,6 @@ def relation_type():
|
||||
return os.environ.get('JUJU_RELATION', None)
|
||||
|
||||
|
||||
@cmdline.subcommand()
|
||||
@cached
|
||||
def relation_id(relation_name=None, service_or_unit=None):
|
||||
"""The relation ID for the current or a specified relation"""
|
||||
@ -216,13 +199,11 @@ def remote_unit():
|
||||
return os.environ.get('JUJU_REMOTE_UNIT', None)
|
||||
|
||||
|
||||
@cmdline.subcommand()
|
||||
def service_name():
|
||||
"""The name service group this unit belongs to"""
|
||||
return local_unit().split('/')[0]
|
||||
|
||||
|
||||
@cmdline.subcommand()
|
||||
@cached
|
||||
def remote_service_name(relid=None):
|
||||
"""The remote service name for a given relation-id (or the current relation)"""
|
||||
|
@ -72,7 +72,7 @@ def service_pause(service_name, init_dir=None):
|
||||
stopped = service_stop(service_name)
|
||||
# XXX: Support systemd too
|
||||
override_path = os.path.join(
|
||||
init_dir, '{}.conf.override'.format(service_name))
|
||||
init_dir, '{}.override'.format(service_name))
|
||||
with open(override_path, 'w') as fh:
|
||||
fh.write("manual\n")
|
||||
return stopped
|
||||
@ -86,7 +86,7 @@ def service_resume(service_name, init_dir=None):
|
||||
if init_dir is None:
|
||||
init_dir = "/etc/init"
|
||||
override_path = os.path.join(
|
||||
init_dir, '{}.conf.override'.format(service_name))
|
||||
init_dir, '{}.override'.format(service_name))
|
||||
if os.path.exists(override_path):
|
||||
os.unlink(override_path)
|
||||
started = service_start(service_name)
|
||||
@ -148,6 +148,15 @@ def adduser(username, password=None, shell='/bin/bash', system_user=False):
|
||||
return user_info
|
||||
|
||||
|
||||
def user_exists(username):
|
||||
try:
|
||||
user_info = pwd.getpwnam(username)
|
||||
user_exists = True
|
||||
except KeyError:
|
||||
user_exists = False
|
||||
return user_exists
|
||||
|
||||
|
||||
def add_group(group_name, system_group=False):
|
||||
"""Add a group to the system"""
|
||||
try:
|
||||
@ -280,6 +289,17 @@ def mounts():
|
||||
return system_mounts
|
||||
|
||||
|
||||
|
||||
def fstab_mount(mountpoint):
|
||||
cmd_args = ['mount', mountpoint]
|
||||
try:
|
||||
subprocess.check_output(cmd_args)
|
||||
except subprocess.CalledProcessError as e:
|
||||
log('Error unmounting {}\n{}'.format(mountpoint, e.output))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def file_hash(path, hash_type='md5'):
|
||||
"""
|
||||
Generate a hash checksum of the contents of 'path' or None if not found.
|
||||
|
54
hooks/charmhelpers/core/hugepage.py
Normal file
54
hooks/charmhelpers/core/hugepage.py
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2014-2015 Canonical Limited.
|
||||
#
|
||||
# This file is part of charm-helpers.
|
||||
#
|
||||
# charm-helpers is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# charm-helpers is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import yaml
|
||||
from charmhelpers.core.fstab import Fstab
|
||||
from charmhelpers.core.sysctl import (
|
||||
create,
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
add_group,
|
||||
add_user_to_group,
|
||||
fstab_mount,
|
||||
mkdir,
|
||||
)
|
||||
|
||||
def hugepage_support(user, group='hugetlb', nr_hugepages=256,
|
||||
max_map_count=65536, mnt_point='/hugepages',
|
||||
pagesize='2MB', mount=True):
|
||||
group_info = add_group(group)
|
||||
gid = group_info.gr_gid
|
||||
add_user_to_group(user, group)
|
||||
sysctl_settings = {
|
||||
'vm.nr_hugepages': nr_hugepages,
|
||||
'vm.max_map_count': max_map_count, # 1GB
|
||||
'vm.hugetlb_shm_group': gid,
|
||||
}
|
||||
create(yaml.dump(sysctl_settings), '/etc/sysctl.d/10-hugepage.conf')
|
||||
mkdir(mnt_point, owner='root', group='root', perms=0o755, force=False)
|
||||
fstab = Fstab()
|
||||
fstab_entry = fstab.get_entry_by_attr('mountpoint', mnt_point)
|
||||
if fstab_entry:
|
||||
fstab.remove_entry(fstab_entry)
|
||||
entry = fstab.Entry('nodev', mnt_point, 'hugetlbfs',
|
||||
'mode=1770,gid={},pagesize={}'.format(gid, pagesize), 0, 0)
|
||||
fstab.add_entry(entry)
|
||||
if mount:
|
||||
fstab_mount(mnt_point)
|
@ -17,6 +17,7 @@
|
||||
import os
|
||||
import yaml
|
||||
from charmhelpers.core import hookenv
|
||||
from charmhelpers.core import host
|
||||
from charmhelpers.core import templating
|
||||
|
||||
from charmhelpers.core.services.base import ManagerCallback
|
||||
@ -244,23 +245,38 @@ class TemplateCallback(ManagerCallback):
|
||||
:param str owner: The owner of the rendered file
|
||||
:param str group: The group of the rendered file
|
||||
:param int perms: The permissions of the rendered file
|
||||
|
||||
:param list template_searchpath: List of paths to search for template in
|
||||
:param partial on_change_action: functools partial to be executed when
|
||||
rendered file changes
|
||||
"""
|
||||
def __init__(self, source, target,
|
||||
owner='root', group='root', perms=0o444):
|
||||
owner='root', group='root', perms=0o444,
|
||||
template_searchpath=None, on_change_action=None):
|
||||
self.source = source
|
||||
self.target = target
|
||||
self.owner = owner
|
||||
self.group = group
|
||||
self.perms = perms
|
||||
self.template_searchpath = template_searchpath
|
||||
self.on_change_action = on_change_action
|
||||
|
||||
def __call__(self, manager, service_name, event_name):
|
||||
pre_checksum = ''
|
||||
if self.on_change_action and os.path.isfile(self.target):
|
||||
pre_checksum = host.file_hash(self.target)
|
||||
print pre_checksum
|
||||
service = manager.get_service(service_name)
|
||||
context = {}
|
||||
for ctx in service.get('required_data', []):
|
||||
context.update(ctx)
|
||||
templating.render(self.source, self.target, context,
|
||||
self.owner, self.group, self.perms)
|
||||
self.owner, self.group, self.perms,
|
||||
self.template_searchpath)
|
||||
if self.on_change_action:
|
||||
if pre_checksum == host.file_hash(self.target):
|
||||
print "No change detected " + self.target
|
||||
else:
|
||||
self.on_change_action()
|
||||
|
||||
|
||||
# Convenience aliases for templates
|
||||
|
@ -21,7 +21,8 @@ from charmhelpers.core import hookenv
|
||||
|
||||
|
||||
def render(source, target, context, owner='root', group='root',
|
||||
perms=0o444, templates_dir=None, encoding='UTF-8'):
|
||||
perms=0o444, templates_dir=None, encoding='UTF-8',
|
||||
template_searchpath=None):
|
||||
"""
|
||||
Render a template.
|
||||
|
||||
@ -40,7 +41,7 @@ def render(source, target, context, owner='root', group='root',
|
||||
this will attempt to use charmhelpers.fetch.apt_install to install it.
|
||||
"""
|
||||
try:
|
||||
from jinja2 import FileSystemLoader, Environment, exceptions
|
||||
from jinja2 import ChoiceLoader, FileSystemLoader, Environment, exceptions
|
||||
except ImportError:
|
||||
try:
|
||||
from charmhelpers.fetch import apt_install
|
||||
@ -50,11 +51,17 @@ def render(source, target, context, owner='root', group='root',
|
||||
level=hookenv.ERROR)
|
||||
raise
|
||||
apt_install('python-jinja2', fatal=True)
|
||||
from jinja2 import FileSystemLoader, Environment, exceptions
|
||||
from jinja2 import ChoiceLoader, FileSystemLoader, Environment, exceptions
|
||||
|
||||
if templates_dir is None:
|
||||
templates_dir = os.path.join(hookenv.charm_dir(), 'templates')
|
||||
loader = Environment(loader=FileSystemLoader(templates_dir))
|
||||
if template_searchpath:
|
||||
fs_loaders = []
|
||||
for tmpl_dir in template_searchpath:
|
||||
fs_loaders.append(FileSystemLoader(tmpl_dir))
|
||||
loader = ChoiceLoader(fs_loaders)
|
||||
else:
|
||||
if templates_dir is None:
|
||||
templates_dir = os.path.join(hookenv.charm_dir(), 'templates')
|
||||
loader = Environment(loader=FileSystemLoader(templates_dir))
|
||||
try:
|
||||
source = source
|
||||
template = loader.get_template(source)
|
||||
|
@ -90,6 +90,14 @@ CLOUD_ARCHIVE_POCKETS = {
|
||||
'kilo/proposed': 'trusty-proposed/kilo',
|
||||
'trusty-kilo/proposed': 'trusty-proposed/kilo',
|
||||
'trusty-proposed/kilo': 'trusty-proposed/kilo',
|
||||
# Liberty
|
||||
'liberty': 'trusty-updates/liberty',
|
||||
'trusty-liberty': 'trusty-updates/liberty',
|
||||
'trusty-liberty/updates': 'trusty-updates/liberty',
|
||||
'trusty-updates/liberty': 'trusty-updates/liberty',
|
||||
'liberty/proposed': 'trusty-proposed/liberty',
|
||||
'trusty-liberty/proposed': 'trusty-proposed/liberty',
|
||||
'trusty-proposed/liberty': 'trusty-proposed/liberty',
|
||||
}
|
||||
|
||||
# The order of this list is very important. Handlers should be listed in from
|
||||
|
@ -65,6 +65,7 @@ from nova_compute_utils import (
|
||||
get_topics,
|
||||
assert_charm_supports_ipv6,
|
||||
manage_ovs,
|
||||
install_hugepages,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
@ -140,6 +141,8 @@ def config_changed():
|
||||
if is_relation_made("nrpe-external-master"):
|
||||
update_nrpe_config()
|
||||
|
||||
install_hugepages()
|
||||
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import pwd
|
||||
|
||||
from base64 import b64decode
|
||||
from copy import deepcopy
|
||||
from subprocess import check_call, check_output, CalledProcessError
|
||||
from subprocess import call, check_call, check_output, CalledProcessError
|
||||
|
||||
from charmhelpers.fetch import (
|
||||
apt_update,
|
||||
@ -54,6 +54,12 @@ from charmhelpers.contrib.python.packages import (
|
||||
pip_install,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hugepage import hugepage_support
|
||||
from charmhelpers.core.host import (
|
||||
fstab_mount,
|
||||
rsync,
|
||||
)
|
||||
|
||||
from nova_compute_context import (
|
||||
CloudComputeContext,
|
||||
MetadataServiceContext,
|
||||
@ -787,3 +793,36 @@ def git_post_install(projects_yaml):
|
||||
|
||||
apt_update()
|
||||
apt_install(LATE_GIT_PACKAGES, fatal=True)
|
||||
|
||||
|
||||
def install_hugepages():
|
||||
""" Configure hugepages """
|
||||
hugepage_config = config('hugepages')
|
||||
if hugepage_config:
|
||||
# TODO: defaults to 2M - this should probably be configurable
|
||||
# and support multiple pool sizes - e.g. 2M and 1G.
|
||||
hugepage_size = 2048
|
||||
if hugepage_config.endswith('%'):
|
||||
import psutil
|
||||
mem = psutil.virtual_memory()
|
||||
hugepage_config_pct = hugepage_config.strip('%')
|
||||
hugepage_multiplier = float(hugepage_config_pct) / 100
|
||||
hugepages = int((mem.total * hugepage_multiplier) / hugepage_size)
|
||||
else:
|
||||
hugepages = int(hugepage_config)
|
||||
mnt_point = '/mnt/huge'
|
||||
hugepage_support(
|
||||
'nova',
|
||||
mnt_point=mnt_point,
|
||||
group='root',
|
||||
nr_hugepages=hugepages,
|
||||
mount=False,
|
||||
)
|
||||
if call(['mountpoint', mnt_point]):
|
||||
fstab_mount(mnt_point)
|
||||
rsync(
|
||||
charm_dir() + '/files/qemu-hugefsdir',
|
||||
'/etc/init.d/qemu-hugefsdir'
|
||||
)
|
||||
check_call('/etc/init.d/qemu-hugefsdir')
|
||||
check_call(['update-rc.d', 'qemu-hugefsdir', 'defaults'])
|
||||
|
@ -14,17 +14,21 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import amulet
|
||||
import ConfigParser
|
||||
import distro_info
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
import sys
|
||||
import time
|
||||
import urlparse
|
||||
|
||||
import amulet
|
||||
import distro_info
|
||||
import six
|
||||
from six.moves import configparser
|
||||
if six.PY3:
|
||||
from urllib import parse as urlparse
|
||||
else:
|
||||
import urlparse
|
||||
|
||||
|
||||
class AmuletUtils(object):
|
||||
@ -142,19 +146,23 @@ class AmuletUtils(object):
|
||||
|
||||
for service_name in services_list:
|
||||
if (self.ubuntu_releases.index(release) >= systemd_switch or
|
||||
service_name == "rabbitmq-server"):
|
||||
# init is systemd
|
||||
service_name in ['rabbitmq-server', 'apache2']):
|
||||
# init is systemd (or regular sysv)
|
||||
cmd = 'sudo service {} status'.format(service_name)
|
||||
output, code = sentry_unit.run(cmd)
|
||||
service_running = code == 0
|
||||
elif self.ubuntu_releases.index(release) < systemd_switch:
|
||||
# init is upstart
|
||||
cmd = 'sudo status {}'.format(service_name)
|
||||
output, code = sentry_unit.run(cmd)
|
||||
service_running = code == 0 and "start/running" in output
|
||||
|
||||
output, code = sentry_unit.run(cmd)
|
||||
self.log.debug('{} `{}` returned '
|
||||
'{}'.format(sentry_unit.info['unit_name'],
|
||||
cmd, code))
|
||||
if code != 0:
|
||||
return "command `{}` returned {}".format(cmd, str(code))
|
||||
if not service_running:
|
||||
return u"command `{}` returned {} {}".format(
|
||||
cmd, output, str(code))
|
||||
return None
|
||||
|
||||
def _get_config(self, unit, filename):
|
||||
@ -164,7 +172,7 @@ class AmuletUtils(object):
|
||||
# NOTE(beisner): by default, ConfigParser does not handle options
|
||||
# with no value, such as the flags used in the mysql my.cnf file.
|
||||
# https://bugs.python.org/issue7005
|
||||
config = ConfigParser.ConfigParser(allow_no_value=True)
|
||||
config = configparser.ConfigParser(allow_no_value=True)
|
||||
config.readfp(io.StringIO(file_contents))
|
||||
return config
|
||||
|
||||
@ -507,11 +515,23 @@ class AmuletUtils(object):
|
||||
'{}'.format(e_proc_name, a_proc_name))
|
||||
|
||||
a_pids_length = len(a_pids)
|
||||
if e_pids_length != a_pids_length:
|
||||
return ('PID count mismatch. {} ({}) expected, actual: '
|
||||
fail_msg = ('PID count mismatch. {} ({}) expected, actual: '
|
||||
'{}, {} ({})'.format(e_sentry_name, e_proc_name,
|
||||
e_pids_length, a_pids_length,
|
||||
a_pids))
|
||||
|
||||
# If expected is not bool, ensure PID quantities match
|
||||
if not isinstance(e_pids_length, bool) and \
|
||||
a_pids_length != e_pids_length:
|
||||
return fail_msg
|
||||
# If expected is bool True, ensure 1 or more PIDs exist
|
||||
elif isinstance(e_pids_length, bool) and \
|
||||
e_pids_length is True and a_pids_length < 1:
|
||||
return fail_msg
|
||||
# If expected is bool False, ensure 0 PIDs exist
|
||||
elif isinstance(e_pids_length, bool) and \
|
||||
e_pids_length is False and a_pids_length != 0:
|
||||
return fail_msg
|
||||
else:
|
||||
self.log.debug('PID check OK: {} {} {}: '
|
||||
'{}'.format(e_sentry_name, e_proc_name,
|
||||
|
@ -44,7 +44,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
Determine if the local branch being tested is derived from its
|
||||
stable or next (dev) branch, and based on this, use the corresonding
|
||||
stable or next branches for the other_services."""
|
||||
base_charms = ['mysql', 'mongodb']
|
||||
base_charms = ['mysql', 'mongodb', 'nrpe']
|
||||
|
||||
if self.series in ['precise', 'trusty']:
|
||||
base_series = self.series
|
||||
@ -81,7 +81,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
|
||||
'ceph-osd', 'ceph-radosgw']
|
||||
# Most OpenStack subordinate charms do not expose an origin option
|
||||
# as that is controlled by the principle.
|
||||
ignore = ['cinder-ceph', 'hacluster', 'neutron-openvswitch']
|
||||
ignore = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe']
|
||||
|
||||
if self.openstack:
|
||||
for svc in services:
|
||||
|
Loading…
x
Reference in New Issue
Block a user