Exemple #1
0
    def configure(self):
        # (dscannell) import the libvirt module to ensure that the the
        # libvirt flags can be read in.
        from nova.virt.libvirt import connection as libvirt_connection

        self.configure_path_permissions()

        self.libvirt_conn = libvirt_connection.get_connection(False)
        config.MANAGEMENT['connection_url'] = self.libvirt_conn.uri
        select_hypervisor('libvirt')
Exemple #2
0
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

    """
    # TODO(termie): maybe lazy load after initial check for permissions
    # TODO(termie): check whether we can be disconnected
    t = FLAGS.connection_type
    if t == 'fake':
        conn = fake.get_connection(read_only)
    elif t == 'libvirt':
        conn = libvirt_conn.get_connection(read_only)
    elif t == 'xenapi':
        conn = xenapi_conn.get_connection(read_only)
    elif t == 'vmwareapi':
        conn = vmwareapi_conn.get_connection(read_only)
    elif t == 'baremetal':
        conn = proxy.get_connection(read_only)
    else:
        raise Exception('Unknown connection type "%s"' % t)

    if conn is None:
        LOG.error(_('Failed to open connection to underlying virt platform'))
        sys.exit(1)
    return utils.check_isinstance(conn, driver.ComputeDriver)
Exemple #3
0
    def configure(self):
        # (dscannell) import the libvirt module to ensure that the the
        # libvirt flags can be read in.
        from nova.virt.libvirt import connection as libvirt_connection

        self.configure_path_permissions()

        openstack_user = self.determine_openstack_user()
        if isinstance(openstack_user, str):
            passwd = pwd.getpwnam(openstack_user)
        else:
            passwd = pwd.getpwuid(openstack_user)
        self.openstack_uid = passwd.pw_uid
        self.openstack_gid = passwd.pw_gid

        self.libvirt_conn = libvirt_connection.get_connection(False)
        config.MANAGEMENT['connection_url'] = self.libvirt_conn.uri
        select_hypervisor('libvirt')
Exemple #4
0
def get_connection(read_only=False):
    """
    Returns an object representing the connection to a virtualization
    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`.

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

    **Related flags**

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

                            * fake
                            * libvirt
                            * xenapi
    """
    # TODO(termie): maybe lazy load after initial check for permissions
    # TODO(termie): check whether we can be disconnected
    t = FLAGS.connection_type
    if t == 'fake':
        conn = fake.get_connection(read_only)
    elif t == 'libvirt':
        conn = libvirt_conn.get_connection(read_only)
    elif t == 'xenapi':
        conn = xenapi_conn.get_connection(read_only)
    elif t == 'hyperv':
        conn = hyperv.get_connection(read_only)
    elif t == 'vmwareapi':
        conn = vmwareapi_conn.get_connection(read_only)
    elif t == 'openvz':
        conn = openvz_conn.get_connection(read_only)
    else:
        raise Exception('Unknown connection type "%s"' % t)

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