Skip to content

Commit

Permalink
Add method deploy_orchestration_stack_queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Jan 22, 2019
1 parent 526045d commit c117a9d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/models/service_orchestration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,45 @@ def deploy_orchestration_stack
save_create_options
end

def deploy_orchestration_stack_queue
userid = User.current_user.try(:userid)
task_opts = {
:action => "deploying Orchestration Stack for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'deploy_orchestration_stack',
:instance_id => id,
:role => 'ems_operations',
:zone => orchestration_manager.my_zone,
:args => []
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def update_orchestration_stack
# use orchestration_template from service_template, which may be different from existing orchestration_template
orchestration_stack.raw_update_stack(service_template.orchestration_template, update_options)
end

def update_orchestration_stack_queue
userid = User.current_user.try(:userid)
task_opts = {
:action => "updating Orchestration Stack for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'update_orchestration_stack',
:instance_id => id,
:role => 'ems_operations',
:zone => orchestration_manager.my_zone,
:args => []
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def orchestration_stack
@orchestration_stack ||= service_resources.find { |sr| sr.resource.kind_of?(OrchestrationStack) }.try(:resource)

Expand Down
13 changes: 13 additions & 0 deletions spec/models/service_orchestration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,17 @@
expect(@resulting_stack.orchestration_template).to eq(template_in_st)
end
end

describe '#deploy_orchestration_stack_queue' do
it 'queues deploy_orchestration_stack' do
service.deploy_orchestration_stack_queue
expect(MiqQueue.find_by(:instance_id => service.id)).to have_attributes(
'method_name' => 'deploy_orchestration_stack',
'class_name' => service.class.name,
'zone' => manager_in_st.my_zone,
'role' => 'ems_operations',
'args' => []
)
end
end
end

0 comments on commit c117a9d

Please sign in to comment.