Skip to content

Commit

Permalink
Merge pull request ManageIQ#11617 from bzwei/service_stack_template
Browse files Browse the repository at this point in the history
Reconnect orchestration stack with its template at post-provisioning
  • Loading branch information
gmcculloug committed Oct 6, 2016
2 parents 876859b + 4bb043d commit ad54db0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/models/service_orchestration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def all_vms
# This is called when provision is completed and stack is added to VMDB through a refresh
def post_provision_configure
add_stack_to_resource

link_orchestration_template
assign_vms_owner
end

Expand All @@ -93,6 +93,12 @@ def add_stack_to_resource
add_resource!(@orchestration_stack) if @orchestration_stack
end

def link_orchestration_template
# some orchestration stacks do not have associations with their templates in their provider, we can link them here
return if @orchestration_stack.nil? || @orchestration_stack.orchestration_template
@orchestration_stack.update_attributes(:orchestration_template => orchestration_template)
end

def assign_vms_owner
all_vms.each do |vm|
vm.update_attributes(:evm_owner_id => evm_owner_id, :miq_group_id => miq_group_id)
Expand Down
11 changes: 10 additions & 1 deletion spec/models/service_orchestration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,18 @@
end
end

it 'add the provisioned stack to service resources' do
it 'adds the provisioned stack to service resources' do
service.post_provision_configure
expect(service.service_resources.find_by(:resource_type => 'OrchestrationStack').resource).to eq(@resulting_stack)
end

it 'reconnects cataloged stack with the orchestration template' do
# purposely disconnect the template
@resulting_stack.update_attributes!(:orchestration_template => nil)

service.post_provision_configure
@resulting_stack.reload
expect(@resulting_stack.orchestration_template).to eq(template_in_st)
end
end
end

0 comments on commit ad54db0

Please sign in to comment.