-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add method for restricting to accessible storages #18391
Changes from all 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 |
---|---|---|
@@ -1,4 +1,16 @@ | ||
class HostStorage < ApplicationRecord | ||
belongs_to :host | ||
belongs_to :storage | ||
|
||
scope :writable, -> { where(:read_only => [nil, false]) } | ||
scope :read_only, -> { where(:read_only => true) } | ||
|
||
scope :accessible, -> { where(:accessible => [true, nil]) } | ||
scope :inaccessible, -> { where(:accessible => false) } | ||
|
||
class << self | ||
def writable_accessible | ||
writable.accessible | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1069,7 +1069,7 @@ def allowed_storages(_options = {}) | |
MiqPreloader.preload(hosts, :storages => {}, :host_storages => :storage) | ||
|
||
storages = hosts.each_with_object({}) do |host, hash| | ||
host.writable_storages.each { |s| hash[s.id] = s } | ||
host.writable_accessible_storages.each { |s| hash[s.id] = s } | ||
end.values | ||
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. This change will help with the Provisioning UI and Automate callers to Unfortunately the @tinaafitz As part of fixing this BZ we should look into changing these calls to use |
||
selected_storage_profile_id = get_value(@values[:placement_storage_profile]) | ||
if selected_storage_profile_id | ||
|
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.
I think it would be good to replace the
writable_storages
andread_only_storages
with associations using these scopes, not sure if in this PR or a followup since it isn't really relatedThere 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.
/cc @NickLaMuro since you modified the
writable_storages
method for performance, wdyt?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.
For reference (since I had to go find it), that performance change was done here:
#17354
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.
Okay, so I think my to cents with this is that you probably want to leave those methods (
writable_storages
andread_only_storages
), and just change them to use the scopes:Or, if we did create a
writable_storages
scope, I would suggest possibly doing the following to maintain the performance benefits of #17354 :Let me know if any of this needs a further explanation... trying to avoid a 📖
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.
Alright I'll leave it as is 😄