-
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
Enhanced inventory collector target and parser classes #13907
Merged
agrare
merged 13 commits into
ManageIQ:master
from
Ladas:enhanced_inventory_collector_target_and_parser_classes
Feb 16, 2017
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
28a74aa
Remove old base classes for new refresh
Ladas e2d8125
Modify Base target class to align with Amazon usecase
Ladas 0f57da2
Modify Collector base class to align with Amazon usecase
Ladas 9435aca
Modify Inventory base class to align with Amazon usecase
Ladas 4fc9ecf
Target initialize is taking a collector object as a parameter
Ladas 6ec3730
Modify Ansible Target to use the new target and manager methods
Ladas 42ab658
Ansible tower enhance target IC definitions
Ladas bcf3d5d
Unify Target and Collector interface
Ladas b58126d
Allow to overwrite aninsible IC defaults
Ladas 8981373
Rename Target to Persister under Inventory
Ladas c333f2d
Dynamic access of collections with Rails like method cache
Ladas 4214aa2
Renames in Persister according to review
Ladas 85ad5bf
Explicitly define a delete method instead of auto-magic
Ladas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/models/manageiq/providers/ansible_tower/inventory/persister/automation_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class ManageIQ::Providers::AnsibleTower::Inventory::Persister::AutomationManager < ManagerRefresh::Inventory::Persister | ||
def automation | ||
ManageIQ::Providers::AnsibleTower::InventoryCollectionDefault::AutomationManager | ||
end | ||
|
||
def initialize_inventory_collections | ||
add_inventory_collections( | ||
automation, | ||
%i(inventory_root_groups configured_systems configuration_scripts configuration_script_sources configuration_script_payloads), | ||
:builder_params => {:manager => manager} | ||
) | ||
|
||
add_inventory_collections( | ||
automation, | ||
%i(credentials), | ||
:builder_params => {:resource => manager} | ||
) | ||
end | ||
end |
60 changes: 0 additions & 60 deletions
60
app/models/manageiq/providers/ansible_tower/inventory/target/automation_manager.rb
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...odels/manageiq/providers/ansible_tower/inventory_collection_default/automation_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class ManageIQ::Providers::AnsibleTower::InventoryCollectionDefault::AutomationManager < ManagerRefresh::InventoryCollectionDefault | ||
class << self | ||
def inventory_root_groups(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ManageIQ::Providers::AutomationManager::InventoryRootGroup, | ||
:association => :inventory_root_groups, | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
|
||
def configured_systems(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem, | ||
:association => :configured_systems, | ||
:manager_ref => [:manager_ref], | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
|
||
def configuration_scripts(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript, | ||
:association => :configuration_scripts, | ||
:manager_ref => [:manager_ref], | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
|
||
def configuration_script_sources(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ConfigurationScriptSource, | ||
:association => :configuration_script_sources, | ||
:manager_ref => [:manager_ref], | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
|
||
def configuration_script_payloads(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook, | ||
:association => :configuration_script_payloads, | ||
:manager_ref => [:manager_ref], | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
|
||
def credentials(extra_attributes = {}) | ||
attributes = { | ||
:model_class => ManageIQ::Providers::AutomationManager::Authentication, | ||
:association => :credentials, | ||
:manager_ref => [:manager_ref], | ||
} | ||
attributes.merge!(extra_attributes) | ||
end | ||
end | ||
end |
55 changes: 0 additions & 55 deletions
55
app/models/manageiq/providers/cloud_manager/refresh_parser_inventory_object.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
class ManagerRefresh::Inventory::Collector | ||
attr_accessor :manager | ||
attr_accessor :target | ||
attr_reader :manager, :target | ||
|
||
def initialize(manager, target) | ||
# @param manager [ManageIQ::Providers::BaseManager] A manager object | ||
# @param target [Object] A refresh Target object | ||
def initialize(manager, refresh_target) | ||
@manager = manager | ||
@target = target | ||
@target = refresh_target | ||
end | ||
|
||
def options | ||
@options ||= Settings.ems_refresh[manager.class.ems_type] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are you using strings/
safe_constantize
to avoid class not found?(basically asking will this work if you don't
.name
, but just reference the class)?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.
Good point, and I'm chiming in, because the original code was mine, so I'm to blame 😉
So, if the class is not found, it would return
nil
andnil.new
will blow up.So we should assume the class is there, check if its not and raise an exception like
you should really implement this
- so the dev knows what he's missing