From a2a8799514657b593bbf7a15950fb33e1e27de9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?FEREZ=20Ga=C3=ABtan?= Date: Fri, 10 Jan 2025 10:38:15 +0100 Subject: [PATCH] Handle libvirt_ceph_pool as a complement of libvirt_ceph_pools --- lib/fog/libvirt/models/compute/server.rb | 7 +++++-- tests/libvirt/models/compute/server_tests.rb | 15 +++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/fog/libvirt/models/compute/server.rb b/lib/fog/libvirt/models/compute/server.rb index a94dc72..f35cf11 100644 --- a/lib/fog/libvirt/models/compute/server.rb +++ b/lib/fog/libvirt/models/compute/server.rb @@ -458,7 +458,7 @@ def read_ceph_args(path = "/etc/foreman/ceph.conf") args = {} - valid_keys = ["monitor", "port", "libvirt_ceph_pools", "auth_username", "auth_uuid", "bus_type"] + valid_keys = ["monitor", "port", "libvirt_ceph_pools", "libvirt_ceph_pool", "auth_username", "auth_uuid", "bus_type"] array_values = ["monitor", "libvirt_ceph_pools"] File.readlines(path).each do |line| @@ -470,7 +470,10 @@ def read_ceph_args(path = "/etc/foreman/ceph.conf") end end - puts args + if args.has_key?("libvirt_ceph_pool") + args.has_key?("libvirt_ceph_pools") ? args["libvirt_ceph_pools"] << args["libvirt_ceph_pool"] : args["libvirt_ceph_pools"] = [args["libvirt_ceph_pool"]] + args.delete("libvirt_ceph_pool") + end args end diff --git a/tests/libvirt/models/compute/server_tests.rb b/tests/libvirt/models/compute/server_tests.rb index 1bb2d04..526932c 100644 --- a/tests/libvirt/models/compute/server_tests.rb +++ b/tests/libvirt/models/compute/server_tests.rb @@ -1,11 +1,7 @@ RealFile = File class FakeFile < RealFile def self.file?(path) - if path == '/etc/foreman/ceph.conf' - return true - else - return RealFile.file(path) - end + path == '/etc/foreman/ceph.conf' || RealFile.file(path) end def self.readlines(path) @@ -14,6 +10,7 @@ def self.readlines(path) "monitor=mon001.example.com,mon002.example.com,mon003.example.com", "port=6789", "libvirt_ceph_pools=rbd_pool_name,second_rbd_pool_name", + "libvirt_ceph_pool=third_rbd_pool_name", "auth_username=libvirt", "auth_uuid=uuid_of_libvirt_secret", "bus_type=virtio" @@ -134,7 +131,8 @@ def self.readlines(path) { :nics => [], :volumes => [ - Fog::Libvirt::Compute::Volume.new({ :path => "rbd_pool_name/block-1", :pool_name => "rbd_pool_name" }) + Fog::Libvirt::Compute::Volume.new({ :path => "rbd_pool_name/block-1", :pool_name => "rbd_pool_name" }), + Fog::Libvirt::Compute::Volume.new({ :path => "third_rbd_pool_name/block-2", :pool_name => "third_rbd_pool_name" }) ] } ) @@ -143,11 +141,12 @@ def self.readlines(path) network_disk = xml.match?(//) mon_host = xml.match?(%r{}) - source_rbd = xml.match?(%r{}) + source_block1_rbd = xml.match?(%r{}) + source_block2_rbd = xml.match?(%r{}) auth_username = xml.match?(//) auth_secret = xml.match?(%r{}) - network_disk && mon_host && source_rbd && auth_username && auth_secret + network_disk && mon_host && source_block1_rbd && source_block2_rbd && auth_username && auth_secret end test("with q35 machine type on x86_64") { server.to_xml.match?(%r{hvm}) } end