mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Output XML elements to debug logs (#1345)
Because libvirt may handle updating the XML of components differently across different versions and user environments, add the generated contents to the debug log to assist in understanding what is happening for different users.
This commit is contained in:
parent
90e89de969
commit
0756362b84
@ -400,9 +400,14 @@ module VagrantPlugins
|
|||||||
# Create Libvirt domain.
|
# Create Libvirt domain.
|
||||||
# Is there a way to tell fog to create new domain with already
|
# Is there a way to tell fog to create new domain with already
|
||||||
# existing volume? Use domain creation from template..
|
# existing volume? Use domain creation from template..
|
||||||
|
xml = to_xml('domain')
|
||||||
|
@logger.debug {
|
||||||
|
"Creating Domain with XML:\n#{xml}"
|
||||||
|
}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
server = env[:machine].provider.driver.connection.servers.create(
|
server = env[:machine].provider.driver.connection.servers.create(
|
||||||
xml: to_xml('domain')
|
xml: xml
|
||||||
)
|
)
|
||||||
rescue Fog::Errors::Error => e
|
rescue Fog::Errors::Error => e
|
||||||
raise Errors::FogCreateServerError, error_message: e.message
|
raise Errors::FogCreateServerError, error_message: e.message
|
||||||
|
@ -78,6 +78,9 @@ module VagrantPlugins
|
|||||||
else
|
else
|
||||||
pool_name = config.storage_pool_name
|
pool_name = config.storage_pool_name
|
||||||
end
|
end
|
||||||
|
@logger.debug {
|
||||||
|
"Creating Volume with XML:\n#{xml}"
|
||||||
|
}
|
||||||
@logger.debug "Using pool #{pool_name} for base box snapshot"
|
@logger.debug "Using pool #{pool_name} for base box snapshot"
|
||||||
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
||||||
xml: xml,
|
xml: xml,
|
||||||
|
@ -159,6 +159,9 @@ module VagrantPlugins
|
|||||||
else
|
else
|
||||||
to_xml(template_name)
|
to_xml(template_name)
|
||||||
end
|
end
|
||||||
|
@logger.debug {
|
||||||
|
"Attaching Network Device with XML:\n#{xml}"
|
||||||
|
}
|
||||||
domain.attach_device(xml)
|
domain.attach_device(xml)
|
||||||
rescue => e
|
rescue => e
|
||||||
raise Errors::AttachDeviceError,
|
raise Errors::AttachDeviceError,
|
||||||
|
@ -337,8 +337,12 @@ module VagrantPlugins
|
|||||||
@network_domain_name = @options[:domain_name]
|
@network_domain_name = @options[:domain_name]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
xml = to_xml('private_network')
|
||||||
|
@logger.debug {
|
||||||
|
"Creating private network with XML:\n#{xml}"
|
||||||
|
}
|
||||||
@interface_network[:libvirt_network] = \
|
@interface_network[:libvirt_network] = \
|
||||||
@libvirt_client.define_network_xml(to_xml('private_network'))
|
@libvirt_client.define_network_xml(xml)
|
||||||
@logger.debug 'created network'
|
@logger.debug 'created network'
|
||||||
rescue => e
|
rescue => e
|
||||||
raise Errors::CreateNetworkError, error_message: e.message
|
raise Errors::CreateNetworkError, error_message: e.message
|
||||||
|
@ -44,8 +44,12 @@ module VagrantPlugins
|
|||||||
@storage_pool_path = storage_pool_path(env)
|
@storage_pool_path = storage_pool_path(env)
|
||||||
@storage_pool_uid = storage_uid(env)
|
@storage_pool_uid = storage_uid(env)
|
||||||
@storage_pool_gid = storage_gid(env)
|
@storage_pool_gid = storage_gid(env)
|
||||||
|
xml = to_xml('default_storage_pool')
|
||||||
|
@logger.debug {
|
||||||
|
"Creating Storage Pool with XML:\n#{xml}"
|
||||||
|
}
|
||||||
libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
|
libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
|
||||||
to_xml('default_storage_pool')
|
xml
|
||||||
)
|
)
|
||||||
libvirt_pool.build
|
libvirt_pool.build
|
||||||
libvirt_pool.create
|
libvirt_pool.create
|
||||||
|
@ -352,6 +352,9 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
# Autostart with host if enabled in Vagrantfile
|
# Autostart with host if enabled in Vagrantfile
|
||||||
libvirt_domain.autostart = config.autostart
|
libvirt_domain.autostart = config.autostart
|
||||||
|
@logger.debug {
|
||||||
|
"Starting Domain with XML:\n#{libvirt_domain.xml_desc}"
|
||||||
|
}
|
||||||
# Actually start the domain
|
# Actually start the domain
|
||||||
domain.start
|
domain.start
|
||||||
rescue Fog::Errors::Error, Errors::VagrantLibvirtError => e
|
rescue Fog::Errors::Error, Errors::VagrantLibvirtError => e
|
||||||
|
@ -47,7 +47,6 @@ module VagrantPlugins
|
|||||||
|
|
||||||
machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"
|
machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"
|
||||||
|
|
||||||
#xml = to_xml('filesystem', folder_opts)
|
|
||||||
xml = Nokogiri::XML::Builder.new do |xml|
|
xml = Nokogiri::XML::Builder.new do |xml|
|
||||||
xml.filesystem(type: 'mount', accessmode: folder_opts[:accessmode]) do
|
xml.filesystem(type: 'mount', accessmode: folder_opts[:accessmode]) do
|
||||||
xml.driver(type: 'path', wrpolicy: 'immediate')
|
xml.driver(type: 'path', wrpolicy: 'immediate')
|
||||||
@ -60,7 +59,9 @@ module VagrantPlugins
|
|||||||
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
||||||
Nokogiri::XML::Node::SaveOptions::FORMAT
|
Nokogiri::XML::Node::SaveOptions::FORMAT
|
||||||
)
|
)
|
||||||
# puts "<<<<< XML:\n #{xml}\n >>>>>"
|
@logger.debug {
|
||||||
|
"Attaching Synced Folder device with XML:\n#{xml}"
|
||||||
|
}
|
||||||
@conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
|
@conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -46,7 +46,6 @@ module VagrantPlugins
|
|||||||
|
|
||||||
machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"
|
machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"
|
||||||
|
|
||||||
#xml = to_xml('filesystem', folder_opts)
|
|
||||||
xml = Nokogiri::XML::Builder.new do |xml|
|
xml = Nokogiri::XML::Builder.new do |xml|
|
||||||
xml.filesystem(type: 'mount', accessmode: 'passthrough') do
|
xml.filesystem(type: 'mount', accessmode: 'passthrough') do
|
||||||
xml.driver(type: 'virtiofs')
|
xml.driver(type: 'virtiofs')
|
||||||
@ -59,7 +58,9 @@ module VagrantPlugins
|
|||||||
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
||||||
Nokogiri::XML::Node::SaveOptions::FORMAT
|
Nokogiri::XML::Node::SaveOptions::FORMAT
|
||||||
)
|
)
|
||||||
# puts "<<<<< XML:\n #{xml}\n >>>>>"
|
@logger.debug {
|
||||||
|
"Attaching Synced Folder device with XML:\n#{xml}"
|
||||||
|
}
|
||||||
@conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
|
@conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -31,6 +31,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
|||||||
allow(connection).to receive(:volumes).and_return(volumes)
|
allow(connection).to receive(:volumes).and_return(volumes)
|
||||||
|
|
||||||
allow(logger).to receive(:info)
|
allow(logger).to receive(:info)
|
||||||
|
allow(logger).to receive(:debug)
|
||||||
|
|
||||||
env[:domain_name] = "vagrant-test_default"
|
env[:domain_name] = "vagrant-test_default"
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomainVolume do
|
|||||||
allow(all).to receive(:first).and_return(box_volume)
|
allow(all).to receive(:first).and_return(box_volume)
|
||||||
allow(box_volume).to receive(:id).and_return(nil)
|
allow(box_volume).to receive(:id).and_return(nil)
|
||||||
env[:domain_name] = 'test'
|
env[:domain_name] = 'test'
|
||||||
|
|
||||||
|
allow(logger).to receive(:debug)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when one disk' do
|
context 'when one disk' do
|
||||||
|
@ -30,6 +30,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
|||||||
allow(connection).to receive(:servers).and_return(servers)
|
allow(connection).to receive(:servers).and_return(servers)
|
||||||
allow(servers).to receive(:get).and_return(domain)
|
allow(servers).to receive(:get).and_return(domain)
|
||||||
|
|
||||||
|
allow(logger).to receive(:debug)
|
||||||
expect(logger).to receive(:info)
|
expect(logger).to receive(:info)
|
||||||
expect(ui).to_not receive(:error)
|
expect(ui).to_not receive(:error)
|
||||||
end
|
end
|
||||||
@ -46,7 +47,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
|||||||
|
|
||||||
it 'should execute without changing' do
|
it 'should execute without changing' do
|
||||||
allow(libvirt_domain).to receive(:undefine)
|
allow(libvirt_domain).to receive(:undefine)
|
||||||
expect(logger).to_not receive(:debug)
|
|
||||||
expect(libvirt_domain).to receive(:autostart=)
|
expect(libvirt_domain).to receive(:autostart=)
|
||||||
expect(domain).to receive(:start)
|
expect(domain).to receive(:start)
|
||||||
|
|
||||||
@ -118,7 +118,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should execute without changing' do
|
it 'should execute without changing' do
|
||||||
expect(logger).to_not receive(:debug)
|
|
||||||
expect(libvirt_domain).to receive(:autostart=)
|
expect(libvirt_domain).to receive(:autostart=)
|
||||||
expect(domain).to receive(:start)
|
expect(domain).to receive(:start)
|
||||||
|
|
||||||
@ -138,7 +137,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should execute without changing' do
|
it 'should execute without changing' do
|
||||||
expect(logger).to_not receive(:debug)
|
|
||||||
expect(libvirt_domain).to receive(:autostart=)
|
expect(libvirt_domain).to receive(:autostart=)
|
||||||
expect(domain).to receive(:start)
|
expect(domain).to receive(:start)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user