Skip to content

Commit

Permalink
bugfix to Enforcing Anti-Affinity Rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter McGowan committed Feb 13, 2017
1 parent b83ed57 commit bf8f378
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 71 deletions.
2 changes: 1 addition & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Summary

* [Introduction](README.md)
* [Preface](preface.asciidoc.wip)
* [Preface](preface.asciidoc)
* [Part 1](part1.asciidoc)
* [Introduction to CloudForms and ManageIQ](introduction/chapter.asciidoc)
* [Introduction to the Automate Datastore](introduction_to_the_automate_datastore/chapter.asciidoc)
Expand Down
22 changes: 12 additions & 10 deletions enforcing_anti_affinity_rules/chapter.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ begin
# Find out this VM's server_role tag
#
our_server_role = vm.tags(:server_role).first
$evm.log(:info, "VM #{vm.name} has a server_role tag of: #{our_server_role}")
#
# Loop through the other VMs on the same host
#
vm.host.vms.each do |this_vm| # <-- Two levels of Association
next if this_vm.name == vm.name
if this_vm.tags(:server_role).first == our_server_role
$evm.log(:info, "VM #{this_vm.name} also has a server_role tag of: \
unless our_server_role.blank?
$evm.log(:info, "VM #{vm.name} has a server_role tag of: #{our_server_role}")
#
# Loop through the other VMs on the same host
#
vm.host.vms.each do |this_vm| # <-- Two levels of Association
next if this_vm.name == vm.name
if this_vm.tags(:server_role).first == our_server_role
$evm.log(:info, "VM #{this_vm.name} also has a server_role tag of: \
#{our_server_role}, taking remedial action")
new_host = relocate_vm(vm)
send_email('EvmGroup-administrator', vm.name, new_host)
new_host = relocate_vm(vm)
send_email('EvmGroup-administrator', vm.name, new_host)
end
end
end
exit MIQ_OK
Expand Down
22 changes: 12 additions & 10 deletions enforcing_anti_affinity_rules/scripts/enforce_anti_affinity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ def send_email(group_name, vm_name, new_host)
# Find out this VM's server_role tag
#
our_server_role = vm.tags(:server_role).first
$evm.log(:info, "VM #{vm.name} has a server_role tag of: #{our_server_role}")
#
# Loop through the other VMs on the same host
#
vm.host.vms.each do |this_vm|
next if this_vm.name == vm.name # Skip if this VM == our VM
if this_vm.tags(:server_role).first == our_server_role
$evm.log(:info, "VM #{this_vm.name} also has a server_role tag of: #{our_server_role}, taking remedial action")
new_host = relocate_vm(vm)
send_email('EvmGroup-administrator', vm.name, new_host)
unless our_server_role.blank?
$evm.log(:info, "VM #{vm.name} has a server_role tag of: #{our_server_role}")
#
# Loop through the other VMs on the same host
#
vm.host.vms.each do |this_vm|
next if this_vm.name == vm.name # Skip if this VM == our VM
if this_vm.tags(:server_role).first == our_server_role
$evm.log(:info, "VM #{this_vm.name} also has a server_role tag of: #{our_server_role}, taking remedial action")
new_host = relocate_vm(vm)
send_email('EvmGroup-administrator', vm.name, new_host)
end
end
end
exit MIQ_OK
Expand Down
Loading

0 comments on commit bf8f378

Please sign in to comment.