-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible refresh parser as graph refresh
- Loading branch information
Showing
8 changed files
with
124 additions
and
177 deletions.
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
111 changes: 0 additions & 111 deletions
111
app/models/manageiq/providers/ansible_tower/automation_manager/refresh_parser.rb
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
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
18 changes: 18 additions & 0 deletions
18
app/models/manageiq/providers/ansible_tower/automation_manager/refresh_worker/collector.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,18 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker::Collector | ||
def initialize(ems, _options = nil) | ||
@ems = ems | ||
@connection = ems.connect | ||
end | ||
|
||
def inventories | ||
@connection.api.inventories.all | ||
end | ||
|
||
def hosts | ||
@connection.api.hosts.all | ||
end | ||
|
||
def job_templates | ||
@connection.api.job_templates.all | ||
end | ||
end |
77 changes: 77 additions & 0 deletions
77
app/models/manageiq/providers/ansible_tower/automation_manager/refresh_worker/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
class ManageIQ::Providers::AnsibleTower::AutomationManager::RefreshWorker::Parser | ||
attr_reader :inventory, :ems | ||
|
||
def initialize(ems, target, inventory) | ||
@ems = ems | ||
@target = target | ||
@inventory = inventory | ||
end | ||
|
||
def parse | ||
[ | ||
inventory_groups, | ||
configured_systems, | ||
configuration_scripts, | ||
] | ||
end | ||
|
||
def inventory_groups | ||
@inventory_groups ||= ManagerRefresh::InventoryCollection.new( | ||
ManageIQ::Providers::AutomationManager::InventoryRootGroup, | ||
:association => :inventory_root_groups, | ||
:parent => ems, | ||
).tap do |c| | ||
inventory.inventories.each do |i| | ||
c << c.new_inventory_object( | ||
# to_s should not be necessary, but its needed to resolve lazy find | ||
:ems_ref => i.id.to_s, | ||
:manager => ems, | ||
:name => i.name, | ||
) | ||
end | ||
end | ||
end | ||
|
||
def configured_systems | ||
ManagerRefresh::InventoryCollection.new( | ||
ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem, | ||
:association => :configured_systems, | ||
:manager_ref => [:manager_ref], | ||
:parent => ems, | ||
).tap do |c| | ||
inventory.hosts.each do |i| | ||
c << c.new_inventory_object( | ||
:manager_ref => i.id, | ||
:manager => ems, | ||
:hostname => i.name, | ||
# to_s should not be necessary, but its needed to resolve lazy find | ||
:inventory_root_group => inventory_groups.lazy_find(i.inventory_id.to_s), | ||
:virtual_instance_ref => i.instance_id, | ||
# FIXME: dont access db here | ||
:counterpart => Vm.find_by(:uid_ems => i.instance_id) | ||
) | ||
end | ||
end | ||
end | ||
|
||
def configuration_scripts | ||
ManagerRefresh::InventoryCollection.new( | ||
ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript, | ||
:association => :configuration_scripts, | ||
:manager_ref => [:manager_ref], | ||
:parent => ems, | ||
).tap do |c| | ||
inventory.job_templates.each do |i| | ||
c << c.new_inventory_object( | ||
:description => i.description, | ||
:inventory_root_group => inventory_groups.lazy_find(i.inventory_id.to_s), | ||
:manager => ems, | ||
:manager_ref => i.id.to_s, | ||
:name => i.name, | ||
:survey_spec => i.survey_spec_hash, | ||
:variables => i.extra_vars_hash, | ||
) | ||
end | ||
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
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
59 changes: 0 additions & 59 deletions
59
spec/models/manageiq/providers/ansible_tower/automation_manager/refresh_parser_spec.rb
This file was deleted.
Oops, something went wrong.