コード例 #1
0
ファイル: driver.py プロジェクト: DavidYan/nova
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(_("Compute driver option required, but not specified"))
        sys.exit(1)

    LOG.info(_("Loading compute driver '%s'") % compute_driver)
    try:
        driver = importutils.import_object_ns('nova.virt',
                                              compute_driver,
                                              virtapi)
        return utils.check_isinstance(driver, ComputeDriver)
    except ImportError:
        LOG.exception(_("Unable to load the virtualization driver"))
        sys.exit(1)
コード例 #2
0
ファイル: __init__.py プロジェクト: dblundell/veta
def load_snapshot_driver():
    if not CONF.veta_snapshot_driver:
        LOG.error(_("Snapshot driver option required, but not specified"))
        sys.exit(1)

    LOG.info(_("Loading snapshot driver '%s'") % CONF.veta_snapshot_driver)
    try:
        driver = importutils.import_object_ns('veta.driver',
                                              CONF.veta_snapshot_driver)
        return utils.check_isinstance(driver, SnapshotDriver)
    except ImportError:
        LOG.exception(_("Unable to load the snapshot driver"))
        sys.exit(1)
コード例 #3
0
ファイル: connection.py プロジェクト: Mirantis/nova
def get_connection(read_only=False):
    """
    Returns an object representing the connection to a virtualization
    platform, or to an on-demand bare-metal provisioning platform.

    This could be :mod:`nova.virt.fake.FakeConnection` in test mode,
    a connection to KVM, QEMU, or UML via :mod:`libvirt_conn`, or a connection
    to XenServer or Xen Cloud Platform via :mod:`xenapi`. Other platforms are
    also supported.

    Any object returned here must conform to the interface documented by
    :mod:`FakeConnection`.

    **Related flags**

    :connection_type:  A string literal that falls through an if/elif structure
                       to determine what virtualization mechanism to use.
                       Values may be

                            * fake
                            * libvirt
                            * xenapi
                            * vmwareapi
                            * baremetal

    """
    deprecated.warn(_('Specifying virt driver via connection_type is '
                      'deprecated. Use compute_driver=classname instead.'))

    driver_name = known_drivers.get(FLAGS.connection_type)

    if driver_name is None:
        raise exception.VirtDriverNotFound(name=FLAGS.connection_type)

    conn = importutils.import_object_ns('nova.virt', driver_name,
                                        read_only=read_only)

    if conn is None:
        LOG.error(_('Failed to open connection to underlying virt platform'))
        sys.exit(1)
    return utils.check_isinstance(conn, driver.ComputeDriver)