Skip to content

Commit

Permalink
add jobs to service_ansible_playbook
Browse files Browse the repository at this point in the history
jobs to orchestration stacks

move from service_ansible_playbook to service
  • Loading branch information
Jillian Tullo committed Mar 9, 2017
1 parent c313acc commit b92057d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Service < ApplicationRecord
virtual_has_many :vms
virtual_has_many :all_vms
virtual_has_many :power_states, :uses => :all_vms
virtual_has_many :orchestration_stacks
virtual_total :v_total_vms, :vms

virtual_has_one :custom_actions
Expand Down Expand Up @@ -224,6 +225,10 @@ def atomic?
service_template ? service_template.atomic? : children.empty?
end

def orchestration_stacks
service_resources.where(:resource_type => 'OrchestrationStack').collect(&:resource)
end

def map_composite_power_states(action)
action_name = "#{action}_action"
service_actions = service_resources.map(&action_name.to_sym).uniq
Expand Down
11 changes: 11 additions & 0 deletions spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,17 @@
end
end

describe '#orchestration_stacks' do
let(:service) { FactoryGirl.create(:service) }
let(:tower_job) { FactoryGirl.create(:embedded_ansible_job) }

before { service.add_resource!(tower_job, :name => ResourceAction::PROVISION) }

it 'returns the orchestration stacks' do
expect(service.orchestration_stacks).to eq([tower_job])
end
end

def create_deep_tree
@service = FactoryGirl.create(:service)
@service_c1 = FactoryGirl.create(:service, :service => @service)
Expand Down

0 comments on commit b92057d

Please sign in to comment.