nova 根据conf动态加载虚拟化驱动

在nova/virt/driver.py 中的ComputeDriver 类中定义了load_compute_driver来加载用于虚拟化的driver。
def load_compute_driver(virtapi, compute_driver=None):
    """Load a compute driver module.

    Load the compute driver module specified by the compute_driver
    configuration option or, if supplied, the driver name supplied as an
    argument.

    Compute drivers constructors take a VirtAPI object as their first object
    and this must be supplied.

    :param virtapi: a VirtAPI instance
    :param compute_driver: a compute driver name to override the config opt
    :returns: a ComputeDriver instance
    """
    if not compute_driver:
        compute_driver = CONF.compute_driver

    if not compute_driver:
        LOG.error(_LE("Compute driver option required, but not specified"))
        sys.exit(1)

    LOG.info(_LI("Loading compute driver '%s'"), compute_driver)
    try:
        driver = importutils.import_object(
            'nova.virt.%s' % compute_driver,
            virtapi)
        return utils.check_isinstance(driver, ComputeDriver)
    except ImportError:
        LOG.exception(_LE("Unable to load the virtualization driver"))
        sys.exit(1)
可以compute_driver 是在CONF.compute_driver得到的,本例中compute_driver=libvirt.LibvirtDriver
因此最终会通过import_object 导入nova.virt.libvirt.LibvirtDriver

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值