Specify which hypervisor to connect virsh to based on virt-type config.
This commit is contained in:
parent
56d7d0a563
commit
e88e585a7d
@ -128,6 +128,15 @@ VIRT_TYPES = {
|
|||||||
'lxc': ['nova-compute-lxc'],
|
'lxc': ['nova-compute-lxc'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Maps virt-type config to a libvirt URI.
|
||||||
|
LIBVIRT_URIS = {
|
||||||
|
'kvm': 'qemu:///system',
|
||||||
|
'qemu': 'qemu:///system',
|
||||||
|
'xen': 'xen:///',
|
||||||
|
'uml': 'uml:///system',
|
||||||
|
'lxc': 'lxc:///',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def ceph_config_file():
|
def ceph_config_file():
|
||||||
return CHARM_CEPH_CONF.format(service_name())
|
return CHARM_CEPH_CONF.format(service_name())
|
||||||
@ -422,14 +431,15 @@ def import_keystone_ca_cert():
|
|||||||
|
|
||||||
|
|
||||||
def create_libvirt_secret(secret_file, secret_uuid, key):
|
def create_libvirt_secret(secret_file, secret_uuid, key):
|
||||||
if secret_uuid in check_output(['virsh', 'secret-list']):
|
uri = LIBVIRT_URIS[config('virt-type')]
|
||||||
|
if secret_uuid in check_output(['virsh', '-c', uri, 'secret-list']):
|
||||||
log('Libvirt secret already exists for uuid %s.' % secret_uuid,
|
log('Libvirt secret already exists for uuid %s.' % secret_uuid,
|
||||||
level=DEBUG)
|
level=DEBUG)
|
||||||
return
|
return
|
||||||
log('Defining new libvirt secret for uuid %s.' % secret_uuid)
|
log('Defining new libvirt secret for uuid %s.' % secret_uuid)
|
||||||
cmd = ['virsh', 'secret-define', '--file', secret_file]
|
cmd = ['virsh', '-c', uri, 'secret-define', '--file', secret_file]
|
||||||
check_call(cmd)
|
check_call(cmd)
|
||||||
cmd = ['virsh', 'secret-set-value', '--secret', secret_uuid,
|
cmd = ['virsh', '-c', uri, 'secret-set-value', '--secret', secret_uuid,
|
||||||
'--base64', key]
|
'--base64', key]
|
||||||
check_call(cmd)
|
check_call(cmd)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user