Add support for setting the libvirt connection uri

This, for example, allows you to run libvirt with non-default
socket path.

Change-Id: Ia01f39f425cccc6acebd31f77b46b1948e24d215
Story: 2004344
Task: 27935
This commit is contained in:
Will Szumski 2018-11-14 16:40:28 +00:00
parent 4f20ed32f6
commit ffcdee61dd
8 changed files with 40 additions and 1 deletions

View File

@ -11,3 +11,22 @@ libvirt_pool_group: "{{ ansible_user_id }}"
# By default, allow QEMU without hardware virtualisation since this is a
# development tool.
libvirt_require_vt: false
# This determines the libvirt unix_sock_dir configuration option. You can set
# this option to the empty string if you want to use the default location. The
# main use case is to run multiple instances of libvirt side-by-side.
libvirt_custom_socket_path: ""
# Sets the path to the libvirtd PID file. You will need to change this if you
# want to run multiple instances of the libvirt daemon side-by-side.
libvirt_custom_pid_path: >-
{%- if libvirt_custom_socket_path -%}
{{ libvirt_custom_socket_path }}/libvirt.pid
{%- endif -%}
# This controls the libvirt connection URI. This value is used on commands run
# on the hypervisor (as opposed to remote connections).
libvirt_local_uri: >-
{%- if libvirt_custom_socket_path -%}
qemu+unix:///system?socket={{ libvirt_custom_socket_path }}/libvirt-sock
{%- endif %}

View File

@ -29,6 +29,9 @@
owner: "{{ libvirt_pool_owner }}"
group: "{{ libvirt_pool_group }}"
libvirt_host_require_vt: "{{ libvirt_require_vt }}"
libvirt_host_uri: "{{ libvirt_local_uri }}"
libvirt_host_socket_dir: "{{ libvirt_custom_socket_path }}"
libvirt_host_pid_path: "{{ libvirt_custom_pid_path }}"
- name: Set up Virtual BMC daemon
include_role:

View File

@ -28,6 +28,7 @@
name: virtualbmc-domain
vars:
vbmc_domain: "{{ domain }}"
vbmc_libvirt_uri: "{{ libvirt_local_uri }}"
vbmc_ipmi_address: "{{ ipmi_address }}"
vbmc_ipmi_username: "{{ ipmi_username }}"
vbmc_ipmi_password: "{{ ipmi_password }}"

View File

@ -16,6 +16,7 @@
include_role:
name: stackhpc.libvirt-vm
vars:
libvirt_vm_uri: "{{ libvirt_local_uri }}"
libvirt_vm_default_console_log_dir: "{{ log_directory }}"
# Configure VM definitions for the Libvirt provider.
# FIXME(w-miller): Set absent/present in tenks_schedule on a per-node

View File

@ -12,7 +12,12 @@
# The output format of this command gives two lines of header, followed by
# (for each vNIC):
# <name> <type> <source interface> <model> <MAC>
command: /usr/bin/virsh domiflist '{{ node.name }}'
command: >-
/usr/bin/virsh
{% if uri %}-c {{ uri }}{% endif %}
domiflist '{{ node.name }}'
vars:
uri: "{{ hostvars[ironic_hypervisor].libvirt_local_uri }}"
register: iflist_res
changed_when: false
become: true

View File

@ -15,3 +15,5 @@ vbmc_log_directory:
vbmc_virtualenv_path:
# Whether the domain should be `present` or `absent` in Virtual BMC.
vbmc_state: present
# libvirt connnection URI
vbmc_libvirt_uri:

View File

@ -45,6 +45,7 @@
--username '{{ vbmc_ipmi_username }}'
--password '{{ vbmc_ipmi_password }}'
--address {{ vbmc_ipmi_address }}
{% if vbmc_libvirt_uri %} --libvirt-uri '{{vbmc_libvirt_uri}}'{% endif %}
when: vbmc_state == 'present'
become: true
tags:

View File

@ -0,0 +1,7 @@
---
features:
- |
Adds support for setting the libvirt connection uri via the
``libvirt_local_uri`` variable. See
`this story <https://storyboard.openstack.org/#!/story/2004344>`_
for details.