-
Notifications
You must be signed in to change notification settings - Fork 900
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
Shared definitions of cloud manager targets #13743
Shared definitions of cloud manager targets #13743
Conversation
@durandom so this is how it looks like for me I think then aws would have class ManageIQ::Providers::Amazon::Inventory::Target::CloudManager < ManageIQ::Providers::Amazon::Inventory::Target
def cloud
ManageIQ::Providers::Amazon::InventoryCollectionDefault::CloudManager
end
def initialize_inventory_collections
add_inventory_collections(
cloud,
%i(vms miq_templates hardwares networks disks availability_zones
flavors key_pairs orchestration_stacks orchestration_stacks_resources
orchestration_stacks_outputs orchestration_stacks_parameters orchestration_templates)
)
end
end |
I think the base class should be at Then there should something like a Like class Target::CloudManager
def vms
ManagerRefresh::InventoryCollection.new(model_class: provider_module::CloudManager::Vm)
end
end
class Amazon::Inventory::Target::CloudManager
def provider_module
ManageIQ::Providers::Amazon
end
end and even that could be somehow automagically inferred, that you eventually, maybe just have to inherit from the base target and it works |
@durandom inheritance will not work here, since e.g in NetworkManager, we need ICs of CloudManager (same for StorageManager) So we either need them as class methods or modules I think |
d361e66
to
f79eb1f
Compare
This pull request is not mergeable. Please rebase and repush. |
InventoryCollectionDefault base class
Shared configurations of InventoryCollections for CloudManager
Shared configurations of InventoryCollections for NetworkManager
Shared configurations of InventoryCollections for StorageManager
f79eb1f
to
dd66d23
Compare
Fix rubocop issues
@miq-bot remove_label wip |
@agrare you could extract Infra for Vmware here. might be, we could move some definitions to a shared superclass |
Checked commits Ladas/manageiq@41060e1~...9bcc88d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/manager_refresh/inventory_collection_default/cloud_manager.rb
|
@durandom @agrare then this is how AWS uses these ManageIQ/manageiq-providers-amazon#134 I do like the 'add_inventory_collection' helper to fill up what can be inferred automatically and 'add_inventory_collections' helper for adding many ICs with the same config The 'add_remaining_inventory_collections' is also cool, but probably only to easily say 'rest is coming from the DB' for the targetted refresh. Otherwise I like that Inventory::Target has to name every IC that will be saved |
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.
Can you show me where those Defaults
are used? To me this looks like another layer of abstraction
@@ -0,0 +1,226 @@ | |||
class ManagerRefresh::InventoryCollectionDefault::CloudManager < ManagerRefresh::InventoryCollectionDefault |
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 this should be at app/models/manageiq/providers/inventory/targets/cloud_manager
- then it's closer to the actual models
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.
oh, if its a target only
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.
yeah, this is default for InventoryCollection, under any target
@@ -0,0 +1,226 @@ | |||
class ManagerRefresh::InventoryCollectionDefault::CloudManager < ManagerRefresh::InventoryCollectionDefault | |||
class << self | |||
def vms(extra_attributes = {}) |
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.
attributes reminds me of the model attributes
but this is rather params for creating the InventoryCollections
right?
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.
yeah, possibly :extra_params might be more descriptive
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 appreciate the effort put into simplifying this and I'm ok with merging this as is so we can further improve on it.
All in all I dont like hashes being passed around here. I would rather see the InventoryCollections created directly. But not sure.
@durandom those are kwargs not hashes :-D a biiig difference :-D |
I only see hashes in this PR 😛 Maybe you use them later as kwargs, but still it starts with a hash |
Shared definitions of cloud manager targets