def load_container_driver(container_driver=None):
"""Load a container driver module.
Load the container driver module specified by the container_driver
configuration option or, if supplied, the driver name supplied as an
argument.
:param container_driver: a container driver name to override the config opt
:returns: a ContainerDriver instance
"""
if not container_driver:
container_driver = CONF.container_driver
if not container_driver:
LOG.error("Container driver option required, "
"but not specified")
sys.exit(1)
LOG.info("Loading container driver '%s'", container_driver)
try:
if not container_driver.startswith('zun.'):
container_driver = 'zun.container.%s' % container_driver
driver = importutils.import_object(container_driver)
if not isinstance(driver, ContainerDriver):
raise Exception(_('Expected driver of type: %s') %
str(ContainerDriver))
return driver
except ImportError:
LOG.exception("Unable to load the container driver")
sys.exit(1)
评论列表
文章目录