-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15645 from d-m-u/merge-retirement-checks
Merge retirement checks
- Loading branch information
Showing
12 changed files
with
48 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class RetirementManager | ||
def self.check | ||
ems_ids = MiqServer.my_server.zone.ext_management_system_ids | ||
[LoadBalancer, OrchestrationStack, Vm, Service].flat_map do |i| | ||
instances = not_retired_with_ems(i, ems_ids) | ||
instances.each(&:retirement_check) | ||
end | ||
end | ||
|
||
def self.not_retired_with_ems(model, ems_ids) | ||
return model.scheduled_to_retire unless model.column_names.include?('ems_id') # Service not assigned to ems_ids | ||
model.scheduled_to_retire.where(:ems_id => ems_ids) | ||
end | ||
private_class_method :not_retired_with_ems | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
describe RetirementManager do | ||
describe "#check" do | ||
it "with retirement date, runs retirement checks" do | ||
_, _, zone = EvmSpecHelper.local_guid_miq_server_zone | ||
ems = FactoryGirl.create(:ems_network, :zone => zone) | ||
|
||
load_balancer = FactoryGirl.create(:load_balancer, :retires_on => Time.zone.today + 1.day, :ext_management_system => ems) | ||
FactoryGirl.create(:load_balancer, :retired => true) | ||
orchestration_stack = FactoryGirl.create(:orchestration_stack, :retires_on => Time.zone.today + 1.day, :ext_management_system => ems) | ||
FactoryGirl.create(:orchestration_stack, :retired => true) | ||
vm = FactoryGirl.create(:vm, :retires_on => Time.zone.today + 1.day, :ems_id => ems.id) | ||
FactoryGirl.create(:vm, :retired => true) | ||
service = FactoryGirl.create(:service, :retires_on => Time.zone.today + 1.day) | ||
FactoryGirl.create(:service, :retired => true) | ||
|
||
expect(RetirementManager.check).to match_array([load_balancer, orchestration_stack, vm, service]) | ||
end | ||
end | ||
end |