From 41d153b91fd4096c3c806df61cdc3c8312fe9ec8 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Tue, 12 Jul 2022 18:28:51 +0100 Subject: [PATCH] Tidy up virtiofs and 9p synced_folder messages (#1527) Remove the excessive output generated for the synced_folder messages emitted when using 9p and virtiofs synced_folders. Fixes: #1525 --- lib/vagrant-libvirt/cap/synced_folder_9p.rb | 6 +++--- lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb | 8 ++++---- locales/en.yml | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/vagrant-libvirt/cap/synced_folder_9p.rb b/lib/vagrant-libvirt/cap/synced_folder_9p.rb index 250d237..2e54408 100644 --- a/lib/vagrant-libvirt/cap/synced_folder_9p.rb +++ b/lib/vagrant-libvirt/cap/synced_folder_9p.rb @@ -45,7 +45,7 @@ module VagrantPlugins mount_tag = Digest::MD5.new.update(folder_opts[:hostpath]).to_s[0, 31] folder_opts[:mount_tag] = mount_tag - machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}" + machine.ui.info I18n.t("vagrant_libvirt.cap.9p.preparing") xml = Nokogiri::XML::Builder.new do |xml| xml.filesystem(type: 'mount', accessmode: folder_opts[:accessmode]) do @@ -74,7 +74,7 @@ module VagrantPlugins # once up, mount folders def enable(machine, folders, _opts) # Go through each folder and mount - machine.ui.info('mounting 9p share in guest') + machine.ui.info I18n.t("vagrant_libvirt.cap.9p.mounting") # Only mount folders that have a guest path specified. mount_folders = {} folders.each do |id, opts| @@ -94,6 +94,7 @@ module VagrantPlugins raise Vagrant::Errors::Error('No Libvirt connection') end @conn = machine.provider.driver.connection.client + machine.ui.info I18n.t("vagrant_libvirt.cap.9p.cleanup") begin if machine.id && machine.id != '' dom = @conn.lookup_domain_by_uuid(machine.id) @@ -101,7 +102,6 @@ module VagrantPlugins '/domain/devices/filesystem' ).each do |xml| dom.detach_device(xml.to_s) - machine.ui.info 'Cleaned up shared folders' end end rescue => e diff --git a/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb b/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb index 3691590..2c739b4 100644 --- a/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +++ b/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb @@ -34,6 +34,8 @@ module VagrantPlugins raise Vagrant::Errors::Error('No Libvirt connection') if machine.provider.driver.connection.nil? @conn = machine.provider.driver.connection.client + machine.ui.info I18n.t("vagrant_libvirt.cap.virtiofs.preparing") + begin # loop through folders folders.each do |id, folder_opts| @@ -44,8 +46,6 @@ module VagrantPlugins mount_tag = Digest::MD5.new.update(folder_opts[:hostpath]).to_s[0, 31] folder_opts[:mount_tag] = mount_tag - machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}" - xml = Nokogiri::XML::Builder.new do |xml| xml.filesystem(type: 'mount', accessmode: 'passthrough') do xml.driver(type: 'virtiofs') @@ -73,7 +73,7 @@ module VagrantPlugins # once up, mount folders def enable(machine, folders, _opts) # Go through each folder and mount - machine.ui.info('mounting virtiofs share in guest') + machine.ui.info I18n.t("vagrant_libvirt.cap.virtiofs.mounting") # Only mount folders that have a guest path specified. mount_folders = {} folders.each do |id, opts| @@ -91,6 +91,7 @@ module VagrantPlugins raise Vagrant::Errors::Error('No Libvirt connection') end @conn = machine.provider.driver.connection.client + machine.ui.info I18n.t("vagrant_libvirt.cap.virtiofs.cleanup") begin if machine.id && machine.id != '' dom = @conn.lookup_domain_by_uuid(machine.id) @@ -98,7 +99,6 @@ module VagrantPlugins '/domain/devices/filesystem' ).each do |xml| dom.detach_device(xml.to_s) - machine.ui.info 'Cleaned up shared folders' end end rescue => e diff --git a/locales/en.yml b/locales/en.yml index 75346d5..d8f5a5f 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -214,3 +214,13 @@ en: preparing: |- The vagrant machine is being prepared for creation, please wait for it to reach a steady state before issuing commands on it. + + cap: + virtiofs: + preparing: Configuring virtiofs device for shared folders... + mounting: Mounting virtiofs shared folders... + cleanup: Removing virtiofs device for shared folders... + 9p: + preparing: Configuring 9p device for shared folders... + mounting: Mounting 9p shared folders... + cleanup: Removing 9p device for shared folders...