Skip to content

Commit

Permalink
workflow_node
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswnl committed Jun 1, 2018
1 parent 2926b62 commit ff91490
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 27 deletions.
3 changes: 3 additions & 0 deletions app/models/configuration_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ class ConfigurationScript < ConfigurationScriptBase
def self.base_model
ConfigurationScript
end

has_many :workflow_nodes
has_many :workflows, :through => :workflow_nodes
end
14 changes: 0 additions & 14 deletions app/models/configuration_script_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ class ConfigurationScriptBase < ApplicationRecord
has_many :authentications,
:through => :authentication_configuration_script_bases

has_many :parent_nodes,
:foreign_key => :child_id,
:class_name => "ConfigurationScriptNode"
has_many :parents,
:through => :parent_nodes,
:source => :parent

has_many :child_nodes,
:foreign_key => :parent_id,
:class_name => "ConfigurationScriptNode"
has_many :children,
:through => :child_nodes,
:source => :child

scope :with_manager, ->(manager_id) { where(:manager_id => manager_id) }

include ProviderObjectMixin
Expand Down
5 changes: 0 additions & 5 deletions app/models/configuration_script_node.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/models/configuration_script_workflow.rb

This file was deleted.

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 @@ -8,11 +8,13 @@ class ManageIQ::Providers::AutomationManager < ManageIQ::Providers::BaseManager
require_nested :InventoryRootGroup
require_nested :OrchestrationStack
require_nested :Workflow
require_nested :WorkflowNode

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 :workflows, :dependent => :destroy, :foreign_key => "manager_id"
has_many :workflow_nodes, :dependent => :destroy, :foreign_key => "manager_id"
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,2 @@
class ManageIQ::Providers::AutomationManager::WorkflowNode < ::WorkflowNode
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class ManageIQ::Providers::ExternalAutomationManager < ManageIQ::Providers::Auto
require_nested :ConfiguredSystem
require_nested :OrchestrationStack
require_nested :Workflow

require_nested :WorkflowNode
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ManageIQ::Providers::ExternalAutomationManager::WorkflowNode < ManageIQ::Providers::AutomationManager::WorkflowNode
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 @@ -13,6 +13,16 @@ def has_automation_manager_workflows(options = {})
}.merge(options))
end

def has_automation_manager_workflow_nodes(options = {})
has_workflow_nodes({
:model_class => provider_module::AutomationManager::WorkflowNode,
:association => :workflow_nodes,
:builder_params => {
:manager => ->(persister) { persister.manager }
},
}.merge(options))
end

def has_automation_manager_configuration_scripts(options = {})
has_configuration_scripts({
:model_class => provider_module::AutomationManager::ConfigurationScript,
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 @@ -22,6 +22,14 @@ def has_workflows(options = {})
}.merge(options))
end

def has_workflow_nodes(options = {})
has_inventory({
:model_class => ::WorkflowNode,
:manager_ref => [:manager_ref],
:inventory_object_attributes => %i(conditions parent configuration_script workflow),
}.merge(options))
end

def has_configuration_scripts(options = {})
has_inventory({
:model_class => ::ConfigurationScript,
Expand Down
2 changes: 2 additions & 0 deletions app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ class Workflow < ConfigurationScriptBase
def self.base_model
Workflow
end
has_many :workflow_nodes
has_many :configuration_scripts, :through => :workflow_nodes
end
5 changes: 5 additions & 0 deletions app/models/workflow_node.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class WorkflowNode < ApplicationRecord
belongs_to :parent, :foreign_key => :parent_id, :class_name => "WorkflowNode"
belongs_to :configuration_script
belongs_to :workflow
end

0 comments on commit ff91490

Please sign in to comment.