Merge "Support specify connection uri for libvirt"

This commit is contained in:
Jenkins 2017-09-04 07:23:56 +00:00 committed by Gerrit Code Review
commit 03c15cf743
2 changed files with 13 additions and 3 deletions

View File

@ -25,12 +25,20 @@ monitor_callback_opts = [
' is error(in seconds).'),
]
libvirt_opts = [
cfg.StrOpt('connection_uri',
default='qemu:///system',
help='Override the default libvirt URI.')
]
def register_opts(conf):
conf.register_opts(monitor_callback_opts, group='callback')
conf.register_opts(libvirt_opts, group='libvirt')
def list_opts():
return {
'callback': monitor_callback_opts
'callback': monitor_callback_opts,
'libvirt': libvirt_opts
}

View File

@ -17,12 +17,14 @@ import time
import eventlet
import libvirt
from oslo_config import cfg
from oslo_log import log as oslo_logging
from masakarimonitors.instancemonitor.libvirt_handler import eventfilter
from masakarimonitors import manager
LOG = oslo_logging.getLogger(__name__)
CONF = cfg.CONF
class InstancemonitorManager(manager.Manager):
@ -120,7 +122,7 @@ class InstancemonitorManager(manager.Manager):
libvirt.VIR_DOMAIN_EVENT_ID_CONTROL_ERROR:
self._my_domain_event_generic_callback
}
# Connect to libvert - If be disconnected, reprocess.
# Connect to libvirt - If be disconnected, reprocess.
self.running = True
while self.running:
vc = libvirt.openReadOnly(uri)
@ -156,7 +158,7 @@ class InstancemonitorManager(manager.Manager):
Set the URI, error handler, and executes event loop processing.
"""
uri = "qemu:///system"
uri = CONF.libvirt.connection_uri
LOG.debug("Using uri:" + uri)
# set error handler & do event loop