Merge "Refactor rootwrap utilities"

This commit is contained in:
Zuul
2025-09-02 08:04:27 +00:00
committed by Gerrit Code Review
3 changed files with 4 additions and 14 deletions

View File

@@ -98,7 +98,7 @@ def create_heartbeat_service(worker_id, conf, queue=None):
def main():
sm = cotyledon.ServiceManager()
conf = _prepare_config()
priv_context.init(root_helper=shlex.split(utils._get_root_helper()))
priv_context.init(root_helper=shlex.split(utils.get_root_helper(conf)))
oslo_config_glue.setup(sm, conf)
if conf.polling.heartbeat_socket_dir is not None:

View File

@@ -24,7 +24,6 @@ from ceilometer import keystone_client
from ceilometer import messaging
from ceilometer import opts
from ceilometer import sample
from ceilometer import utils
from ceilometer import version
@@ -53,7 +52,6 @@ def prepare_service(argv=None, config_files=None, conf=None):
keystone_client.post_register_keystoneauth_opts(conf)
log.setup(conf, 'ceilometer')
utils.setup_root_helper(conf)
sample.setup(conf)
gmr_opts.set_defaults(conf)

View File

@@ -23,24 +23,16 @@ import threading
from oslo_config import cfg
from oslo_utils import timeutils
ROOTWRAP_CONF = "/etc/ceilometer/rootwrap.conf"
OPTS = [
cfg.StrOpt('rootwrap_config',
default=ROOTWRAP_CONF,
default='/etc/ceilometer/rootwrap.conf',
help='Path to the rootwrap configuration file to '
'use for running commands as root'),
]
def _get_root_helper():
global ROOTWRAP_CONF
return 'sudo ceilometer-rootwrap %s' % ROOTWRAP_CONF
def setup_root_helper(conf):
global ROOTWRAP_CONF
ROOTWRAP_CONF = conf.rootwrap_config
def get_root_helper(conf):
return 'sudo ceilometer-rootwrap %s' % conf.rootwrap_config
def spawn_thread(target, *args, **kwargs):