diff -Nru ruby-fog-libvirt-0.7.0/debian/changelog ruby-fog-libvirt-0.8.0/debian/changelog --- ruby-fog-libvirt-0.7.0/debian/changelog 2020-11-22 14:53:33.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/debian/changelog 2021-01-22 12:04:08.000000000 +0000 @@ -1,3 +1,9 @@ +ruby-fog-libvirt (0.8.0-1) unstable; urgency=medium + + * New upstream version 0.8.0 + + -- Hans-Christoph Steiner Fri, 22 Jan 2021 13:04:08 +0100 + ruby-fog-libvirt (0.7.0-1) unstable; urgency=medium [ Utkarsh Gupta ] diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/compute.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/compute.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/compute.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/compute.rb 2021-01-22 11:15:33.000000000 +0000 @@ -44,6 +44,7 @@ request :list_interfaces request :destroy_interface request :get_node_info + request :update_autostart request :update_display request :libversion diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/README.md ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/README.md --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/README.md 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/README.md 2021-01-22 11:15:33.000000000 +0000 @@ -35,10 +35,13 @@ libvirt_ceph_pool=rbd_pool_name auth_username=libvirt auth_uuid=uuid_of_libvirt_secret +bus_type=virtio ``` For more recent versions of libvirt which support using the secret by name (`usage` attribute in the `secret` tag), you can also drop `auth_uuid` and specify `auth_usage` instead. If both are specified, `auth_uuid` will be preferred for maximum compatibility. +The `bus_type` can be set to `virtio` or `scsi`. If it is ommited, the default is `scsi`. + ## Configuration The URI can be configured in two ways: diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/server.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/server.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/server.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/server.rb 2021-01-22 11:15:33.000000000 +0000 @@ -30,6 +30,7 @@ attribute :cpu attribute :hugepages attribute :guest_agent + attribute :virtio_rng attribute :state @@ -77,6 +78,10 @@ action_status end + def update_autostart(value) + service.update_autostart(uuid, value) + end + def mac nics.first.mac if nics && nics.first end @@ -131,9 +136,10 @@ end #alias methods - alias_method :halt, :poweroff - alias_method :stop, :shutdown - alias_method :active?, :active + alias_method :halt, :poweroff + alias_method :stop, :shutdown + alias_method :active?, :active + alias_method :autostart?, :autostart def volumes # lazy loading of volumes @@ -473,6 +479,7 @@ :os_type => "hvm", :arch => "x86_64", :domain_type => "kvm", + :autostart => false, :iso_dir => default_iso_dir, :network_interface_type => "network", :network_nat_network => "default", @@ -482,6 +489,7 @@ :cpu => {}, :hugepages => false, :guest_agent => true, + :virtio_rng => {}, } end diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/templates/server.xml.erb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/templates/server.xml.erb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/models/compute/templates/server.xml.erb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/models/compute/templates/server.xml.erb 2021-01-22 11:15:33.000000000 +0000 @@ -52,9 +52,11 @@ + <% if args.key?("monitor") -%> <% args["monitor"].split(",").each do |mon| %> <% end %> + <% end %> <% if args.key?("auth_uuid") -%> @@ -63,7 +65,11 @@ <% end -%> - ' bus='scsi'/> + <% if args['bus_type'] == 'virtio' %> + ' bus='virtio'/> + <% else %> + ' bus='scsi'/> + <% end %> <% else %> @@ -94,6 +100,16 @@ <% end -%> + +<% + rng_backend_model = virtio_rng[:backend_model] ? virtio_rng[:backend_model] : 'random' +-%> +<% if virtio_rng[:backend_path] -%> + <%= virtio_rng[:backend_path] %> +<% else -%> + +<% end -%> + diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/list_networks.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/list_networks.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/list_networks.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/list_networks.rb 2021-01-22 11:15:33.000000000 +0000 @@ -25,12 +25,20 @@ end end + # bridge name may not be defined in some networks, we should skip that in such case def network_to_attributes(net) return if net.nil? + + begin + bridge_name = net.bridge_name + rescue Libvirt::Error + bridge_name = '' + end + { :uuid => net.uuid, :name => net.name, - :bridge_name => net.bridge_name + :bridge_name => bridge_name } end end diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/list_volumes.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/list_volumes.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/list_volumes.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/list_volumes.rb 2021-01-22 11:15:33.000000000 +0000 @@ -17,7 +17,7 @@ end end else - return [get_volume(filter)] + data << get_volume(filter) end data.compact end @@ -69,7 +69,8 @@ return raw ? vol : volume_to_attributes(vol) end end - { } + + nil end end @@ -77,15 +78,22 @@ def list_volumes(filters={ }) vol1 = mock_volume 'vol1' vol2 = mock_volume 'vol2' - [vol1, vol2] + vols = [vol1, vol2] + + if filters.keys.empty? + return vols + end + + key = filters.keys.first + vols.select { |v| v[key] == filters[key] } end def mock_volume name { :pool_name => 'vol.pool.name', - :key => 'vol.key', - :id => 'vol.key', - :path => 'vol.path', + :key => "vol.#{name}", # needs to match id + :id => "vol.#{name}", + :path => "path/to/disk", # used by in mock_files/domain.xml :name => name, :format_type => 'raw', :allocation => 123, diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/update_autostart.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/update_autostart.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/requests/compute/update_autostart.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/requests/compute/update_autostart.rb 2021-01-22 11:15:33.000000000 +0000 @@ -0,0 +1,18 @@ +module Fog + module Libvirt + class Compute + class Real + def update_autostart(uuid, value) + domain = client.lookup_domain_by_uuid(uuid) + domain.autostart = value + end + end + + class Mock + def update_autostart(uuid, value) + value + end + end + end + end +end diff -Nru ruby-fog-libvirt-0.7.0/lib/fog/libvirt/version.rb ruby-fog-libvirt-0.8.0/lib/fog/libvirt/version.rb --- ruby-fog-libvirt-0.7.0/lib/fog/libvirt/version.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/lib/fog/libvirt/version.rb 2021-01-22 11:15:33.000000000 +0000 @@ -1,5 +1,5 @@ module Fog module Libvirt - VERSION = '0.7.0' + VERSION = '0.8.0' end end diff -Nru ruby-fog-libvirt-0.7.0/tests/libvirt/compute_tests.rb ruby-fog-libvirt-0.8.0/tests/libvirt/compute_tests.rb --- ruby-fog-libvirt-0.7.0/tests/libvirt/compute_tests.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/tests/libvirt/compute_tests.rb 2021-01-22 11:15:33.000000000 +0000 @@ -9,7 +9,8 @@ end tests("Compute requests") do - %w{ create_domain create_volume define_domain define_pool destroy_interface destroy_network get_node_info list_domains + %w{ create_domain create_volume define_domain define_pool destroy_interface destroy_network get_node_info + update_autostart list_domains list_interfaces list_networks list_pools list_pool_volumes list_volumes pool_action vm_action volume_action dhcp_leases }.each do |request| test("it should respond to #{request}") { compute.respond_to? request } diff -Nru ruby-fog-libvirt-0.7.0/tests/libvirt/models/compute/server_tests.rb ruby-fog-libvirt-0.8.0/tests/libvirt/models/compute/server_tests.rb --- ruby-fog-libvirt-0.7.0/tests/libvirt/models/compute/server_tests.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/tests/libvirt/models/compute/server_tests.rb 2021-01-22 11:15:33.000000000 +0000 @@ -5,6 +5,8 @@ tests('The server model should') do tests('have the action') do + test('autostart') { server.respond_to? 'autostart' } + test('update_autostart') { server.respond_to? 'update_autostart' } test('reload') { server.respond_to? 'reload' } %w{ start stop destroy reboot suspend }.each do |action| test(action) { server.respond_to? action } diff -Nru ruby-fog-libvirt-0.7.0/tests/libvirt/models/compute/volumes_tests.rb ruby-fog-libvirt-0.8.0/tests/libvirt/models/compute/volumes_tests.rb --- ruby-fog-libvirt-0.7.0/tests/libvirt/models/compute/volumes_tests.rb 2019-11-02 21:26:13.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/tests/libvirt/models/compute/volumes_tests.rb 2021-01-22 11:15:33.000000000 +0000 @@ -9,6 +9,7 @@ tests('should be able to get a model') do tests('by instance uuid').succeeds { volumes.get volumes.first.id } end + test('filtered should be empty') { volumes.all(:name => "does-not-exist").empty? } end end diff -Nru ruby-fog-libvirt-0.7.0/tests/libvirt/requests/compute/update_autostart_tests.rb ruby-fog-libvirt-0.8.0/tests/libvirt/requests/compute/update_autostart_tests.rb --- ruby-fog-libvirt-0.7.0/tests/libvirt/requests/compute/update_autostart_tests.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-fog-libvirt-0.8.0/tests/libvirt/requests/compute/update_autostart_tests.rb 2021-01-22 11:15:33.000000000 +0000 @@ -0,0 +1,12 @@ +Shindo.tests('Fog::Compute[:libvirt] | update_autostart request', ['libvirt']) do + + servers = Fog::Compute[:libvirt].servers + + tests('The response should') do + test('should not be empty') { not servers.empty? } + server = servers.first + tests('should be false').succeeds { server.autostart == false } + server.update_autostart(true) + end + +end