Skip to content

Commit 64fff70

Browse files
committed
Add a common ServiceTemplateAutomation parent class
Add a common parent class that Awx/AnsibleTower/TerraformEnterprise can inherit from.
1 parent c1a7616 commit 64fff70

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

app/models/service_automation.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ServiceAutomation < Service
2+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ServiceTemplateAutomation < ServiceTemplate
2+
include ServiceTemplateAutomationMixin
3+
4+
def generic?
5+
prov_type.start_with?("generic_")
6+
end
7+
end

app/models/service_template_awx.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
class ServiceTemplateAwx < ServiceTemplate
1+
class ServiceTemplateAwx < ServiceTemplateAutomation
22
include ServiceConfigurationMixin
3-
include ServiceTemplateAutomationMixin
43

54
before_update :remove_invalid_resource
65

76
alias job_template configuration_script
87
alias job_template= configuration_script=
98

9+
def create_subtasks(_parent_service_task, _parent_service)
10+
if generic?
11+
# no sub task is needed for this service
12+
[]
13+
else
14+
super
15+
end
16+
end
17+
1018
def self.create_catalog_item(options, _auth_user = nil)
1119
transaction do
1220
create_from_options(options).tap do |service_template|
@@ -31,11 +39,6 @@ def remove_invalid_resource
3139
end
3240
end
3341

34-
def create_subtasks(_parent_service_task, _parent_service)
35-
# no sub task is needed for this service
36-
[]
37-
end
38-
3942
def self.default_provisioning_entry_point(_service_type)
4043
'/AutomationManagement/AnsibleTower/Service/Provisioning/StateMachines/Provision/CatalogItemInitialization'
4144
end

spec/factories/service_template.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
factory :service_template do
33
sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" }
44
end
5+
factory :service_template_automation, :class => 'ServiceTemplateAutomation', :parent => :service_template
56
factory :service_template_orchestration, :class => 'ServiceTemplateOrchestration', :parent => :service_template
67
factory :service_template_ansible_playbook, :class => 'ServiceTemplateAnsiblePlaybook', :parent => :service_template
7-
factory :service_template_ansible_tower, :class => 'ServiceTemplateAnsibleTower', :parent => :service_template
8+
factory :service_template_ansible_tower, :class => 'ServiceTemplateAnsibleTower', :parent => :service_template_automation
89
factory :service_template_container_template, :class => 'ServiceTemplateContainerTemplate', :parent => :service_template
910

1011
trait :with_provision_resource_action_and_dialog do

0 commit comments

Comments
 (0)