Skip to content
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

Merged

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Feb 2, 2017

Shared definitions of cloud manager targets

@Ladas
Copy link
Contributor Author

Ladas commented Feb 2, 2017

@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

@durandom
Copy link
Member

durandom commented Feb 4, 2017

I think the base class should be at app/models/manageiq/providers/inventory/targets/cloud_manager

Then there should something like a class_method that sets the module, because in most cases this is the only thing that changes.

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

@Ladas
Copy link
Contributor Author

Ladas commented Feb 6, 2017

@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

@Ladas Ladas force-pushed the shared_definitions_of_manager_refresh_targets branch from d361e66 to f79eb1f Compare February 8, 2017 13:05
@Ladas Ladas changed the title [WIP] Shared definitions of cloud manager targets Shared definitions of cloud manager targets Feb 8, 2017
@Ladas Ladas changed the title Shared definitions of cloud manager targets [WIP] (Depends on #13739) Shared definitions of cloud manager targets Feb 8, 2017
@miq-bot
Copy link
Member

miq-bot commented Feb 8, 2017

This pull request is not mergeable. Please rebase and repush.

Ladas added 4 commits February 8, 2017 14:39
InventoryCollectionDefault base class
Shared configurations of InventoryCollections for CloudManager
Shared configurations of InventoryCollections for NetworkManager
Shared configurations of InventoryCollections for StorageManager
@Ladas Ladas force-pushed the shared_definitions_of_manager_refresh_targets branch from f79eb1f to dd66d23 Compare February 8, 2017 13:40
@Ladas Ladas changed the title [WIP] (Depends on #13739) Shared definitions of cloud manager targets Shared definitions of cloud manager targets Feb 8, 2017
Fix rubocop issues
@Ladas
Copy link
Contributor Author

Ladas commented Feb 8, 2017

@miq-bot remove_label wip

@Ladas
Copy link
Contributor Author

Ladas commented Feb 8, 2017

@miq-bot assign @agrare

@Ladas
Copy link
Contributor Author

Ladas commented Feb 8, 2017

@agrare you could extract Infra for Vmware here. might be, we could move some definitions to a shared superclass

@miq-bot miq-bot removed the wip label Feb 8, 2017
@miq-bot miq-bot assigned agrare and unassigned blomquisg Feb 8, 2017
@miq-bot
Copy link
Member

miq-bot commented Feb 8, 2017

Checked commits Ladas/manageiq@41060e1~...9bcc88d with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 2 offenses detected

app/models/manager_refresh/inventory_collection_default/cloud_manager.rb

@Ladas
Copy link
Contributor Author

Ladas commented Feb 9, 2017

@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

Copy link
Member

@durandom durandom left a 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
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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 = {})
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@durandom durandom left a 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.

@Ladas
Copy link
Contributor Author

Ladas commented Feb 10, 2017

@durandom those are kwargs not hashes :-D a biiig difference :-D

@agrare agrare merged commit a07b131 into ManageIQ:master Feb 10, 2017
@agrare agrare added this to the Sprint 54 Ending Feb 13, 2017 milestone Feb 10, 2017
@agrare agrare added the euwe/no label Feb 10, 2017
@durandom
Copy link
Member

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants