Skip to content

Commit

Permalink
Integrate with external Tower Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswnl committed Jun 7, 2018
1 parent bfb744c commit dd1215d
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/configuration_workflow.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ConfigurationWorkflow < ConfigurationScriptBase
def self.base_model
ConfigurationWorkflow
end
end
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/automation_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ManageIQ::Providers::AutomationManager < ManageIQ::Providers::BaseManager
require_nested :ConfigurationScript
require_nested :ConfigurationScriptPayload
require_nested :ConfigurationScriptSource
require_nested :ConfigurationWorkflow
require_nested :ConfiguredSystem
require_nested :InventoryGroup
require_nested :InventoryRootGroup
Expand All @@ -11,6 +12,7 @@ class ManageIQ::Providers::AutomationManager < ManageIQ::Providers::BaseManager
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 :configuration_workflows, :dependent => :destroy, :foreign_key => "manager_id", :inverse_of => :manager
has_many :credentials, :class_name => "ManageIQ::Providers::AutomationManager::Authentication",
:as => :resource, :dependent => :destroy
has_many :inventory_groups, :dependent => :destroy, :foreign_key => "ems_id", :inverse_of => :manager
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ManageIQ::Providers::AutomationManager::ConfigurationWorkflow < ::ConfigurationWorkflow
belongs_to :manager, :class_name => "ManageIQ::Providers::AutomationManager", :inverse_of => :configuration_workflows
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ManageIQ::Providers::EmbeddedAnsible::AutomationManager < ManageIQ::Provid

require_nested :ConfigurationScript
require_nested :ConfigurationScriptSource
require_nested :ConfigurationWorkflow
require_nested :ConfiguredSystem
require_nested :EventCatcher
require_nested :EventParser
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationWorkflow < ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationWorkflow
include ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::ConfigurationWorkflow
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ManageIQ::Providers::EmbeddedAutomationManager::ConfigurationWorkflow < ManageIQ::Providers::AutomationManager::ConfigurationWorkflow
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ManageIQ::Providers::ExternalAutomationManager < ManageIQ::Providers::Auto
require_nested :ConfigurationScript
require_nested :ConfigurationScriptPayload
require_nested :ConfigurationScriptSource
require_nested :ConfigurationWorkflow
require_nested :ConfiguredSystem
require_nested :OrchestrationStack
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ManageIQ::Providers::ExternalAutomationManager::ConfigurationWorkflow < ManageIQ::Providers::AutomationManager::ConfigurationWorkflow
end
10 changes: 10 additions & 0 deletions app/models/manager_refresh/inventory/automation_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def has_automation_manager_configuration_script_sources(options = {})
}.merge(options))
end

def has_automation_manager_configuration_workflows(options = {})
has_configuration_workflows({
:model_class => provider_module::AutomationManager::ConfigurationWorkflow,
:association => :configuration_workflows,
:builder_params => {
:manager => ->(persister) { persister.manager }
},
}.merge(options))
end

def has_automation_manager_configured_systems(options = {})
has_configured_systems({
:model_class => provider_module::AutomationManager::ConfiguredSystem,
Expand Down
8 changes: 8 additions & 0 deletions app/models/manager_refresh/inventory/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def has_configuration_script_payloads(options = {})
}.merge(options))
end

def has_configuration_workflows(options = {})
has_inventory({
:model_class => ::ConfigurationWorkflow,
:manager_ref => [:manager_ref],
:inventory_object_attributes => %i(name description survey_spec variables),
}.merge(options))
end

def has_configured_systems(options = {})
has_inventory({
:model_class => ::ConfiguredSystem,
Expand Down
1 change: 1 addition & 0 deletions spec/factories/configuration_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:parent => :configuration_script_payload

factory :configuration_script, :class => "ConfigurationScript", :parent => :configuration_script_base
factory :configuration_workflow, :class => "ConfigurationWorkflow", :parent => :configuration_script_base
factory :ansible_configuration_script,
:class => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript",
:parent => :configuration_script
Expand Down
7 changes: 7 additions & 0 deletions spec/factories/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@
end
end

trait(:configuration_workflow) do
after(:create) do |x|
type = (x.type.split("::")[0..2] + %w(AutomationManager ConfigurationWorkflow)).join("::")
x.configuration_workflows << FactoryGirl.create(:configuration_workflow, :type => type)
end
end

# Leaf classes for automation_manager

factory :automation_manager_ansible_tower,
Expand Down

0 comments on commit dd1215d

Please sign in to comment.