-
Notifications
You must be signed in to change notification settings - Fork 46
Implement Ceph multiple pools and tests #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -346,13 +346,13 @@ def to_xml | |
|
|
||
| volumes.each_with_index do |volume, index| | ||
| target_device = "vd#{('a'..'z').to_a[index]}" | ||
| if ceph_args && volume.pool_name.include?(ceph_args["libvirt_ceph_pool"]) | ||
| if ceph_args && ceph_args["libvirt_ceph_pools"]&.include?(volume.pool_name) | ||
| xml.disk(:type => "network", :device => "disk") do | ||
| xml.driver(:name => "qemu", :type => volume.format_type, :cache => "writeback", :discard => "unmap") | ||
| xml.source(:protocol => "rbd", :name => volume.path) | ||
|
|
||
| ceph_args["monitor"]&.split(",")&.each do |monitor| | ||
| xml.host(:name => monitor, :port => ceph_args["port"]) | ||
| xml.source(:protocol => "rbd", :name => volume.path) do | ||
| ceph_args["monitor"]&.each do |monitor| | ||
| xml.host(:name => monitor, :port => ceph_args["port"]) | ||
| end | ||
| end | ||
|
|
||
| xml.auth(:username => ceph_args["auth_username"]) do | ||
|
|
@@ -458,11 +458,21 @@ def read_ceph_args(path = "/etc/foreman/ceph.conf") | |
|
|
||
| args = {} | ||
|
|
||
| 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| | ||
| pair = line.strip.split("=") | ||
| key = pair[0] | ||
| value = pair[1] | ||
| args[key] = value | ||
| key = pair[0].strip | ||
| if valid_keys.include?(key) | ||
| value = array_values.include?(key) ? pair[1].split(',').map(&:strip) : pair[1].strip | ||
| args[key] = value | ||
| end | ||
| end | ||
|
|
||
| if args.has_key?("libvirt_ceph_pool") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be tempted to only read
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. I think it's more of a transitive way of managing both at the same time. But in the end, you're right. |
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to limit this? Wouldn't it be safe to just parse everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration file can contains some comments or extra lines. So I think it's better to only import configuration line respecting a minimal schema.