From 1eb5531b63a12302b3fc2da7534b5ef2bf56e67e Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Fri, 13 Apr 2018 10:49:46 -0400 Subject: [PATCH] Add method retire_now to container OrchestrationStack. So the container service may be retired. https://bugzilla.redhat.com/show_bug.cgi?id=1564154 --- .../providers/container_manager/orchestration_stack.rb | 5 +++++ spec/factories/orchestration_stack.rb | 2 ++ .../container_manager/orchestration_stack_spec.rb | 10 ++++++++++ 3 files changed, 17 insertions(+) create mode 100644 spec/models/manageiq/providers/container_manager/orchestration_stack_spec.rb diff --git a/app/models/manageiq/providers/container_manager/orchestration_stack.rb b/app/models/manageiq/providers/container_manager/orchestration_stack.rb index 15f5b5fa236..0b5469b2b03 100644 --- a/app/models/manageiq/providers/container_manager/orchestration_stack.rb +++ b/app/models/manageiq/providers/container_manager/orchestration_stack.rb @@ -22,6 +22,11 @@ def self.status_class "#{name}::Status".constantize end + def retire_now(requester = nil) + update_attributes(:retirement_requester => requester) + finish_retirement + end + def raw_status failed = resources.any? { |obj| obj.resource_status == 'failed' } if failed diff --git a/spec/factories/orchestration_stack.rb b/spec/factories/orchestration_stack.rb index 10482594967..6dc47d06fc4 100644 --- a/spec/factories/orchestration_stack.rb +++ b/spec/factories/orchestration_stack.rb @@ -74,4 +74,6 @@ factory :embedded_ansible_job, :class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job" factory :orchestration_stack_vmware_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Vmware::CloudManager::OrchestrationStack" + + factory :orchestration_stack_container, :parent => :orchestration_stack, :class => "ManageIQ::Providers::ContainerManager::OrchestrationStack" end diff --git a/spec/models/manageiq/providers/container_manager/orchestration_stack_spec.rb b/spec/models/manageiq/providers/container_manager/orchestration_stack_spec.rb new file mode 100644 index 00000000000..bffced763a2 --- /dev/null +++ b/spec/models/manageiq/providers/container_manager/orchestration_stack_spec.rb @@ -0,0 +1,10 @@ +describe ManageIQ::Providers::ContainerManager::OrchestrationStack do + let(:stack) { FactoryGirl.create(:orchestration_stack_container) } + + describe '#retire_now' do + it 'retires the orchestration stack' do + expect(stack).to receive(:finish_retirement).once + stack.retire_now + end + end +end