Remove stderr spam when using salt-cloud with libvirt

Install error handler and redirect stderr output to debug log.
This commit is contained in:
Ric Klaren 2017-09-11 15:48:41 -05:00
parent 47cd8723c6
commit 9aecf5f847

View file

@ -82,9 +82,6 @@ from salt.exceptions import (
SaltCloudSystemExit
)
# Get logging started
log = logging.getLogger(__name__)
VIRT_STATE_NAME_MAP = {0: 'running',
1: 'running',
2: 'running',
@ -99,6 +96,18 @@ IP_LEARNING_XML = """<filterref filter='clean-traffic'>
__virtualname__ = 'libvirt'
# Set up logging
log = logging.getLogger(__name__)
def libvirtErrorHandler(ctx, error):
'''
Redirect stderr prints from libvirt to salt logging.
'''
log.debug("libvirt error {0}".format(error))
if HAS_LIBVIRT:
libvirt.registerErrorHandler(f=libvirtErrorHandler, ctx=None)
def __virtual__():
'''