-
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
Migrate AnsibleTower ConfigurationManager to AutomationManager #13630
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,51 @@ | ||
# Calling order | ||
# | ||
# - ems | ||
# - configuration_profiles | ||
# - operating_system_flavor (links) | ||
# - customization_script_ptable (link) | ||
# - customization_script_medium (link) | ||
# - configured_systems | ||
# - operating_system_flavor (links) | ||
# - customization_scripts (links) | ||
## ? use guid? | ||
module EmsRefresh | ||
module SaveInventoryAutomation | ||
def save_automation_manager_inventory(manager, hashes, target = nil) | ||
return if hashes.nil? | ||
save_child_inventory(manager, hashes, [:ems_folders, :configuration_profiles, :configured_systems, :configuration_scripts], target) | ||
manager.save | ||
end | ||
|
||
def save_configuration_profiles_inventory(manager, hashes, target) | ||
delete_missing_records = target.nil? || manager == target | ||
save_inventory_assoc(manager.configuration_profiles, hashes, delete_missing_records, [:manager_ref]) | ||
|
||
link_children_references(manager.configuration_profiles) | ||
end | ||
|
||
def save_configured_systems_inventory(manager, hashes, target) | ||
delete_missing_records = target.nil? || manager == target | ||
# these records are cross referenced to the hashes | ||
# get the id out and store in this record | ||
hashes.each do |hash| | ||
hash[:configuration_profile_id] = hash.fetch_path(:configuration_profile, :id) | ||
hash[:inventory_root_group_id] = hash.fetch_path(:inventory_root_group, :id) | ||
end | ||
save_inventory_assoc(manager.configured_systems, hashes, delete_missing_records, [:manager_ref], nil, [:configuration_profile, :inventory_root_group]) | ||
end | ||
|
||
def save_configuration_scripts_inventory(manager, hashes, target) | ||
delete_missing_records = target.nil? || manager == target | ||
# these records are cross referenced to the hashes | ||
# get the id out and store in this record | ||
hashes.each { |hash| hash[:inventory_root_group_id] = hash.fetch_path(:inventory_root_group, :id) } | ||
save_inventory_assoc(manager.configuration_scripts, hashes, delete_missing_records, [:manager_ref], nil, [:configuration_script, :inventory_root_group]) | ||
end | ||
|
||
def save_ems_folders_inventory(manager, hashes, target) | ||
delete_missing_records = target.nil? || manager == target | ||
save_inventory_assoc(manager.inventory_groups, hashes, delete_missing_records, [:ems_ref], nil, [:ems_folder]) | ||
end | ||
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
2 changes: 1 addition & 1 deletion
2
...iguration_manager/configuration_script.rb → ...utomation_manager/configuration_script.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
2 changes: 1 addition & 1 deletion
2
...onfiguration_manager/configured_system.rb → ...r/automation_manager/configured_system.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
3 changes: 3 additions & 0 deletions
3
app/models/manageiq/providers/ansible_tower/automation_manager/event_catcher.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,3 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::EventCatcher < ManageIQ::Providers::BaseManager::EventCatcher | ||
require_nested :Runner | ||
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
2 changes: 1 addition & 1 deletion
2
...iguration_manager/event_catcher/stream.rb → ...utomation_manager/event_catcher/stream.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
2 changes: 1 addition & 1 deletion
2
...wer/configuration_manager/event_parser.rb → ..._tower/automation_manager/event_parser.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
4 changes: 2 additions & 2 deletions
4
...nsible_tower/configuration_manager/job.rb → ...s/ansible_tower/automation_manager/job.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
2 changes: 1 addition & 1 deletion
2
...tower/configuration_manager/job/status.rb → ...le_tower/automation_manager/job/status.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
2 changes: 2 additions & 0 deletions
2
app/models/manageiq/providers/ansible_tower/automation_manager/playbook.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,2 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook < ConfigurationScriptPayload | ||
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
11 changes: 11 additions & 0 deletions
11
app/models/manageiq/providers/ansible_tower/automation_manager/refresh_worker.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,11 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker < MiqEmsRefreshWorker | ||
require_nested :Runner | ||
|
||
def self.ems_class | ||
parent | ||
end | ||
|
||
def self.settings_name | ||
:ems_refresh_worker_ansible_tower_automation | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
app/models/manageiq/providers/ansible_tower/automation_manager/refresh_worker/runner.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,2 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker::Runner < ManageIQ::Providers::BaseManager::RefreshWorker::Runner | ||
end |
17 changes: 17 additions & 0 deletions
17
app/models/manageiq/providers/ansible_tower/automation_manager/refresher.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,17 @@ | ||
module ManageIQ::Providers | ||
module AnsibleTower | ||
class AutomationManager::Refresher < ManageIQ::Providers::BaseManager::Refresher | ||
include ::EmsRefresh::Refreshers::EmsRefresherMixin | ||
|
||
def parse_legacy_inventory(automation_manager) | ||
automation_manager.with_provider_connection do |connection| | ||
# TODO clean up with @ems_data | ||
automation_manager.api_version = connection.api.version | ||
automation_manager.save | ||
end | ||
|
||
ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshParser.automation_manager_inv_to_hashes(automation_manager, refresher_options) | ||
end | ||
end | ||
end | ||
end |
3 changes: 0 additions & 3 deletions
3
app/models/manageiq/providers/ansible_tower/configuration_manager/event_catcher.rb
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
app/models/manageiq/providers/ansible_tower/configuration_manager/playbook.rb
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/models/manageiq/providers/ansible_tower/configuration_manager/refresh_worker.rb
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
app/models/manageiq/providers/ansible_tower/configuration_manager/refresh_worker/runner.rb
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
app/models/manageiq/providers/ansible_tower/configuration_manager/refresher.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class ManageIQ::Providers::AutomationManager < ::ExtManagementSystem | ||
require_nested :InventoryGroup | ||
require_nested :InventoryRootGroup | ||
|
||
has_many :configured_systems, :dependent => :destroy, :foreign_key => "manager_id" | ||
has_many :configuration_profiles, :dependent => :destroy, :foreign_key => "manager_id" | ||
has_many :configuration_scripts, :dependent => :destroy, :foreign_key => "manager_id" | ||
has_many :inventory_groups, :dependent => :destroy, :foreign_key => "ems_id", :inverse_of => :manager | ||
has_many :configuration_script_sources, :dependent => :destroy, :foreign_key => "manager_id" | ||
|
||
virtual_column :total_configuration_profiles, :type => :integer | ||
virtual_column :total_configured_systems, :type => :integer | ||
|
||
def self.hostname_required? | ||
false | ||
end | ||
|
||
def total_configuration_profiles | ||
Rbac.filtered(configuration_profiles, :match_via_descendants => ConfiguredSystem).count | ||
end | ||
|
||
def total_configured_systems | ||
Rbac.filtered(configured_systems, :match_via_descendants => ConfiguredSystem).count | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
.../configuration_manager/inventory_group.rb → ...ers/automation_manager/inventory_group.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
2 changes: 1 addition & 1 deletion
2
...iguration_manager/inventory_root_group.rb → ...utomation_manager/inventory_root_group.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
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
9 changes: 9 additions & 0 deletions
9
app/models/manageiq/providers/embedded_ansible/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,9 @@ | ||
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager < ManageIQ::Providers::EmbeddedAutomationManager | ||
def self.ems_type | ||
@ems_type ||= "embedded_ansible_automation".freeze | ||
end | ||
|
||
def self.description | ||
@description ||= "Embedded Ansible Automation".freeze | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::EmbeddedAutomationManager < ManageIQ::Providers::AutomationManager | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::ExternalAutomationManager < ManageIQ::Providers::AutomationManager | ||
end |
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.
This implies a Settings migration is needed, as well as a change to settings.yml
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.
Follow up PR?
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, just to unblock others, but it must be the next PR so we don't forget. (Normally I'd say "heck no" 😉 )