mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Extract finalizing from the uri to a separate method (#1231)
Finalize settings that may be provided via the URI afterwards.
This commit is contained in:
parent
97ea81d2be
commit
39dc11d2a8
@ -764,27 +764,7 @@ module VagrantPlugins
|
||||
@uri = _generate_uri(@qemu_use_session == UNSET_VALUE ? false : @qemu_use_session)
|
||||
end
|
||||
|
||||
# Parse uri to extract individual components
|
||||
uri = _parse_uri(@uri)
|
||||
|
||||
# only set @connect_via_ssh if not explicitly to avoid overriding
|
||||
# and allow an error to occur if the @uri and @connect_via_ssh disagree
|
||||
@connect_via_ssh = uri.scheme.include? "ssh" if @connect_via_ssh == UNSET_VALUE
|
||||
|
||||
# Set qemu_use_session based on the URI if it wasn't set by the user
|
||||
if @qemu_use_session == UNSET_VALUE
|
||||
if (uri.scheme.start_with? "qemu") && (uri.path.include? "session")
|
||||
@qemu_use_session = true
|
||||
else
|
||||
@qemu_use_session = false
|
||||
end
|
||||
end
|
||||
|
||||
# Extract host and username values from uri if provided, otherwise nil
|
||||
@host = uri.host
|
||||
@username = uri.user
|
||||
|
||||
finalize_id_ssh_key_file
|
||||
finalize_from_uri
|
||||
|
||||
@storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE
|
||||
@snapshot_pool_name = @storage_pool_name if @snapshot_pool_name == UNSET_VALUE
|
||||
@ -991,6 +971,30 @@ module VagrantPlugins
|
||||
|
||||
private
|
||||
|
||||
def finalize_from_uri
|
||||
# Parse uri to extract individual components
|
||||
uri = _parse_uri(@uri)
|
||||
|
||||
# only set @connect_via_ssh if not explicitly to avoid overriding
|
||||
# and allow an error to occur if the @uri and @connect_via_ssh disagree
|
||||
@connect_via_ssh = uri.scheme.include? "ssh" if @connect_via_ssh == UNSET_VALUE
|
||||
|
||||
# Set qemu_use_session based on the URI if it wasn't set by the user
|
||||
if @qemu_use_session == UNSET_VALUE
|
||||
if (uri.scheme.start_with? "qemu") && (uri.path.include? "session")
|
||||
@qemu_use_session = true
|
||||
else
|
||||
@qemu_use_session = false
|
||||
end
|
||||
end
|
||||
|
||||
# Extract host and username values from uri if provided, otherwise nil
|
||||
@host = uri.host
|
||||
@username = uri.user
|
||||
|
||||
finalize_id_ssh_key_file
|
||||
end
|
||||
|
||||
def resolve_ssh_key_file(key_file)
|
||||
# set ssh key for access to Libvirt host
|
||||
# if no slash, prepend $HOME/.ssh/
|
||||
|
Loading…
Reference in New Issue
Block a user